diff options
Diffstat (limited to 'deps/v8/src/objects-inl.h')
-rw-r--r-- | deps/v8/src/objects-inl.h | 76 |
1 files changed, 32 insertions, 44 deletions
diff --git a/deps/v8/src/objects-inl.h b/deps/v8/src/objects-inl.h index 06a13df5a..95a0eca6a 100644 --- a/deps/v8/src/objects-inl.h +++ b/deps/v8/src/objects-inl.h @@ -1030,10 +1030,7 @@ int Smi::value() { Smi* Smi::FromInt(int value) { ASSERT(Smi::IsValid(value)); - int smi_shift_bits = kSmiTagSize + kSmiShiftSize; - intptr_t tagged_value = - (static_cast<intptr_t>(value) << smi_shift_bits) | kSmiTag; - return reinterpret_cast<Smi*>(tagged_value); + return reinterpret_cast<Smi*>(Internals::IntToSmi(value)); } @@ -1111,28 +1108,8 @@ Failure* Failure::Construct(Type type, intptr_t value) { bool Smi::IsValid(intptr_t value) { -#ifdef DEBUG - bool in_range = (value >= kMinValue) && (value <= kMaxValue); -#endif - -#ifdef V8_TARGET_ARCH_X64 - // To be representable as a long smi, the value must be a 32-bit integer. - bool result = (value == static_cast<int32_t>(value)); -#else - // To be representable as an tagged small integer, the two - // most-significant bits of 'value' must be either 00 or 11 due to - // sign-extension. To check this we add 01 to the two - // most-significant bits, and check if the most-significant bit is 0 - // - // CAUTION: The original code below: - // bool result = ((value + 0x40000000) & 0x80000000) == 0; - // may lead to incorrect results according to the C language spec, and - // in fact doesn't work correctly with gcc4.1.1 in some cases: The - // compiler may produce undefined results in case of signed integer - // overflow. The computation must be done w/ unsigned ints. - bool result = (static_cast<uintptr_t>(value + 0x40000000U) < 0x80000000U); -#endif - ASSERT(result == in_range); + bool result = Internals::IsValidSmi(value); + ASSERT_EQ(result, value >= kMinValue && value <= kMaxValue); return result; } @@ -1484,10 +1461,17 @@ void JSObject::initialize_properties() { void JSObject::initialize_elements() { - ASSERT(map()->has_fast_smi_or_object_elements() || - map()->has_fast_double_elements()); - ASSERT(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array())); - WRITE_FIELD(this, kElementsOffset, GetHeap()->empty_fixed_array()); + if (map()->has_fast_smi_or_object_elements() || + map()->has_fast_double_elements()) { + ASSERT(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array())); + WRITE_FIELD(this, kElementsOffset, GetHeap()->empty_fixed_array()); + } else if (map()->has_external_array_elements()) { + ExternalArray* empty_array = GetHeap()->EmptyExternalArrayForMap(map()); + ASSERT(!GetHeap()->InNewSpace(empty_array)); + WRITE_FIELD(this, kElementsOffset, empty_array); + } else { + UNREACHABLE(); + } } @@ -1521,9 +1505,19 @@ MaybeObject* JSObject::ResetElements() { MaybeObject* JSObject::AllocateStorageForMap(Map* map) { ASSERT(this->map()->inobject_properties() == map->inobject_properties()); - ElementsKind expected_kind = this->map()->elements_kind(); - if (map->elements_kind() != expected_kind) { - MaybeObject* maybe_map = map->AsElementsKind(expected_kind); + ElementsKind obj_kind = this->map()->elements_kind(); + ElementsKind map_kind = map->elements_kind(); + if (map_kind != obj_kind) { + ElementsKind to_kind = map_kind; + if (IsMoreGeneralElementsKindTransition(map_kind, obj_kind) || + IsDictionaryElementsKind(obj_kind)) { + to_kind = obj_kind; + } + MaybeObject* maybe_obj = + IsDictionaryElementsKind(to_kind) ? NormalizeElements() + : TransitionElementsKind(to_kind); + if (maybe_obj->IsFailure()) return maybe_obj; + MaybeObject* maybe_map = map->AsElementsKind(to_kind); if (!maybe_map->To(&map)) return maybe_map; } int total_size = @@ -3608,17 +3602,15 @@ bool Map::CanBeDeprecated() { if (FLAG_track_double_fields && details.representation().IsDouble()) { return true; } + if (FLAG_track_heap_object_fields && + details.representation().IsHeapObject()) { + return true; + } } return false; } -Handle<Map> Map::CurrentMapForDeprecated(Handle<Map> map) { - if (!map->is_deprecated()) return map; - return GeneralizeRepresentation(map, 0, Representation::Smi()); -} - - void Map::NotifyLeafMapLayoutChange() { dependent_code()->DeoptimizeDependentCodeGroup( GetIsolate(), @@ -4668,6 +4660,7 @@ BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, dont_optimize, kDontOptimize) BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, dont_inline, kDontInline) BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, dont_cache, kDontCache) +BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, dont_flush, kDontFlush) BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_generator, kIsGenerator) void SharedFunctionInfo::BeforeVisitingPointers() { @@ -4675,11 +4668,6 @@ void SharedFunctionInfo::BeforeVisitingPointers() { } -void SharedFunctionInfo::ClearOptimizedCodeMap() { - set_optimized_code_map(Smi::FromInt(0)); -} - - ACCESSORS(CodeCache, default_cache, FixedArray, kDefaultCacheOffset) ACCESSORS(CodeCache, normal_type_cache, Object, kNormalTypeCacheOffset) |