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

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: doing proper rebase 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 #undef SIMD128_TYPE_CHECKER 156 #undef SIMD128_TYPE_CHECKER
157 157
158 #define IS_TYPE_FUNCTION_DEF(type_) \ 158 #define IS_TYPE_FUNCTION_DEF(type_) \
159 bool Object::Is##type_() const { \ 159 bool Object::Is##type_() const { \
160 return IsHeapObject() && HeapObject::cast(this)->Is##type_(); \ 160 return IsHeapObject() && HeapObject::cast(this)->Is##type_(); \
161 } 161 }
162 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DEF) 162 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DEF)
163 ODDBALL_LIST(IS_TYPE_FUNCTION_DEF) 163 ODDBALL_LIST(IS_TYPE_FUNCTION_DEF)
164 #undef IS_TYPE_FUNCTION_DEF 164 #undef IS_TYPE_FUNCTION_DEF
165 165
166 bool HeapObject::IsTheHole(Isolate* isolate) const {
167 return this == isolate->heap()->the_hole_value();
168 }
169
170 bool HeapObject::IsUndefined(Isolate* isolate) const {
171 return this == isolate->heap()->undefined_value();
172 }
173
174 bool Object::IsTheHole(Isolate* isolate) const {
Michael Starzinger 2016/06/06 08:55:08 Likewise, could we drop the second pair?
175 return this == isolate->heap()->the_hole_value();
176 }
177
178 bool Object::IsUndefined(Isolate* isolate) const {
179 return this == isolate->heap()->undefined_value();
180 }
181
166 bool HeapObject::IsString() const { 182 bool HeapObject::IsString() const {
167 return map()->instance_type() < FIRST_NONSTRING_TYPE; 183 return map()->instance_type() < FIRST_NONSTRING_TYPE;
168 } 184 }
169 185
170 bool HeapObject::IsName() const { 186 bool HeapObject::IsName() const {
171 return map()->instance_type() <= LAST_NAME_TYPE; 187 return map()->instance_type() <= LAST_NAME_TYPE;
172 } 188 }
173 189
174 bool HeapObject::IsUniqueName() const { 190 bool HeapObject::IsUniqueName() const {
175 return IsInternalizedString() || IsSymbol(); 191 return IsInternalizedString() || IsSymbol();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 return StringShape(String::cast(this)).IsExternal() && 254 return StringShape(String::cast(this)).IsExternal() &&
239 String::cast(this)->IsOneByteRepresentation(); 255 String::cast(this)->IsOneByteRepresentation();
240 } 256 }
241 257
242 bool HeapObject::IsExternalTwoByteString() const { 258 bool HeapObject::IsExternalTwoByteString() const {
243 if (!IsString()) return false; 259 if (!IsString()) return false;
244 return StringShape(String::cast(this)).IsExternal() && 260 return StringShape(String::cast(this)).IsExternal() &&
245 String::cast(this)->IsTwoByteRepresentation(); 261 String::cast(this)->IsTwoByteRepresentation();
246 } 262 }
247 263
248
249 bool Object::HasValidElements() { 264 bool Object::HasValidElements() {
250 // Dictionary is covered under FixedArray. 265 // Dictionary is covered under FixedArray.
251 return IsFixedArray() || IsFixedDoubleArray() || IsFixedTypedArrayBase(); 266 return IsFixedArray() || IsFixedDoubleArray() || IsFixedTypedArrayBase();
252 } 267 }
253 268
254 269
255 bool Object::KeyEquals(Object* second) { 270 bool Object::KeyEquals(Object* second) {
256 Object* first = this; 271 Object* first = this;
257 if (second->IsNumber()) { 272 if (second->IsNumber()) {
258 if (first->IsNumber()) return first->Number() == second->Number(); 273 if (first->IsNumber()) return first->Number() == second->Number();
(...skipping 1536 matching lines...) Expand 10 before | Expand all | Expand 10 after
1795 Object** objects, 1810 Object** objects,
1796 uint32_t count, 1811 uint32_t count,
1797 EnsureElementsMode mode) { 1812 EnsureElementsMode mode) {
1798 ElementsKind current_kind = object->GetElementsKind(); 1813 ElementsKind current_kind = object->GetElementsKind();
1799 ElementsKind target_kind = current_kind; 1814 ElementsKind target_kind = current_kind;
1800 { 1815 {
1801 DisallowHeapAllocation no_allocation; 1816 DisallowHeapAllocation no_allocation;
1802 DCHECK(mode != ALLOW_COPIED_DOUBLE_ELEMENTS); 1817 DCHECK(mode != ALLOW_COPIED_DOUBLE_ELEMENTS);
1803 bool is_holey = IsFastHoleyElementsKind(current_kind); 1818 bool is_holey = IsFastHoleyElementsKind(current_kind);
1804 if (current_kind == FAST_HOLEY_ELEMENTS) return; 1819 if (current_kind == FAST_HOLEY_ELEMENTS) return;
1805 Heap* heap = object->GetHeap(); 1820 Object* the_hole = object->GetHeap()->the_hole_value();
1806 Object* the_hole = heap->the_hole_value();
1807 for (uint32_t i = 0; i < count; ++i) { 1821 for (uint32_t i = 0; i < count; ++i) {
1808 Object* current = *objects++; 1822 Object* current = *objects++;
1809 if (current == the_hole) { 1823 if (current == the_hole) {
1810 is_holey = true; 1824 is_holey = true;
1811 target_kind = GetHoleyElementsKind(target_kind); 1825 target_kind = GetHoleyElementsKind(target_kind);
1812 } else if (!current->IsSmi()) { 1826 } else if (!current->IsSmi()) {
1813 if (mode == ALLOW_CONVERTED_DOUBLE_ELEMENTS && current->IsNumber()) { 1827 if (mode == ALLOW_CONVERTED_DOUBLE_ELEMENTS && current->IsNumber()) {
1814 if (IsFastSmiElementsKind(target_kind)) { 1828 if (IsFastSmiElementsKind(target_kind)) {
1815 if (is_holey) { 1829 if (is_holey) {
1816 target_kind = FAST_HOLEY_DOUBLE_ELEMENTS; 1830 target_kind = FAST_HOLEY_DOUBLE_ELEMENTS;
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
2002 WRITE_BARRIER(GetHeap(), this, kNextOffset, val); 2016 WRITE_BARRIER(GetHeap(), this, kNextOffset, val);
2003 } 2017 }
2004 } 2018 }
2005 2019
2006 2020
2007 void WeakCell::clear_next(Object* the_hole_value) { 2021 void WeakCell::clear_next(Object* the_hole_value) {
2008 DCHECK_EQ(GetHeap()->the_hole_value(), the_hole_value); 2022 DCHECK_EQ(GetHeap()->the_hole_value(), the_hole_value);
2009 set_next(the_hole_value, SKIP_WRITE_BARRIER); 2023 set_next(the_hole_value, SKIP_WRITE_BARRIER);
2010 } 2024 }
2011 2025
2012 2026 bool WeakCell::next_cleared() { return next()->IsTheHole(GetIsolate()); }
2013 bool WeakCell::next_cleared() { return next()->IsTheHole(); }
2014
2015 2027
2016 int JSObject::GetHeaderSize() { return GetHeaderSize(map()->instance_type()); } 2028 int JSObject::GetHeaderSize() { return GetHeaderSize(map()->instance_type()); }
2017 2029
2018 2030
2019 int JSObject::GetHeaderSize(InstanceType type) { 2031 int JSObject::GetHeaderSize(InstanceType type) {
2020 // Check for the most common kind of JavaScript object before 2032 // Check for the most common kind of JavaScript object before
2021 // falling into the generic switch. This speeds up the internal 2033 // falling into the generic switch. This speeds up the internal
2022 // field operations considerably on average. 2034 // field operations considerably on average.
2023 if (type == JS_OBJECT_TYPE) return JSObject::kHeaderSize; 2035 if (type == JS_OBJECT_TYPE) return JSObject::kHeaderSize;
2024 switch (type) { 2036 switch (type) {
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
2274 bool Object::ToArrayLength(uint32_t* index) { return Object::ToUint32(index); } 2286 bool Object::ToArrayLength(uint32_t* index) { return Object::ToUint32(index); }
2275 2287
2276 2288
2277 bool Object::ToArrayIndex(uint32_t* index) { 2289 bool Object::ToArrayIndex(uint32_t* index) {
2278 return Object::ToUint32(index) && *index != kMaxUInt32; 2290 return Object::ToUint32(index) && *index != kMaxUInt32;
2279 } 2291 }
2280 2292
2281 2293
2282 void Object::VerifyApiCallResultType() { 2294 void Object::VerifyApiCallResultType() {
2283 #if DEBUG 2295 #if DEBUG
2284 if (!(IsSmi() || IsString() || IsSymbol() || IsJSReceiver() || 2296 if (IsSmi()) return;
Michael Starzinger 2016/06/06 08:55:08 This is debug code, IMHO it should not return but
Camillo Bruni 2016/06/06 12:27:49 If it's a SMI it's a valid api call result => don'
Michael Starzinger 2016/06/06 12:29:26 Acknowledged. Ah, oops, I misread the original cod
2285 IsHeapNumber() || IsSimd128Value() || IsUndefined() || IsTrue() || 2297 DCHECK(IsHeapObject());
2286 IsFalse() || IsNull())) { 2298 Isolate* isolate = HeapObject::cast(this)->GetIsolate();
2299 if (!(IsString() || IsSymbol() || IsJSReceiver() || IsHeapNumber() ||
2300 IsSimd128Value() || IsUndefined(isolate) || IsTrue() || IsFalse() ||
2301 IsNull())) {
2287 FATAL("API call returned invalid object"); 2302 FATAL("API call returned invalid object");
2288 } 2303 }
2289 #endif // DEBUG 2304 #endif // DEBUG
2290 } 2305 }
2291 2306
2292 2307
2293 Object* FixedArray::get(int index) const { 2308 Object* FixedArray::get(int index) const {
2294 SLOW_DCHECK(index >= 0 && index < this->length()); 2309 SLOW_DCHECK(index >= 0 && index < this->length());
2295 return READ_FIELD(this, kHeaderSize + index * kPointerSize); 2310 return READ_FIELD(this, kHeaderSize + index * kPointerSize);
2296 } 2311 }
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2459 return data_start() + kFirstIndex + index; 2474 return data_start() + kFirstIndex + index;
2460 } 2475 }
2461 2476
2462 2477
2463 void ArrayList::Set(int index, Object* obj) { 2478 void ArrayList::Set(int index, Object* obj) {
2464 FixedArray::cast(this)->set(kFirstIndex + index, obj); 2479 FixedArray::cast(this)->set(kFirstIndex + index, obj);
2465 } 2480 }
2466 2481
2467 2482
2468 void ArrayList::Clear(int index, Object* undefined) { 2483 void ArrayList::Clear(int index, Object* undefined) {
2469 DCHECK(undefined->IsUndefined()); 2484 DCHECK(undefined->IsUndefined(GetIsolate()));
2470 FixedArray::cast(this) 2485 FixedArray::cast(this)
2471 ->set(kFirstIndex + index, undefined, SKIP_WRITE_BARRIER); 2486 ->set(kFirstIndex + index, undefined, SKIP_WRITE_BARRIER);
2472 } 2487 }
2473 2488
2474 2489
2475 WriteBarrierMode HeapObject::GetWriteBarrierMode( 2490 WriteBarrierMode HeapObject::GetWriteBarrierMode(
2476 const DisallowHeapAllocation& promise) { 2491 const DisallowHeapAllocation& promise) {
2477 Heap* heap = GetHeap(); 2492 Heap* heap = GetHeap();
2478 if (heap->incremental_marking()->IsMarking()) return UPDATE_WRITE_BARRIER; 2493 if (heap->incremental_marking()->IsMarking()) return UPDATE_WRITE_BARRIER;
2479 if (heap->InNewSpace(this)) return SKIP_WRITE_BARRIER; 2494 if (heap->InNewSpace(this)) return SKIP_WRITE_BARRIER;
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
3034 const int kMinCapacity = 4; 3049 const int kMinCapacity = 4;
3035 int capacity = base::bits::RoundUpToPowerOfTwo32(at_least_space_for * 2); 3050 int capacity = base::bits::RoundUpToPowerOfTwo32(at_least_space_for * 2);
3036 return Max(capacity, kMinCapacity); 3051 return Max(capacity, kMinCapacity);
3037 } 3052 }
3038 3053
3039 bool HashTableBase::IsKey(Heap* heap, Object* k) { 3054 bool HashTableBase::IsKey(Heap* heap, Object* k) {
3040 return k != heap->the_hole_value() && k != heap->undefined_value(); 3055 return k != heap->the_hole_value() && k != heap->undefined_value();
3041 } 3056 }
3042 3057
3043 bool HashTableBase::IsKey(Object* k) { 3058 bool HashTableBase::IsKey(Object* k) {
3044 return !k->IsTheHole() && !k->IsUndefined(); 3059 Isolate* isolate = this->GetIsolate();
3060 return !k->IsTheHole(isolate) && !k->IsUndefined(isolate);
3045 } 3061 }
3046 3062
3047 3063
3048 void HashTableBase::SetNumberOfElements(int nof) { 3064 void HashTableBase::SetNumberOfElements(int nof) {
3049 set(kNumberOfElementsIndex, Smi::FromInt(nof)); 3065 set(kNumberOfElementsIndex, Smi::FromInt(nof));
3050 } 3066 }
3051 3067
3052 3068
3053 void HashTableBase::SetNumberOfDeletedElements(int nod) { 3069 void HashTableBase::SetNumberOfDeletedElements(int nod) {
3054 set(kNumberOfDeletedElementsIndex, Smi::FromInt(nod)); 3070 set(kNumberOfDeletedElementsIndex, Smi::FromInt(nod));
(...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after
4234 ElementType cast_value = Traits::defaultValue(); 4250 ElementType cast_value = Traits::defaultValue();
4235 if (value->IsSmi()) { 4251 if (value->IsSmi()) {
4236 int int_value = Smi::cast(value)->value(); 4252 int int_value = Smi::cast(value)->value();
4237 cast_value = from_int(int_value); 4253 cast_value = from_int(int_value);
4238 } else if (value->IsHeapNumber()) { 4254 } else if (value->IsHeapNumber()) {
4239 double double_value = HeapNumber::cast(value)->value(); 4255 double double_value = HeapNumber::cast(value)->value();
4240 cast_value = from_double(double_value); 4256 cast_value = from_double(double_value);
4241 } else { 4257 } else {
4242 // Clamp undefined to the default value. All other types have been 4258 // Clamp undefined to the default value. All other types have been
4243 // converted to a number type further up in the call chain. 4259 // converted to a number type further up in the call chain.
4244 DCHECK(value->IsUndefined()); 4260 DCHECK(value->IsUndefined(GetIsolate()));
4245 } 4261 }
4246 set(index, cast_value); 4262 set(index, cast_value);
4247 } 4263 }
4248 4264
4249 4265
4250 Handle<Object> Uint8ArrayTraits::ToHandle(Isolate* isolate, uint8_t scalar) { 4266 Handle<Object> Uint8ArrayTraits::ToHandle(Isolate* isolate, uint8_t scalar) {
4251 return handle(Smi::FromInt(scalar), isolate); 4267 return handle(Smi::FromInt(scalar), isolate);
4252 } 4268 }
4253 4269
4254 4270
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after
5418 void Map::set_prototype_info(Object* value, WriteBarrierMode mode) { 5434 void Map::set_prototype_info(Object* value, WriteBarrierMode mode) {
5419 DCHECK(is_prototype_map()); 5435 DCHECK(is_prototype_map());
5420 WRITE_FIELD(this, Map::kTransitionsOrPrototypeInfoOffset, value); 5436 WRITE_FIELD(this, Map::kTransitionsOrPrototypeInfoOffset, value);
5421 CONDITIONAL_WRITE_BARRIER( 5437 CONDITIONAL_WRITE_BARRIER(
5422 GetHeap(), this, Map::kTransitionsOrPrototypeInfoOffset, value, mode); 5438 GetHeap(), this, Map::kTransitionsOrPrototypeInfoOffset, value, mode);
5423 } 5439 }
5424 5440
5425 5441
5426 void Map::SetBackPointer(Object* value, WriteBarrierMode mode) { 5442 void Map::SetBackPointer(Object* value, WriteBarrierMode mode) {
5427 DCHECK(instance_type() >= FIRST_JS_RECEIVER_TYPE); 5443 DCHECK(instance_type() >= FIRST_JS_RECEIVER_TYPE);
5428 DCHECK((value->IsMap() && GetBackPointer()->IsUndefined())); 5444 DCHECK(value->IsMap());
5445 DCHECK(GetBackPointer()->IsUndefined(GetIsolate()));
5429 DCHECK(!value->IsMap() || 5446 DCHECK(!value->IsMap() ||
5430 Map::cast(value)->GetConstructor() == constructor_or_backpointer()); 5447 Map::cast(value)->GetConstructor() == constructor_or_backpointer());
5431 set_constructor_or_backpointer(value, mode); 5448 set_constructor_or_backpointer(value, mode);
5432 } 5449 }
5433 5450
5434 ACCESSORS(Map, code_cache, FixedArray, kCodeCacheOffset) 5451 ACCESSORS(Map, code_cache, FixedArray, kCodeCacheOffset)
5435 ACCESSORS(Map, dependent_code, DependentCode, kDependentCodeOffset) 5452 ACCESSORS(Map, dependent_code, DependentCode, kDependentCodeOffset)
5436 ACCESSORS(Map, weak_cell_cache, Object, kWeakCellCacheOffset) 5453 ACCESSORS(Map, weak_cell_cache, Object, kWeakCellCacheOffset)
5437 ACCESSORS(Map, constructor_or_backpointer, Object, 5454 ACCESSORS(Map, constructor_or_backpointer, Object,
5438 kConstructorOrBackPointerOffset) 5455 kConstructorOrBackPointerOffset)
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
5957 return function_data()->IsFunctionTemplateInfo(); 5974 return function_data()->IsFunctionTemplateInfo();
5958 } 5975 }
5959 5976
5960 5977
5961 FunctionTemplateInfo* SharedFunctionInfo::get_api_func_data() { 5978 FunctionTemplateInfo* SharedFunctionInfo::get_api_func_data() {
5962 DCHECK(IsApiFunction()); 5979 DCHECK(IsApiFunction());
5963 return FunctionTemplateInfo::cast(function_data()); 5980 return FunctionTemplateInfo::cast(function_data());
5964 } 5981 }
5965 5982
5966 void SharedFunctionInfo::set_api_func_data(FunctionTemplateInfo* data) { 5983 void SharedFunctionInfo::set_api_func_data(FunctionTemplateInfo* data) {
5967 DCHECK(function_data()->IsUndefined()); 5984 DCHECK(function_data()->IsUndefined(GetIsolate()));
5968 set_function_data(data); 5985 set_function_data(data);
5969 } 5986 }
5970 5987
5971 bool SharedFunctionInfo::HasBytecodeArray() { 5988 bool SharedFunctionInfo::HasBytecodeArray() {
5972 return function_data()->IsBytecodeArray(); 5989 return function_data()->IsBytecodeArray();
5973 } 5990 }
5974 5991
5975 BytecodeArray* SharedFunctionInfo::bytecode_array() { 5992 BytecodeArray* SharedFunctionInfo::bytecode_array() {
5976 DCHECK(HasBytecodeArray()); 5993 DCHECK(HasBytecodeArray());
5977 return BytecodeArray::cast(function_data()); 5994 return BytecodeArray::cast(function_data());
5978 } 5995 }
5979 5996
5980 void SharedFunctionInfo::set_bytecode_array(BytecodeArray* bytecode) { 5997 void SharedFunctionInfo::set_bytecode_array(BytecodeArray* bytecode) {
5981 DCHECK(function_data()->IsUndefined()); 5998 DCHECK(function_data()->IsUndefined(GetIsolate()));
5982 set_function_data(bytecode); 5999 set_function_data(bytecode);
5983 } 6000 }
5984 6001
5985 void SharedFunctionInfo::ClearBytecodeArray() { 6002 void SharedFunctionInfo::ClearBytecodeArray() {
5986 DCHECK(function_data()->IsUndefined() || HasBytecodeArray()); 6003 DCHECK(function_data()->IsUndefined(GetIsolate()) || HasBytecodeArray());
5987 set_function_data(GetHeap()->undefined_value()); 6004 set_function_data(GetHeap()->undefined_value());
5988 } 6005 }
5989 6006
5990 bool SharedFunctionInfo::HasBuiltinFunctionId() { 6007 bool SharedFunctionInfo::HasBuiltinFunctionId() {
5991 return function_identifier()->IsSmi(); 6008 return function_identifier()->IsSmi();
5992 } 6009 }
5993 6010
5994 BuiltinFunctionId SharedFunctionInfo::builtin_function_id() { 6011 BuiltinFunctionId SharedFunctionInfo::builtin_function_id() {
5995 DCHECK(HasBuiltinFunctionId()); 6012 DCHECK(HasBuiltinFunctionId());
5996 return static_cast<BuiltinFunctionId>( 6013 return static_cast<BuiltinFunctionId>(
5997 Smi::cast(function_identifier())->value()); 6014 Smi::cast(function_identifier())->value());
5998 } 6015 }
5999 6016
6000 void SharedFunctionInfo::set_builtin_function_id(BuiltinFunctionId id) { 6017 void SharedFunctionInfo::set_builtin_function_id(BuiltinFunctionId id) {
6001 set_function_identifier(Smi::FromInt(id)); 6018 set_function_identifier(Smi::FromInt(id));
6002 } 6019 }
6003 6020
6004 bool SharedFunctionInfo::HasInferredName() { 6021 bool SharedFunctionInfo::HasInferredName() {
6005 return function_identifier()->IsString(); 6022 return function_identifier()->IsString();
6006 } 6023 }
6007 6024
6008 String* SharedFunctionInfo::inferred_name() { 6025 String* SharedFunctionInfo::inferred_name() {
6009 if (HasInferredName()) { 6026 if (HasInferredName()) {
6010 return String::cast(function_identifier()); 6027 return String::cast(function_identifier());
6011 } 6028 }
6012 DCHECK(function_identifier()->IsUndefined() || HasBuiltinFunctionId()); 6029 Isolate* isolate = GetIsolate();
6013 return GetIsolate()->heap()->empty_string(); 6030 DCHECK(function_identifier()->IsUndefined(isolate) || HasBuiltinFunctionId());
6031 return isolate->heap()->empty_string();
6014 } 6032 }
6015 6033
6016 void SharedFunctionInfo::set_inferred_name(String* inferred_name) { 6034 void SharedFunctionInfo::set_inferred_name(String* inferred_name) {
6017 DCHECK(function_identifier()->IsUndefined() || HasInferredName()); 6035 DCHECK(function_identifier()->IsUndefined(GetIsolate()) || HasInferredName());
6018 set_function_identifier(inferred_name); 6036 set_function_identifier(inferred_name);
6019 } 6037 }
6020 6038
6021 int SharedFunctionInfo::ic_age() { 6039 int SharedFunctionInfo::ic_age() {
6022 return ICAgeBits::decode(counters()); 6040 return ICAgeBits::decode(counters());
6023 } 6041 }
6024 6042
6025 6043
6026 void SharedFunctionInfo::set_ic_age(int ic_age) { 6044 void SharedFunctionInfo::set_ic_age(int ic_age) {
6027 set_counters(ICAgeBits::update(counters(), ic_age)); 6045 set_counters(ICAgeBits::update(counters(), ic_age));
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
6093 6111
6094 6112
6095 void SharedFunctionInfo::set_disable_optimization_reason(BailoutReason reason) { 6113 void SharedFunctionInfo::set_disable_optimization_reason(BailoutReason reason) {
6096 set_opt_count_and_bailout_reason(DisabledOptimizationReasonBits::update( 6114 set_opt_count_and_bailout_reason(DisabledOptimizationReasonBits::update(
6097 opt_count_and_bailout_reason(), reason)); 6115 opt_count_and_bailout_reason(), reason));
6098 } 6116 }
6099 6117
6100 6118
6101 bool SharedFunctionInfo::IsBuiltin() { 6119 bool SharedFunctionInfo::IsBuiltin() {
6102 Object* script_obj = script(); 6120 Object* script_obj = script();
6103 if (script_obj->IsUndefined()) return true; 6121 if (script_obj->IsUndefined(GetIsolate())) return true;
6104 Script* script = Script::cast(script_obj); 6122 Script* script = Script::cast(script_obj);
6105 Script::Type type = static_cast<Script::Type>(script->type()); 6123 Script::Type type = static_cast<Script::Type>(script->type());
6106 return type != Script::TYPE_NORMAL; 6124 return type != Script::TYPE_NORMAL;
6107 } 6125 }
6108 6126
6109 6127
6110 bool SharedFunctionInfo::IsSubjectToDebugging() { return !IsBuiltin(); } 6128 bool SharedFunctionInfo::IsSubjectToDebugging() { return !IsBuiltin(); }
6111 6129
6112 6130
6113 bool SharedFunctionInfo::OptimizedCodeMapIsCleared() const { 6131 bool SharedFunctionInfo::OptimizedCodeMapIsCleared() const {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
6226 6244
6227 JSObject* JSFunction::global_proxy() { 6245 JSObject* JSFunction::global_proxy() {
6228 return context()->global_proxy(); 6246 return context()->global_proxy();
6229 } 6247 }
6230 6248
6231 6249
6232 Context* JSFunction::native_context() { return context()->native_context(); } 6250 Context* JSFunction::native_context() { return context()->native_context(); }
6233 6251
6234 6252
6235 void JSFunction::set_context(Object* value) { 6253 void JSFunction::set_context(Object* value) {
6236 DCHECK(value->IsUndefined() || value->IsContext()); 6254 DCHECK(value->IsUndefined(GetIsolate()) || value->IsContext());
6237 WRITE_FIELD(this, kContextOffset, value); 6255 WRITE_FIELD(this, kContextOffset, value);
6238 WRITE_BARRIER(GetHeap(), this, kContextOffset, value); 6256 WRITE_BARRIER(GetHeap(), this, kContextOffset, value);
6239 } 6257 }
6240 6258
6241 ACCESSORS(JSFunction, prototype_or_initial_map, Object, 6259 ACCESSORS(JSFunction, prototype_or_initial_map, Object,
6242 kPrototypeOrInitialMapOffset) 6260 kPrototypeOrInitialMapOffset)
6243 6261
6244 6262
6245 Map* JSFunction::initial_map() { 6263 Map* JSFunction::initial_map() {
6246 return Map::cast(prototype_or_initial_map()); 6264 return Map::cast(prototype_or_initial_map());
6247 } 6265 }
6248 6266
6249 6267
6250 bool JSFunction::has_initial_map() { 6268 bool JSFunction::has_initial_map() {
6251 return prototype_or_initial_map()->IsMap(); 6269 return prototype_or_initial_map()->IsMap();
6252 } 6270 }
6253 6271
6254 6272
6255 bool JSFunction::has_instance_prototype() { 6273 bool JSFunction::has_instance_prototype() {
6256 return has_initial_map() || !prototype_or_initial_map()->IsTheHole(); 6274 return has_initial_map() ||
6275 !prototype_or_initial_map()->IsTheHole(GetIsolate());
6257 } 6276 }
6258 6277
6259 6278
6260 bool JSFunction::has_prototype() { 6279 bool JSFunction::has_prototype() {
6261 return map()->has_non_instance_prototype() || has_instance_prototype(); 6280 return map()->has_non_instance_prototype() || has_instance_prototype();
6262 } 6281 }
6263 6282
6264 6283
6265 Object* JSFunction::instance_prototype() { 6284 Object* JSFunction::instance_prototype() {
6266 DCHECK(has_instance_prototype()); 6285 DCHECK(has_instance_prototype());
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
6642 #endif 6661 #endif
6643 6662
6644 6663
6645 ACCESSORS(JSRegExp, data, Object, kDataOffset) 6664 ACCESSORS(JSRegExp, data, Object, kDataOffset)
6646 ACCESSORS(JSRegExp, flags, Object, kFlagsOffset) 6665 ACCESSORS(JSRegExp, flags, Object, kFlagsOffset)
6647 ACCESSORS(JSRegExp, source, Object, kSourceOffset) 6666 ACCESSORS(JSRegExp, source, Object, kSourceOffset)
6648 6667
6649 6668
6650 JSRegExp::Type JSRegExp::TypeTag() { 6669 JSRegExp::Type JSRegExp::TypeTag() {
6651 Object* data = this->data(); 6670 Object* data = this->data();
6652 if (data->IsUndefined()) return JSRegExp::NOT_COMPILED; 6671 if (data->IsUndefined(GetIsolate())) return JSRegExp::NOT_COMPILED;
6653 Smi* smi = Smi::cast(FixedArray::cast(data)->get(kTagIndex)); 6672 Smi* smi = Smi::cast(FixedArray::cast(data)->get(kTagIndex));
6654 return static_cast<JSRegExp::Type>(smi->value()); 6673 return static_cast<JSRegExp::Type>(smi->value());
6655 } 6674 }
6656 6675
6657 6676
6658 int JSRegExp::CaptureCount() { 6677 int JSRegExp::CaptureCount() {
6659 switch (TypeTag()) { 6678 switch (TypeTag()) {
6660 case ATOM: 6679 case ATOM:
6661 return 0; 6680 return 0;
6662 case IRREGEXP: 6681 case IRREGEXP:
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
7331 return (getter() == getter_value) && (setter() == setter_value); 7350 return (getter() == getter_value) && (setter() == setter_value);
7332 } 7351 }
7333 7352
7334 7353
7335 bool AccessorPair::ContainsAccessor() { 7354 bool AccessorPair::ContainsAccessor() {
7336 return IsJSAccessor(getter()) || IsJSAccessor(setter()); 7355 return IsJSAccessor(getter()) || IsJSAccessor(setter());
7337 } 7356 }
7338 7357
7339 7358
7340 bool AccessorPair::IsJSAccessor(Object* obj) { 7359 bool AccessorPair::IsJSAccessor(Object* obj) {
7341 return obj->IsCallable() || obj->IsUndefined(); 7360 return obj->IsCallable() || obj->IsUndefined(GetIsolate());
7342 } 7361 }
7343 7362
7344 7363
7345 template<typename Derived, typename Shape, typename Key> 7364 template<typename Derived, typename Shape, typename Key>
7346 void Dictionary<Derived, Shape, Key>::SetEntry(int entry, 7365 void Dictionary<Derived, Shape, Key>::SetEntry(int entry,
7347 Handle<Object> key, 7366 Handle<Object> key,
7348 Handle<Object> value) { 7367 Handle<Object> value) {
7349 this->SetEntry(entry, key, value, PropertyDetails(Smi::FromInt(0))); 7368 this->SetEntry(entry, key, value, PropertyDetails(Smi::FromInt(0)));
7350 } 7369 }
7351 7370
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
7476 Object* raw_value = dict->ValueAt(entry); 7495 Object* raw_value = dict->ValueAt(entry);
7477 DCHECK(raw_value->IsPropertyCell()); 7496 DCHECK(raw_value->IsPropertyCell());
7478 PropertyCell* cell = PropertyCell::cast(raw_value); 7497 PropertyCell* cell = PropertyCell::cast(raw_value);
7479 cell->set_property_details(value); 7498 cell->set_property_details(value);
7480 } 7499 }
7481 7500
7482 7501
7483 template <typename Dictionary> 7502 template <typename Dictionary>
7484 bool GlobalDictionaryShape::IsDeleted(Dictionary* dict, int entry) { 7503 bool GlobalDictionaryShape::IsDeleted(Dictionary* dict, int entry) {
7485 DCHECK(dict->ValueAt(entry)->IsPropertyCell()); 7504 DCHECK(dict->ValueAt(entry)->IsPropertyCell());
7486 return PropertyCell::cast(dict->ValueAt(entry))->value()->IsTheHole(); 7505 Isolate* isolate = dict->GetIsolate();
7506 return PropertyCell::cast(dict->ValueAt(entry))->value()->IsTheHole(isolate);
7487 } 7507 }
7488 7508
7489 7509
7490 bool ObjectHashTableShape::IsMatch(Handle<Object> key, Object* other) { 7510 bool ObjectHashTableShape::IsMatch(Handle<Object> key, Object* other) {
7491 return key->SameValue(other); 7511 return key->SameValue(other);
7492 } 7512 }
7493 7513
7494 7514
7495 uint32_t ObjectHashTableShape::Hash(Handle<Object> key) { 7515 uint32_t ObjectHashTableShape::Hash(Handle<Object> key) {
7496 return Smi::cast(key->GetHash())->value(); 7516 return Smi::cast(key->GetHash())->value();
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
7750 DCHECK_EQ(isolate_->relocatable_top(), this); 7770 DCHECK_EQ(isolate_->relocatable_top(), this);
7751 isolate_->set_relocatable_top(prev_); 7771 isolate_->set_relocatable_top(prev_);
7752 } 7772 }
7753 7773
7754 7774
7755 template<class Derived, class TableType> 7775 template<class Derived, class TableType>
7756 Object* OrderedHashTableIterator<Derived, TableType>::CurrentKey() { 7776 Object* OrderedHashTableIterator<Derived, TableType>::CurrentKey() {
7757 TableType* table(TableType::cast(this->table())); 7777 TableType* table(TableType::cast(this->table()));
7758 int index = Smi::cast(this->index())->value(); 7778 int index = Smi::cast(this->index())->value();
7759 Object* key = table->KeyAt(index); 7779 Object* key = table->KeyAt(index);
7760 DCHECK(!key->IsTheHole()); 7780 DCHECK(!key->IsTheHole(table->GetIsolate()));
7761 return key; 7781 return key;
7762 } 7782 }
7763 7783
7764 7784
7765 void JSSetIterator::PopulateValueArray(FixedArray* array) { 7785 void JSSetIterator::PopulateValueArray(FixedArray* array) {
7766 array->set(0, CurrentKey()); 7786 array->set(0, CurrentKey());
7767 } 7787 }
7768 7788
7769 7789
7770 void JSMapIterator::PopulateValueArray(FixedArray* array) { 7790 void JSMapIterator::PopulateValueArray(FixedArray* array) {
7771 array->set(0, CurrentKey()); 7791 array->set(0, CurrentKey());
7772 array->set(1, CurrentValue()); 7792 array->set(1, CurrentValue());
7773 } 7793 }
7774 7794
7775 7795
7776 Object* JSMapIterator::CurrentValue() { 7796 Object* JSMapIterator::CurrentValue() {
7777 OrderedHashMap* table(OrderedHashMap::cast(this->table())); 7797 OrderedHashMap* table(OrderedHashMap::cast(this->table()));
7778 int index = Smi::cast(this->index())->value(); 7798 int index = Smi::cast(this->index())->value();
7779 Object* value = table->ValueAt(index); 7799 Object* value = table->ValueAt(index);
7780 DCHECK(!value->IsTheHole()); 7800 DCHECK(!value->IsTheHole(table->GetIsolate()));
7781 return value; 7801 return value;
7782 } 7802 }
7783 7803
7784 7804
7785 String::SubStringRange::SubStringRange(String* string, int first, int length) 7805 String::SubStringRange::SubStringRange(String* string, int first, int length)
7786 : string_(string), 7806 : string_(string),
7787 first_(first), 7807 first_(first),
7788 length_(length == -1 ? string->length() : length) {} 7808 length_(length == -1 ? string->length() : length) {}
7789 7809
7790 7810
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
7906 #undef WRITE_INT64_FIELD 7926 #undef WRITE_INT64_FIELD
7907 #undef READ_BYTE_FIELD 7927 #undef READ_BYTE_FIELD
7908 #undef WRITE_BYTE_FIELD 7928 #undef WRITE_BYTE_FIELD
7909 #undef NOBARRIER_READ_BYTE_FIELD 7929 #undef NOBARRIER_READ_BYTE_FIELD
7910 #undef NOBARRIER_WRITE_BYTE_FIELD 7930 #undef NOBARRIER_WRITE_BYTE_FIELD
7911 7931
7912 } // namespace internal 7932 } // namespace internal
7913 } // namespace v8 7933 } // namespace v8
7914 7934
7915 #endif // V8_OBJECTS_INL_H_ 7935 #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