~ubuntu-branches/ubuntu/saucy/libv8/saucy

« back to all changes in this revision

Viewing changes to src/utils.h

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2012-04-07 16:26:13 UTC
  • mfrom: (15.1.27 sid)
  • Revision ID: package-import@ubuntu.com-20120407162613-dqo1m6w9r3fh8tst
Tags: 3.8.9.16-3
* mipsel build fixes :
  + v8_use_mips_abi_hardfloat=false, this lowers EABI requirements.
  + v8_can_use_fpu_instructions=false, detect if FPU is present.
  + set -Wno-unused-but-set-variable only on mipsel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright 2011 the V8 project authors. All rights reserved.
 
1
// Copyright 2012 the V8 project authors. All rights reserved.
2
2
// Redistribution and use in source and binary forms, with or without
3
3
// modification, are permitted provided that the following conditions are
4
4
// met:
252
252
// ----------------------------------------------------------------------------
253
253
// Hash function.
254
254
 
 
255
static const uint32_t kZeroHashSeed = 0;
 
256
 
255
257
// Thomas Wang, Integer Hash Functions.
256
258
// http://www.concentric.net/~Ttwang/tech/inthash.htm
257
 
inline uint32_t ComputeIntegerHash(uint32_t key) {
 
259
inline uint32_t ComputeIntegerHash(uint32_t key, uint32_t seed) {
258
260
  uint32_t hash = key;
 
261
  hash = hash ^ seed;
259
262
  hash = ~hash + (hash << 15);  // hash = (hash << 15) - hash - 1;
260
263
  hash = hash ^ (hash >> 12);
261
264
  hash = hash + (hash << 2);
280
283
 
281
284
inline uint32_t ComputePointerHash(void* ptr) {
282
285
  return ComputeIntegerHash(
283
 
      static_cast<uint32_t>(reinterpret_cast<intptr_t>(ptr)));
 
286
      static_cast<uint32_t>(reinterpret_cast<intptr_t>(ptr)),
 
287
      v8::internal::kZeroHashSeed);
284
288
}
285
289
 
286
290
 
927
931
  explicit EnumSet(T bits = 0) : bits_(bits) {}
928
932
  bool IsEmpty() const { return bits_ == 0; }
929
933
  bool Contains(E element) const { return (bits_ & Mask(element)) != 0; }
 
934
  bool ContainsAnyOf(const EnumSet& set) const {
 
935
    return (bits_ & set.bits_) != 0;
 
936
  }
930
937
  void Add(E element) { bits_ |= Mask(element); }
 
938
  void Add(const EnumSet& set) { bits_ |= set.bits_; }
931
939
  void Remove(E element) { bits_ &= ~Mask(element); }
 
940
  void Remove(const EnumSet& set) { bits_ &= ~set.bits_; }
 
941
  void RemoveAll() { bits_ = 0; }
 
942
  void Intersect(const EnumSet& set) { bits_ &= set.bits_; }
932
943
  T ToIntegral() const { return bits_; }
 
944
  bool operator==(const EnumSet& set) { return bits_ == set.bits_; }
933
945
 
934
946
 private:
935
947
  T Mask(E element) const {