Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Side by Side Diff: src/objects-inl.h

Issue 2028983002: Introduce IsUndefined(Isolate*) and IsTheHole(Isolate*) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: reducing old cmpare patterns Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // Review notes: 5 // Review notes:
6 // 6 //
7 // - The use of macros in these inline functions may seem superfluous 7 // - The use of macros in these inline functions may seem superfluous
8 // but it is absolutely needed to make sure gcc generates optimal 8 // but it is absolutely needed to make sure gcc generates optimal
9 // code. gcc is not happy when attempting to inline too deep. 9 // code. gcc is not happy when attempting to inline too deep.
10 // 10 //
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 #undef SIMD128_TYPE_CHECKER 155 #undef SIMD128_TYPE_CHECKER
156 156
157 #define IS_TYPE_FUNCTION_DEF(type_) \ 157 #define IS_TYPE_FUNCTION_DEF(type_) \
158 bool Object::Is##type_() const { \ 158 bool Object::Is##type_() const { \
159 return IsHeapObject() && HeapObject::cast(this)->Is##type_(); \ 159 return IsHeapObject() && HeapObject::cast(this)->Is##type_(); \
160 } 160 }
161 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DEF) 161 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DEF)
162 ODDBALL_LIST(IS_TYPE_FUNCTION_DEF) 162 ODDBALL_LIST(IS_TYPE_FUNCTION_DEF)
163 #undef IS_TYPE_FUNCTION_DEF 163 #undef IS_TYPE_FUNCTION_DEF
164 164
165 bool HeapObject::IsTheHole(Isolate* isolate) const {
166 return this == isolate->heap()->the_hole_value();
167 }
168
169 bool HeapObject::IsUndefined(Isolate* isolate) const {
170 return this == isolate->heap()->undefined_value();
171 }
172
173 bool Object::IsTheHole(Isolate* isolate) const {
174 return this == isolate->heap()->the_hole_value();
175 }
176
177 bool Object::IsUndefined(Isolate* isolate) const {
178 return this == isolate->heap()->undefined_value();
179 }
180
165 bool HeapObject::IsString() const { 181 bool HeapObject::IsString() const {
166 return map()->instance_type() < FIRST_NONSTRING_TYPE; 182 return map()->instance_type() < FIRST_NONSTRING_TYPE;
167 } 183 }
168 184
169 bool HeapObject::IsName() const { 185 bool HeapObject::IsName() const {
170 return map()->instance_type() <= LAST_NAME_TYPE; 186 return map()->instance_type() <= LAST_NAME_TYPE;
171 } 187 }
172 188
173 bool HeapObject::IsUniqueName() const { 189 bool HeapObject::IsUniqueName() const {
174 return IsInternalizedString() || IsSymbol(); 190 return IsInternalizedString() || IsSymbol();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 return StringShape(String::cast(this)).IsExternal() && 253 return StringShape(String::cast(this)).IsExternal() &&
238 String::cast(this)->IsOneByteRepresentation(); 254 String::cast(this)->IsOneByteRepresentation();
239 } 255 }
240 256
241 bool HeapObject::IsExternalTwoByteString() const { 257 bool HeapObject::IsExternalTwoByteString() const {
242 if (!IsString()) return false; 258 if (!IsString()) return false;
243 return StringShape(String::cast(this)).IsExternal() && 259 return StringShape(String::cast(this)).IsExternal() &&
244 String::cast(this)->IsTwoByteRepresentation(); 260 String::cast(this)->IsTwoByteRepresentation();
245 } 261 }
246 262
247
248 bool Object::HasValidElements() { 263 bool Object::HasValidElements() {
249 // Dictionary is covered under FixedArray. 264 // Dictionary is covered under FixedArray.
250 return IsFixedArray() || IsFixedDoubleArray() || IsFixedTypedArrayBase(); 265 return IsFixedArray() || IsFixedDoubleArray() || IsFixedTypedArrayBase();
251 } 266 }
252 267
253 268
254 bool Object::KeyEquals(Object* second) { 269 bool Object::KeyEquals(Object* second) {
255 Object* first = this; 270 Object* first = this;
256 if (second->IsNumber()) { 271 if (second->IsNumber()) {
257 if (first->IsNumber()) return first->Number() == second->Number(); 272 if (first->IsNumber()) return first->Number() == second->Number();
(...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1516 1531
1517 ACCESSORS(JSReceiver, properties, FixedArray, kPropertiesOffset) 1532 ACCESSORS(JSReceiver, properties, FixedArray, kPropertiesOffset)
1518 1533
1519 1534
1520 Object** FixedArray::GetFirstElementAddress() { 1535 Object** FixedArray::GetFirstElementAddress() {
1521 return reinterpret_cast<Object**>(FIELD_ADDR(this, OffsetOfElementAt(0))); 1536 return reinterpret_cast<Object**>(FIELD_ADDR(this, OffsetOfElementAt(0)));
1522 } 1537 }
1523 1538
1524 1539
1525 bool FixedArray::ContainsOnlySmisOrHoles() { 1540 bool FixedArray::ContainsOnlySmisOrHoles() {
1526 Object* the_hole = GetHeap()->the_hole_value(); 1541 Isolate* isolate = GetIsolate();
1527 Object** current = GetFirstElementAddress(); 1542 Object** current = GetFirstElementAddress();
1528 for (int i = 0; i < length(); ++i) { 1543 for (int i = 0; i < length(); ++i) {
1529 Object* candidate = *current++; 1544 Object* candidate = *current++;
1530 if (!candidate->IsSmi() && candidate != the_hole) return false; 1545 if (!candidate->IsSmi() && !candidate->IsTheHole(isolate)) return false;
1531 } 1546 }
1532 return true; 1547 return true;
1533 } 1548 }
1534 1549
1535 1550
1536 FixedArrayBase* JSObject::elements() const { 1551 FixedArrayBase* JSObject::elements() const {
1537 Object* array = READ_FIELD(this, kElementsOffset); 1552 Object* array = READ_FIELD(this, kElementsOffset);
1538 return static_cast<FixedArrayBase*>(array); 1553 return static_cast<FixedArrayBase*>(array);
1539 } 1554 }
1540 1555
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1794 Object** objects, 1809 Object** objects,
1795 uint32_t count, 1810 uint32_t count,
1796 EnsureElementsMode mode) { 1811 EnsureElementsMode mode) {
1797 ElementsKind current_kind = object->GetElementsKind(); 1812 ElementsKind current_kind = object->GetElementsKind();
1798 ElementsKind target_kind = current_kind; 1813 ElementsKind target_kind = current_kind;
1799 { 1814 {
1800 DisallowHeapAllocation no_allocation; 1815 DisallowHeapAllocation no_allocation;
1801 DCHECK(mode != ALLOW_COPIED_DOUBLE_ELEMENTS); 1816 DCHECK(mode != ALLOW_COPIED_DOUBLE_ELEMENTS);
1802 bool is_holey = IsFastHoleyElementsKind(current_kind); 1817 bool is_holey = IsFastHoleyElementsKind(current_kind);
1803 if (current_kind == FAST_HOLEY_ELEMENTS) return; 1818 if (current_kind == FAST_HOLEY_ELEMENTS) return;
1804 Heap* heap = object->GetHeap(); 1819 Isolate* isolate = object->GetIsolate();
1805 Object* the_hole = heap->the_hole_value();
1806 for (uint32_t i = 0; i < count; ++i) { 1820 for (uint32_t i = 0; i < count; ++i) {
1807 Object* current = *objects++; 1821 Object* current = *objects++;
1808 if (current == the_hole) { 1822 if (current->IsTheHole(isolate)) {
1809 is_holey = true; 1823 is_holey = true;
1810 target_kind = GetHoleyElementsKind(target_kind); 1824 target_kind = GetHoleyElementsKind(target_kind);
1811 } else if (!current->IsSmi()) { 1825 } else if (!current->IsSmi()) {
1812 if (mode == ALLOW_CONVERTED_DOUBLE_ELEMENTS && current->IsNumber()) { 1826 if (mode == ALLOW_CONVERTED_DOUBLE_ELEMENTS && current->IsNumber()) {
1813 if (IsFastSmiElementsKind(target_kind)) { 1827 if (IsFastSmiElementsKind(target_kind)) {
1814 if (is_holey) { 1828 if (is_holey) {
1815 target_kind = FAST_HOLEY_DOUBLE_ELEMENTS; 1829 target_kind = FAST_HOLEY_DOUBLE_ELEMENTS;
1816 } else { 1830 } else {
1817 target_kind = FAST_DOUBLE_ELEMENTS; 1831 target_kind = FAST_DOUBLE_ELEMENTS;
1818 } 1832 }
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
2001 WRITE_BARRIER(GetHeap(), this, kNextOffset, val); 2015 WRITE_BARRIER(GetHeap(), this, kNextOffset, val);
2002 } 2016 }
2003 } 2017 }
2004 2018
2005 2019
2006 void WeakCell::clear_next(Object* the_hole_value) { 2020 void WeakCell::clear_next(Object* the_hole_value) {
2007 DCHECK_EQ(GetHeap()->the_hole_value(), the_hole_value); 2021 DCHECK_EQ(GetHeap()->the_hole_value(), the_hole_value);
2008 set_next(the_hole_value, SKIP_WRITE_BARRIER); 2022 set_next(the_hole_value, SKIP_WRITE_BARRIER);
2009 } 2023 }
2010 2024
2011 2025 bool WeakCell::next_cleared() { return next()->IsTheHole(GetIsolate()); }
2012 bool WeakCell::next_cleared() { return next()->IsTheHole(); }
2013
2014 2026
2015 int JSObject::GetHeaderSize() { return GetHeaderSize(map()->instance_type()); } 2027 int JSObject::GetHeaderSize() { return GetHeaderSize(map()->instance_type()); }
2016 2028
2017 2029
2018 int JSObject::GetHeaderSize(InstanceType type) { 2030 int JSObject::GetHeaderSize(InstanceType type) {
2019 // Check for the most common kind of JavaScript object before 2031 // Check for the most common kind of JavaScript object before
2020 // falling into the generic switch. This speeds up the internal 2032 // falling into the generic switch. This speeds up the internal
2021 // field operations considerably on average. 2033 // field operations considerably on average.
2022 if (type == JS_OBJECT_TYPE) return JSObject::kHeaderSize; 2034 if (type == JS_OBJECT_TYPE) return JSObject::kHeaderSize;
2023 switch (type) { 2035 switch (type) {
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
2273 bool Object::ToArrayLength(uint32_t* index) { return Object::ToUint32(index); } 2285 bool Object::ToArrayLength(uint32_t* index) { return Object::ToUint32(index); }
2274 2286
2275 2287
2276 bool Object::ToArrayIndex(uint32_t* index) { 2288 bool Object::ToArrayIndex(uint32_t* index) {
2277 return Object::ToUint32(index) && *index != kMaxUInt32; 2289 return Object::ToUint32(index) && *index != kMaxUInt32;
2278 } 2290 }
2279 2291
2280 2292
2281 void Object::VerifyApiCallResultType() { 2293 void Object::VerifyApiCallResultType() {
2282 #if DEBUG 2294 #if DEBUG
2283 if (!(IsSmi() || IsString() || IsSymbol() || IsJSReceiver() || 2295 if (IsSmi()) return;
2284 IsHeapNumber() || IsSimd128Value() || IsUndefined() || IsTrue() || 2296 DCHECK(IsHeapObject());
2285 IsFalse() || IsNull())) { 2297 Isolate* isolate = HeapObject::cast(this)->GetIsolate();
2298 if (!(IsString() || IsSymbol() || IsJSReceiver() || IsHeapNumber() ||
2299 IsSimd128Value() || IsUndefined(isolate) || IsTrue() || IsFalse() ||
2300 IsNull())) {
2286 FATAL("API call returned invalid object"); 2301 FATAL("API call returned invalid object");
2287 } 2302 }
2288 #endif // DEBUG 2303 #endif // DEBUG
2289 } 2304 }
2290 2305
2291 2306
2292 Object* FixedArray::get(int index) const { 2307 Object* FixedArray::get(int index) const {
2293 SLOW_DCHECK(index >= 0 && index < this->length()); 2308 SLOW_DCHECK(index >= 0 && index < this->length());
2294 return READ_FIELD(this, kHeaderSize + index * kPointerSize); 2309 return READ_FIELD(this, kHeaderSize + index * kPointerSize);
2295 } 2310 }
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2458 return data_start() + kFirstIndex + index; 2473 return data_start() + kFirstIndex + index;
2459 } 2474 }
2460 2475
2461 2476
2462 void ArrayList::Set(int index, Object* obj) { 2477 void ArrayList::Set(int index, Object* obj) {
2463 FixedArray::cast(this)->set(kFirstIndex + index, obj); 2478 FixedArray::cast(this)->set(kFirstIndex + index, obj);
2464 } 2479 }
2465 2480
2466 2481
2467 void ArrayList::Clear(int index, Object* undefined) { 2482 void ArrayList::Clear(int index, Object* undefined) {
2468 DCHECK(undefined->IsUndefined()); 2483 DCHECK(undefined->IsUndefined(GetIsolate()));
2469 FixedArray::cast(this) 2484 FixedArray::cast(this)
2470 ->set(kFirstIndex + index, undefined, SKIP_WRITE_BARRIER); 2485 ->set(kFirstIndex + index, undefined, SKIP_WRITE_BARRIER);
2471 } 2486 }
2472 2487
2473 2488
2474 WriteBarrierMode HeapObject::GetWriteBarrierMode( 2489 WriteBarrierMode HeapObject::GetWriteBarrierMode(
2475 const DisallowHeapAllocation& promise) { 2490 const DisallowHeapAllocation& promise) {
2476 Heap* heap = GetHeap(); 2491 Heap* heap = GetHeap();
2477 if (heap->incremental_marking()->IsMarking()) return UPDATE_WRITE_BARRIER; 2492 if (heap->incremental_marking()->IsMarking()) return UPDATE_WRITE_BARRIER;
2478 if (heap->InNewSpace(this)) return SKIP_WRITE_BARRIER; 2493 if (heap->InNewSpace(this)) return SKIP_WRITE_BARRIER;
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
3014 const int kMinCapacity = 4; 3029 const int kMinCapacity = 4;
3015 int capacity = base::bits::RoundUpToPowerOfTwo32(at_least_space_for * 2); 3030 int capacity = base::bits::RoundUpToPowerOfTwo32(at_least_space_for * 2);
3016 return Max(capacity, kMinCapacity); 3031 return Max(capacity, kMinCapacity);
3017 } 3032 }
3018 3033
3019 bool HashTableBase::IsKey(Heap* heap, Object* k) { 3034 bool HashTableBase::IsKey(Heap* heap, Object* k) {
3020 return k != heap->the_hole_value() && k != heap->undefined_value(); 3035 return k != heap->the_hole_value() && k != heap->undefined_value();
3021 } 3036 }
3022 3037
3023 bool HashTableBase::IsKey(Object* k) { 3038 bool HashTableBase::IsKey(Object* k) {
3024 return !k->IsTheHole() && !k->IsUndefined(); 3039 Isolate* isolate = this->GetIsolate();
3040 return !k->IsTheHole(isolate) && !k->IsUndefined(isolate);
3025 } 3041 }
3026 3042
3027 3043
3028 void HashTableBase::SetNumberOfElements(int nof) { 3044 void HashTableBase::SetNumberOfElements(int nof) {
3029 set(kNumberOfElementsIndex, Smi::FromInt(nof)); 3045 set(kNumberOfElementsIndex, Smi::FromInt(nof));
3030 } 3046 }
3031 3047
3032 3048
3033 void HashTableBase::SetNumberOfDeletedElements(int nod) { 3049 void HashTableBase::SetNumberOfDeletedElements(int nod) {
3034 set(kNumberOfDeletedElementsIndex, Smi::FromInt(nod)); 3050 set(kNumberOfDeletedElementsIndex, Smi::FromInt(nod));
(...skipping 13 matching lines...) Expand all
3048 3064
3049 3065
3050 // Find entry for key otherwise return kNotFound. 3066 // Find entry for key otherwise return kNotFound.
3051 template <typename Derived, typename Shape, typename Key> 3067 template <typename Derived, typename Shape, typename Key>
3052 int HashTable<Derived, Shape, Key>::FindEntry(Isolate* isolate, Key key, 3068 int HashTable<Derived, Shape, Key>::FindEntry(Isolate* isolate, Key key,
3053 int32_t hash) { 3069 int32_t hash) {
3054 uint32_t capacity = Capacity(); 3070 uint32_t capacity = Capacity();
3055 uint32_t entry = FirstProbe(hash, capacity); 3071 uint32_t entry = FirstProbe(hash, capacity);
3056 uint32_t count = 1; 3072 uint32_t count = 1;
3057 // EnsureCapacity will guarantee the hash table is never full. 3073 // EnsureCapacity will guarantee the hash table is never full.
3058 Object* undefined = isolate->heap()->undefined_value();
3059 Object* the_hole = isolate->heap()->the_hole_value();
3060 while (true) { 3074 while (true) {
3061 Object* element = KeyAt(entry); 3075 Object* element = KeyAt(entry);
3062 // Empty entry. Uses raw unchecked accessors because it is called by the 3076 // Empty entry. Uses raw unchecked accessors because it is called by the
3063 // string table during bootstrapping. 3077 // string table during bootstrapping.
3064 if (element == undefined) break; 3078 if (element->IsUndefined(isolate)) break;
ulan 2016/06/01 19:01:44 Isn't this performance critical? Before it was on
3065 if (element != the_hole && Shape::IsMatch(key, element)) return entry; 3079 if (!element->IsTheHole(isolate) && Shape::IsMatch(key, element)) {
3080 return entry;
3081 }
3066 entry = NextProbe(entry, count++, capacity); 3082 entry = NextProbe(entry, count++, capacity);
3067 } 3083 }
3068 return kNotFound; 3084 return kNotFound;
3069 } 3085 }
3070 3086
3071 bool StringSetShape::IsMatch(String* key, Object* value) { 3087 bool StringSetShape::IsMatch(String* key, Object* value) {
3072 return value->IsString() && key->Equals(String::cast(value)); 3088 return value->IsString() && key->Equals(String::cast(value));
3073 } 3089 }
3074 3090
3075 uint32_t StringSetShape::Hash(String* key) { return key->Hash(); } 3091 uint32_t StringSetShape::Hash(String* key) { return key->Hash(); }
(...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after
4214 ElementType cast_value = Traits::defaultValue(); 4230 ElementType cast_value = Traits::defaultValue();
4215 if (value->IsSmi()) { 4231 if (value->IsSmi()) {
4216 int int_value = Smi::cast(value)->value(); 4232 int int_value = Smi::cast(value)->value();
4217 cast_value = from_int(int_value); 4233 cast_value = from_int(int_value);
4218 } else if (value->IsHeapNumber()) { 4234 } else if (value->IsHeapNumber()) {
4219 double double_value = HeapNumber::cast(value)->value(); 4235 double double_value = HeapNumber::cast(value)->value();
4220 cast_value = from_double(double_value); 4236 cast_value = from_double(double_value);
4221 } else { 4237 } else {
4222 // Clamp undefined to the default value. All other types have been 4238 // Clamp undefined to the default value. All other types have been
4223 // converted to a number type further up in the call chain. 4239 // converted to a number type further up in the call chain.
4224 DCHECK(value->IsUndefined()); 4240 DCHECK(value->IsUndefined(GetIsolate()));
4225 } 4241 }
4226 set(index, cast_value); 4242 set(index, cast_value);
4227 } 4243 }
4228 4244
4229 4245
4230 Handle<Object> Uint8ArrayTraits::ToHandle(Isolate* isolate, uint8_t scalar) { 4246 Handle<Object> Uint8ArrayTraits::ToHandle(Isolate* isolate, uint8_t scalar) {
4231 return handle(Smi::FromInt(scalar), isolate); 4247 return handle(Smi::FromInt(scalar), isolate);
4232 } 4248 }
4233 4249
4234 4250
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after
5398 void Map::set_prototype_info(Object* value, WriteBarrierMode mode) { 5414 void Map::set_prototype_info(Object* value, WriteBarrierMode mode) {
5399 DCHECK(is_prototype_map()); 5415 DCHECK(is_prototype_map());
5400 WRITE_FIELD(this, Map::kTransitionsOrPrototypeInfoOffset, value); 5416 WRITE_FIELD(this, Map::kTransitionsOrPrototypeInfoOffset, value);
5401 CONDITIONAL_WRITE_BARRIER( 5417 CONDITIONAL_WRITE_BARRIER(
5402 GetHeap(), this, Map::kTransitionsOrPrototypeInfoOffset, value, mode); 5418 GetHeap(), this, Map::kTransitionsOrPrototypeInfoOffset, value, mode);
5403 } 5419 }
5404 5420
5405 5421
5406 void Map::SetBackPointer(Object* value, WriteBarrierMode mode) { 5422 void Map::SetBackPointer(Object* value, WriteBarrierMode mode) {
5407 DCHECK(instance_type() >= FIRST_JS_RECEIVER_TYPE); 5423 DCHECK(instance_type() >= FIRST_JS_RECEIVER_TYPE);
5408 DCHECK((value->IsMap() && GetBackPointer()->IsUndefined())); 5424 DCHECK(value->IsMap());
5425 DCHECK(GetBackPointer()->IsUndefined(GetIsolate()));
5409 DCHECK(!value->IsMap() || 5426 DCHECK(!value->IsMap() ||
5410 Map::cast(value)->GetConstructor() == constructor_or_backpointer()); 5427 Map::cast(value)->GetConstructor() == constructor_or_backpointer());
5411 set_constructor_or_backpointer(value, mode); 5428 set_constructor_or_backpointer(value, mode);
5412 } 5429 }
5413 5430
5414 5431
5415 ACCESSORS(Map, code_cache, Object, kCodeCacheOffset) 5432 ACCESSORS(Map, code_cache, Object, kCodeCacheOffset)
5416 ACCESSORS(Map, dependent_code, DependentCode, kDependentCodeOffset) 5433 ACCESSORS(Map, dependent_code, DependentCode, kDependentCodeOffset)
5417 ACCESSORS(Map, weak_cell_cache, Object, kWeakCellCacheOffset) 5434 ACCESSORS(Map, weak_cell_cache, Object, kWeakCellCacheOffset)
5418 ACCESSORS(Map, constructor_or_backpointer, Object, 5435 ACCESSORS(Map, constructor_or_backpointer, Object,
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
5938 return function_data()->IsFunctionTemplateInfo(); 5955 return function_data()->IsFunctionTemplateInfo();
5939 } 5956 }
5940 5957
5941 5958
5942 FunctionTemplateInfo* SharedFunctionInfo::get_api_func_data() { 5959 FunctionTemplateInfo* SharedFunctionInfo::get_api_func_data() {
5943 DCHECK(IsApiFunction()); 5960 DCHECK(IsApiFunction());
5944 return FunctionTemplateInfo::cast(function_data()); 5961 return FunctionTemplateInfo::cast(function_data());
5945 } 5962 }
5946 5963
5947 void SharedFunctionInfo::set_api_func_data(FunctionTemplateInfo* data) { 5964 void SharedFunctionInfo::set_api_func_data(FunctionTemplateInfo* data) {
5948 DCHECK(function_data()->IsUndefined()); 5965 DCHECK(function_data()->IsUndefined(GetIsolate()));
5949 set_function_data(data); 5966 set_function_data(data);
5950 } 5967 }
5951 5968
5952 bool SharedFunctionInfo::HasBytecodeArray() { 5969 bool SharedFunctionInfo::HasBytecodeArray() {
5953 return function_data()->IsBytecodeArray(); 5970 return function_data()->IsBytecodeArray();
5954 } 5971 }
5955 5972
5956 BytecodeArray* SharedFunctionInfo::bytecode_array() { 5973 BytecodeArray* SharedFunctionInfo::bytecode_array() {
5957 DCHECK(HasBytecodeArray()); 5974 DCHECK(HasBytecodeArray());
5958 return BytecodeArray::cast(function_data()); 5975 return BytecodeArray::cast(function_data());
5959 } 5976 }
5960 5977
5961 void SharedFunctionInfo::set_bytecode_array(BytecodeArray* bytecode) { 5978 void SharedFunctionInfo::set_bytecode_array(BytecodeArray* bytecode) {
5962 DCHECK(function_data()->IsUndefined()); 5979 DCHECK(function_data()->IsUndefined(GetIsolate()));
5963 set_function_data(bytecode); 5980 set_function_data(bytecode);
5964 } 5981 }
5965 5982
5966 void SharedFunctionInfo::ClearBytecodeArray() { 5983 void SharedFunctionInfo::ClearBytecodeArray() {
5967 DCHECK(function_data()->IsUndefined() || HasBytecodeArray()); 5984 DCHECK(function_data()->IsUndefined(GetIsolate()) || HasBytecodeArray());
5968 set_function_data(GetHeap()->undefined_value()); 5985 set_function_data(GetHeap()->undefined_value());
5969 } 5986 }
5970 5987
5971 bool SharedFunctionInfo::HasBuiltinFunctionId() { 5988 bool SharedFunctionInfo::HasBuiltinFunctionId() {
5972 return function_identifier()->IsSmi(); 5989 return function_identifier()->IsSmi();
5973 } 5990 }
5974 5991
5975 BuiltinFunctionId SharedFunctionInfo::builtin_function_id() { 5992 BuiltinFunctionId SharedFunctionInfo::builtin_function_id() {
5976 DCHECK(HasBuiltinFunctionId()); 5993 DCHECK(HasBuiltinFunctionId());
5977 return static_cast<BuiltinFunctionId>( 5994 return static_cast<BuiltinFunctionId>(
5978 Smi::cast(function_identifier())->value()); 5995 Smi::cast(function_identifier())->value());
5979 } 5996 }
5980 5997
5981 void SharedFunctionInfo::set_builtin_function_id(BuiltinFunctionId id) { 5998 void SharedFunctionInfo::set_builtin_function_id(BuiltinFunctionId id) {
5982 set_function_identifier(Smi::FromInt(id)); 5999 set_function_identifier(Smi::FromInt(id));
5983 } 6000 }
5984 6001
5985 bool SharedFunctionInfo::HasInferredName() { 6002 bool SharedFunctionInfo::HasInferredName() {
5986 return function_identifier()->IsString(); 6003 return function_identifier()->IsString();
5987 } 6004 }
5988 6005
5989 String* SharedFunctionInfo::inferred_name() { 6006 String* SharedFunctionInfo::inferred_name() {
5990 if (HasInferredName()) { 6007 if (HasInferredName()) {
5991 return String::cast(function_identifier()); 6008 return String::cast(function_identifier());
5992 } 6009 }
5993 DCHECK(function_identifier()->IsUndefined() || HasBuiltinFunctionId()); 6010 Isolate* isolate = GetIsolate();
5994 return GetIsolate()->heap()->empty_string(); 6011 DCHECK(function_identifier()->IsUndefined(isolate) || HasBuiltinFunctionId());
6012 return isolate->heap()->empty_string();
5995 } 6013 }
5996 6014
5997 void SharedFunctionInfo::set_inferred_name(String* inferred_name) { 6015 void SharedFunctionInfo::set_inferred_name(String* inferred_name) {
5998 DCHECK(function_identifier()->IsUndefined() || HasInferredName()); 6016 DCHECK(function_identifier()->IsUndefined(GetIsolate()) || HasInferredName());
5999 set_function_identifier(inferred_name); 6017 set_function_identifier(inferred_name);
6000 } 6018 }
6001 6019
6002 int SharedFunctionInfo::ic_age() { 6020 int SharedFunctionInfo::ic_age() {
6003 return ICAgeBits::decode(counters()); 6021 return ICAgeBits::decode(counters());
6004 } 6022 }
6005 6023
6006 6024
6007 void SharedFunctionInfo::set_ic_age(int ic_age) { 6025 void SharedFunctionInfo::set_ic_age(int ic_age) {
6008 set_counters(ICAgeBits::update(counters(), ic_age)); 6026 set_counters(ICAgeBits::update(counters(), ic_age));
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
6074 6092
6075 6093
6076 void SharedFunctionInfo::set_disable_optimization_reason(BailoutReason reason) { 6094 void SharedFunctionInfo::set_disable_optimization_reason(BailoutReason reason) {
6077 set_opt_count_and_bailout_reason(DisabledOptimizationReasonBits::update( 6095 set_opt_count_and_bailout_reason(DisabledOptimizationReasonBits::update(
6078 opt_count_and_bailout_reason(), reason)); 6096 opt_count_and_bailout_reason(), reason));
6079 } 6097 }
6080 6098
6081 6099
6082 bool SharedFunctionInfo::IsBuiltin() { 6100 bool SharedFunctionInfo::IsBuiltin() {
6083 Object* script_obj = script(); 6101 Object* script_obj = script();
6084 if (script_obj->IsUndefined()) return true; 6102 if (script_obj->IsUndefined(GetIsolate())) return true;
6085 Script* script = Script::cast(script_obj); 6103 Script* script = Script::cast(script_obj);
6086 Script::Type type = static_cast<Script::Type>(script->type()); 6104 Script::Type type = static_cast<Script::Type>(script->type());
6087 return type != Script::TYPE_NORMAL; 6105 return type != Script::TYPE_NORMAL;
6088 } 6106 }
6089 6107
6090 6108
6091 bool SharedFunctionInfo::IsSubjectToDebugging() { return !IsBuiltin(); } 6109 bool SharedFunctionInfo::IsSubjectToDebugging() { return !IsBuiltin(); }
6092 6110
6093 6111
6094 bool SharedFunctionInfo::OptimizedCodeMapIsCleared() const { 6112 bool SharedFunctionInfo::OptimizedCodeMapIsCleared() const {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
6207 6225
6208 JSObject* JSFunction::global_proxy() { 6226 JSObject* JSFunction::global_proxy() {
6209 return context()->global_proxy(); 6227 return context()->global_proxy();
6210 } 6228 }
6211 6229
6212 6230
6213 Context* JSFunction::native_context() { return context()->native_context(); } 6231 Context* JSFunction::native_context() { return context()->native_context(); }
6214 6232
6215 6233
6216 void JSFunction::set_context(Object* value) { 6234 void JSFunction::set_context(Object* value) {
6217 DCHECK(value->IsUndefined() || value->IsContext()); 6235 DCHECK(value->IsUndefined(GetIsolate()) || value->IsContext());
6218 WRITE_FIELD(this, kContextOffset, value); 6236 WRITE_FIELD(this, kContextOffset, value);
6219 WRITE_BARRIER(GetHeap(), this, kContextOffset, value); 6237 WRITE_BARRIER(GetHeap(), this, kContextOffset, value);
6220 } 6238 }
6221 6239
6222 ACCESSORS(JSFunction, prototype_or_initial_map, Object, 6240 ACCESSORS(JSFunction, prototype_or_initial_map, Object,
6223 kPrototypeOrInitialMapOffset) 6241 kPrototypeOrInitialMapOffset)
6224 6242
6225 6243
6226 Map* JSFunction::initial_map() { 6244 Map* JSFunction::initial_map() {
6227 return Map::cast(prototype_or_initial_map()); 6245 return Map::cast(prototype_or_initial_map());
6228 } 6246 }
6229 6247
6230 6248
6231 bool JSFunction::has_initial_map() { 6249 bool JSFunction::has_initial_map() {
6232 return prototype_or_initial_map()->IsMap(); 6250 return prototype_or_initial_map()->IsMap();
6233 } 6251 }
6234 6252
6235 6253
6236 bool JSFunction::has_instance_prototype() { 6254 bool JSFunction::has_instance_prototype() {
6237 return has_initial_map() || !prototype_or_initial_map()->IsTheHole(); 6255 return has_initial_map() ||
6256 !prototype_or_initial_map()->IsTheHole(GetIsolate());
6238 } 6257 }
6239 6258
6240 6259
6241 bool JSFunction::has_prototype() { 6260 bool JSFunction::has_prototype() {
6242 return map()->has_non_instance_prototype() || has_instance_prototype(); 6261 return map()->has_non_instance_prototype() || has_instance_prototype();
6243 } 6262 }
6244 6263
6245 6264
6246 Object* JSFunction::instance_prototype() { 6265 Object* JSFunction::instance_prototype() {
6247 DCHECK(has_instance_prototype()); 6266 DCHECK(has_instance_prototype());
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
6623 #endif 6642 #endif
6624 6643
6625 6644
6626 ACCESSORS(JSRegExp, data, Object, kDataOffset) 6645 ACCESSORS(JSRegExp, data, Object, kDataOffset)
6627 ACCESSORS(JSRegExp, flags, Object, kFlagsOffset) 6646 ACCESSORS(JSRegExp, flags, Object, kFlagsOffset)
6628 ACCESSORS(JSRegExp, source, Object, kSourceOffset) 6647 ACCESSORS(JSRegExp, source, Object, kSourceOffset)
6629 6648
6630 6649
6631 JSRegExp::Type JSRegExp::TypeTag() { 6650 JSRegExp::Type JSRegExp::TypeTag() {
6632 Object* data = this->data(); 6651 Object* data = this->data();
6633 if (data->IsUndefined()) return JSRegExp::NOT_COMPILED; 6652 if (data->IsUndefined(GetIsolate())) return JSRegExp::NOT_COMPILED;
6634 Smi* smi = Smi::cast(FixedArray::cast(data)->get(kTagIndex)); 6653 Smi* smi = Smi::cast(FixedArray::cast(data)->get(kTagIndex));
6635 return static_cast<JSRegExp::Type>(smi->value()); 6654 return static_cast<JSRegExp::Type>(smi->value());
6636 } 6655 }
6637 6656
6638 6657
6639 int JSRegExp::CaptureCount() { 6658 int JSRegExp::CaptureCount() {
6640 switch (TypeTag()) { 6659 switch (TypeTag()) {
6641 case ATOM: 6660 case ATOM:
6642 return 0; 6661 return 0;
6643 case IRREGEXP: 6662 case IRREGEXP:
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
7312 return (getter() == getter_value) && (setter() == setter_value); 7331 return (getter() == getter_value) && (setter() == setter_value);
7313 } 7332 }
7314 7333
7315 7334
7316 bool AccessorPair::ContainsAccessor() { 7335 bool AccessorPair::ContainsAccessor() {
7317 return IsJSAccessor(getter()) || IsJSAccessor(setter()); 7336 return IsJSAccessor(getter()) || IsJSAccessor(setter());
7318 } 7337 }
7319 7338
7320 7339
7321 bool AccessorPair::IsJSAccessor(Object* obj) { 7340 bool AccessorPair::IsJSAccessor(Object* obj) {
7322 return obj->IsCallable() || obj->IsUndefined(); 7341 return obj->IsCallable() || obj->IsUndefined(GetIsolate());
7323 } 7342 }
7324 7343
7325 7344
7326 template<typename Derived, typename Shape, typename Key> 7345 template<typename Derived, typename Shape, typename Key>
7327 void Dictionary<Derived, Shape, Key>::SetEntry(int entry, 7346 void Dictionary<Derived, Shape, Key>::SetEntry(int entry,
7328 Handle<Object> key, 7347 Handle<Object> key,
7329 Handle<Object> value) { 7348 Handle<Object> value) {
7330 this->SetEntry(entry, key, value, PropertyDetails(Smi::FromInt(0))); 7349 this->SetEntry(entry, key, value, PropertyDetails(Smi::FromInt(0)));
7331 } 7350 }
7332 7351
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
7457 Object* raw_value = dict->ValueAt(entry); 7476 Object* raw_value = dict->ValueAt(entry);
7458 DCHECK(raw_value->IsPropertyCell()); 7477 DCHECK(raw_value->IsPropertyCell());
7459 PropertyCell* cell = PropertyCell::cast(raw_value); 7478 PropertyCell* cell = PropertyCell::cast(raw_value);
7460 cell->set_property_details(value); 7479 cell->set_property_details(value);
7461 } 7480 }
7462 7481
7463 7482
7464 template <typename Dictionary> 7483 template <typename Dictionary>
7465 bool GlobalDictionaryShape::IsDeleted(Dictionary* dict, int entry) { 7484 bool GlobalDictionaryShape::IsDeleted(Dictionary* dict, int entry) {
7466 DCHECK(dict->ValueAt(entry)->IsPropertyCell()); 7485 DCHECK(dict->ValueAt(entry)->IsPropertyCell());
7467 return PropertyCell::cast(dict->ValueAt(entry))->value()->IsTheHole(); 7486 Isolate* isolate = dict->GetIsolate();
7487 return PropertyCell::cast(dict->ValueAt(entry))->value()->IsTheHole(isolate);
7468 } 7488 }
7469 7489
7470 7490
7471 bool ObjectHashTableShape::IsMatch(Handle<Object> key, Object* other) { 7491 bool ObjectHashTableShape::IsMatch(Handle<Object> key, Object* other) {
7472 return key->SameValue(other); 7492 return key->SameValue(other);
7473 } 7493 }
7474 7494
7475 7495
7476 uint32_t ObjectHashTableShape::Hash(Handle<Object> key) { 7496 uint32_t ObjectHashTableShape::Hash(Handle<Object> key) {
7477 return Smi::cast(key->GetHash())->value(); 7497 return Smi::cast(key->GetHash())->value();
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
7731 DCHECK_EQ(isolate_->relocatable_top(), this); 7751 DCHECK_EQ(isolate_->relocatable_top(), this);
7732 isolate_->set_relocatable_top(prev_); 7752 isolate_->set_relocatable_top(prev_);
7733 } 7753 }
7734 7754
7735 7755
7736 template<class Derived, class TableType> 7756 template<class Derived, class TableType>
7737 Object* OrderedHashTableIterator<Derived, TableType>::CurrentKey() { 7757 Object* OrderedHashTableIterator<Derived, TableType>::CurrentKey() {
7738 TableType* table(TableType::cast(this->table())); 7758 TableType* table(TableType::cast(this->table()));
7739 int index = Smi::cast(this->index())->value(); 7759 int index = Smi::cast(this->index())->value();
7740 Object* key = table->KeyAt(index); 7760 Object* key = table->KeyAt(index);
7741 DCHECK(!key->IsTheHole()); 7761 DCHECK(!key->IsTheHole(table->GetIsolate()));
7742 return key; 7762 return key;
7743 } 7763 }
7744 7764
7745 7765
7746 void JSSetIterator::PopulateValueArray(FixedArray* array) { 7766 void JSSetIterator::PopulateValueArray(FixedArray* array) {
7747 array->set(0, CurrentKey()); 7767 array->set(0, CurrentKey());
7748 } 7768 }
7749 7769
7750 7770
7751 void JSMapIterator::PopulateValueArray(FixedArray* array) { 7771 void JSMapIterator::PopulateValueArray(FixedArray* array) {
7752 array->set(0, CurrentKey()); 7772 array->set(0, CurrentKey());
7753 array->set(1, CurrentValue()); 7773 array->set(1, CurrentValue());
7754 } 7774 }
7755 7775
7756 7776
7757 Object* JSMapIterator::CurrentValue() { 7777 Object* JSMapIterator::CurrentValue() {
7758 OrderedHashMap* table(OrderedHashMap::cast(this->table())); 7778 OrderedHashMap* table(OrderedHashMap::cast(this->table()));
7759 int index = Smi::cast(this->index())->value(); 7779 int index = Smi::cast(this->index())->value();
7760 Object* value = table->ValueAt(index); 7780 Object* value = table->ValueAt(index);
7761 DCHECK(!value->IsTheHole()); 7781 DCHECK(!value->IsTheHole(table->GetIsolate()));
7762 return value; 7782 return value;
7763 } 7783 }
7764 7784
7765 7785
7766 String::SubStringRange::SubStringRange(String* string, int first, int length) 7786 String::SubStringRange::SubStringRange(String* string, int first, int length)
7767 : string_(string), 7787 : string_(string),
7768 first_(first), 7788 first_(first),
7769 length_(length == -1 ? string->length() : length) {} 7789 length_(length == -1 ? string->length() : length) {}
7770 7790
7771 7791
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
7887 #undef WRITE_INT64_FIELD 7907 #undef WRITE_INT64_FIELD
7888 #undef READ_BYTE_FIELD 7908 #undef READ_BYTE_FIELD
7889 #undef WRITE_BYTE_FIELD 7909 #undef WRITE_BYTE_FIELD
7890 #undef NOBARRIER_READ_BYTE_FIELD 7910 #undef NOBARRIER_READ_BYTE_FIELD
7891 #undef NOBARRIER_WRITE_BYTE_FIELD 7911 #undef NOBARRIER_WRITE_BYTE_FIELD
7892 7912
7893 } // namespace internal 7913 } // namespace internal
7894 } // namespace v8 7914 } // namespace v8
7895 7915
7896 #endif // V8_OBJECTS_INL_H_ 7916 #endif // V8_OBJECTS_INL_H_
OLDNEW
« src/objects.h ('K') | « src/objects-debug.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698