| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 } | 567 } |
| 568 | 568 |
| 569 | 569 |
| 570 bool Object::IsContext() { | 570 bool Object::IsContext() { |
| 571 if (Object::IsHeapObject()) { | 571 if (Object::IsHeapObject()) { |
| 572 Map* map = HeapObject::cast(this)->map(); | 572 Map* map = HeapObject::cast(this)->map(); |
| 573 Heap* heap = map->GetHeap(); | 573 Heap* heap = map->GetHeap(); |
| 574 return (map == heap->function_context_map() || | 574 return (map == heap->function_context_map() || |
| 575 map == heap->catch_context_map() || | 575 map == heap->catch_context_map() || |
| 576 map == heap->with_context_map() || | 576 map == heap->with_context_map() || |
| 577 map == heap->global_context_map() || | 577 map == heap->native_context_map() || |
| 578 map == heap->block_context_map() || | 578 map == heap->block_context_map() || |
| 579 map == heap->module_context_map()); | 579 map == heap->module_context_map()); |
| 580 } | 580 } |
| 581 return false; | 581 return false; |
| 582 } | 582 } |
| 583 | 583 |
| 584 | 584 |
| 585 bool Object::IsGlobalContext() { | 585 bool Object::IsNativeContext() { |
| 586 return Object::IsHeapObject() && | 586 return Object::IsHeapObject() && |
| 587 HeapObject::cast(this)->map() == | 587 HeapObject::cast(this)->map() == |
| 588 HeapObject::cast(this)->GetHeap()->global_context_map(); | 588 HeapObject::cast(this)->GetHeap()->native_context_map(); |
| 589 } | 589 } |
| 590 | 590 |
| 591 | 591 |
| 592 bool Object::IsModuleContext() { | 592 bool Object::IsModuleContext() { |
| 593 return Object::IsHeapObject() && | 593 return Object::IsHeapObject() && |
| 594 HeapObject::cast(this)->map() == | 594 HeapObject::cast(this)->map() == |
| 595 HeapObject::cast(this)->GetHeap()->module_context_map(); | 595 HeapObject::cast(this)->GetHeap()->module_context_map(); |
| 596 } | 596 } |
| 597 | 597 |
| 598 | 598 |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1332 return this; | 1332 return this; |
| 1333 } | 1333 } |
| 1334 | 1334 |
| 1335 | 1335 |
| 1336 MaybeObject* JSObject::GetElementsTransitionMap(Isolate* isolate, | 1336 MaybeObject* JSObject::GetElementsTransitionMap(Isolate* isolate, |
| 1337 ElementsKind to_kind) { | 1337 ElementsKind to_kind) { |
| 1338 Map* current_map = map(); | 1338 Map* current_map = map(); |
| 1339 ElementsKind from_kind = current_map->elements_kind(); | 1339 ElementsKind from_kind = current_map->elements_kind(); |
| 1340 if (from_kind == to_kind) return current_map; | 1340 if (from_kind == to_kind) return current_map; |
| 1341 | 1341 |
| 1342 Context* global_context = isolate->context()->global_context(); | 1342 Context* native_context = isolate->context()->native_context(); |
| 1343 Object* maybe_array_maps = global_context->js_array_maps(); | 1343 Object* maybe_array_maps = native_context->js_array_maps(); |
| 1344 if (maybe_array_maps->IsFixedArray()) { | 1344 if (maybe_array_maps->IsFixedArray()) { |
| 1345 FixedArray* array_maps = FixedArray::cast(maybe_array_maps); | 1345 FixedArray* array_maps = FixedArray::cast(maybe_array_maps); |
| 1346 if (array_maps->get(from_kind) == current_map) { | 1346 if (array_maps->get(from_kind) == current_map) { |
| 1347 Object* maybe_transitioned_map = array_maps->get(to_kind); | 1347 Object* maybe_transitioned_map = array_maps->get(to_kind); |
| 1348 if (maybe_transitioned_map->IsMap()) { | 1348 if (maybe_transitioned_map->IsMap()) { |
| 1349 return Map::cast(maybe_transitioned_map); | 1349 return Map::cast(maybe_transitioned_map); |
| 1350 } | 1350 } |
| 1351 } | 1351 } |
| 1352 } | 1352 } |
| 1353 | 1353 |
| (...skipping 2308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3662 | 3662 |
| 3663 | 3663 |
| 3664 ACCESSORS(Map, code_cache, Object, kCodeCacheOffset) | 3664 ACCESSORS(Map, code_cache, Object, kCodeCacheOffset) |
| 3665 ACCESSORS(Map, constructor, Object, kConstructorOffset) | 3665 ACCESSORS(Map, constructor, Object, kConstructorOffset) |
| 3666 | 3666 |
| 3667 ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset) | 3667 ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset) |
| 3668 ACCESSORS(JSFunction, literals_or_bindings, FixedArray, kLiteralsOffset) | 3668 ACCESSORS(JSFunction, literals_or_bindings, FixedArray, kLiteralsOffset) |
| 3669 ACCESSORS(JSFunction, next_function_link, Object, kNextFunctionLinkOffset) | 3669 ACCESSORS(JSFunction, next_function_link, Object, kNextFunctionLinkOffset) |
| 3670 | 3670 |
| 3671 ACCESSORS(GlobalObject, builtins, JSBuiltinsObject, kBuiltinsOffset) | 3671 ACCESSORS(GlobalObject, builtins, JSBuiltinsObject, kBuiltinsOffset) |
| 3672 ACCESSORS(GlobalObject, global_context, Context, kGlobalContextOffset) | 3672 ACCESSORS(GlobalObject, native_context, Context, kNativeContextOffset) |
| 3673 ACCESSORS(GlobalObject, global_receiver, JSObject, kGlobalReceiverOffset) | 3673 ACCESSORS(GlobalObject, global_receiver, JSObject, kGlobalReceiverOffset) |
| 3674 | 3674 |
| 3675 ACCESSORS(JSGlobalProxy, context, Object, kContextOffset) | 3675 ACCESSORS(JSGlobalProxy, context, Object, kContextOffset) |
| 3676 | 3676 |
| 3677 ACCESSORS(AccessorInfo, getter, Object, kGetterOffset) | 3677 ACCESSORS(AccessorInfo, getter, Object, kGetterOffset) |
| 3678 ACCESSORS(AccessorInfo, setter, Object, kSetterOffset) | 3678 ACCESSORS(AccessorInfo, setter, Object, kSetterOffset) |
| 3679 ACCESSORS(AccessorInfo, data, Object, kDataOffset) | 3679 ACCESSORS(AccessorInfo, data, Object, kDataOffset) |
| 3680 ACCESSORS(AccessorInfo, name, Object, kNameOffset) | 3680 ACCESSORS(AccessorInfo, name, Object, kNameOffset) |
| 3681 ACCESSORS_TO_SMI(AccessorInfo, flag, kFlagOffset) | 3681 ACCESSORS_TO_SMI(AccessorInfo, flag, kFlagOffset) |
| 3682 ACCESSORS(AccessorInfo, expected_receiver_type, Object, | 3682 ACCESSORS(AccessorInfo, expected_receiver_type, Object, |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4217 | 4217 |
| 4218 void JSFunction::ReplaceCode(Code* code) { | 4218 void JSFunction::ReplaceCode(Code* code) { |
| 4219 bool was_optimized = IsOptimized(); | 4219 bool was_optimized = IsOptimized(); |
| 4220 bool is_optimized = code->kind() == Code::OPTIMIZED_FUNCTION; | 4220 bool is_optimized = code->kind() == Code::OPTIMIZED_FUNCTION; |
| 4221 | 4221 |
| 4222 set_code(code); | 4222 set_code(code); |
| 4223 | 4223 |
| 4224 // Add/remove the function from the list of optimized functions for this | 4224 // Add/remove the function from the list of optimized functions for this |
| 4225 // context based on the state change. | 4225 // context based on the state change. |
| 4226 if (!was_optimized && is_optimized) { | 4226 if (!was_optimized && is_optimized) { |
| 4227 context()->global_context()->AddOptimizedFunction(this); | 4227 context()->native_context()->AddOptimizedFunction(this); |
| 4228 } | 4228 } |
| 4229 if (was_optimized && !is_optimized) { | 4229 if (was_optimized && !is_optimized) { |
| 4230 context()->global_context()->RemoveOptimizedFunction(this); | 4230 context()->native_context()->RemoveOptimizedFunction(this); |
| 4231 } | 4231 } |
| 4232 } | 4232 } |
| 4233 | 4233 |
| 4234 | 4234 |
| 4235 Context* JSFunction::context() { | 4235 Context* JSFunction::context() { |
| 4236 return Context::cast(READ_FIELD(this, kContextOffset)); | 4236 return Context::cast(READ_FIELD(this, kContextOffset)); |
| 4237 } | 4237 } |
| 4238 | 4238 |
| 4239 | 4239 |
| 4240 Object* JSFunction::unchecked_context() { | 4240 Object* JSFunction::unchecked_context() { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 4263 } | 4263 } |
| 4264 | 4264 |
| 4265 | 4265 |
| 4266 void JSFunction::set_initial_map(Map* value) { | 4266 void JSFunction::set_initial_map(Map* value) { |
| 4267 set_prototype_or_initial_map(value); | 4267 set_prototype_or_initial_map(value); |
| 4268 } | 4268 } |
| 4269 | 4269 |
| 4270 | 4270 |
| 4271 MaybeObject* JSFunction::set_initial_map_and_cache_transitions( | 4271 MaybeObject* JSFunction::set_initial_map_and_cache_transitions( |
| 4272 Map* initial_map) { | 4272 Map* initial_map) { |
| 4273 Context* global_context = context()->global_context(); | 4273 Context* native_context = context()->native_context(); |
| 4274 Object* array_function = | 4274 Object* array_function = |
| 4275 global_context->get(Context::ARRAY_FUNCTION_INDEX); | 4275 native_context->get(Context::ARRAY_FUNCTION_INDEX); |
| 4276 if (array_function->IsJSFunction() && | 4276 if (array_function->IsJSFunction() && |
| 4277 this == JSFunction::cast(array_function)) { | 4277 this == JSFunction::cast(array_function)) { |
| 4278 // Replace all of the cached initial array maps in the global context with | 4278 // Replace all of the cached initial array maps in the native context with |
| 4279 // the appropriate transitioned elements kind maps. | 4279 // the appropriate transitioned elements kind maps. |
| 4280 Heap* heap = GetHeap(); | 4280 Heap* heap = GetHeap(); |
| 4281 MaybeObject* maybe_maps = | 4281 MaybeObject* maybe_maps = |
| 4282 heap->AllocateFixedArrayWithHoles(kElementsKindCount); | 4282 heap->AllocateFixedArrayWithHoles(kElementsKindCount); |
| 4283 FixedArray* maps; | 4283 FixedArray* maps; |
| 4284 if (!maybe_maps->To(&maps)) return maybe_maps; | 4284 if (!maybe_maps->To(&maps)) return maybe_maps; |
| 4285 | 4285 |
| 4286 Map* current_map = initial_map; | 4286 Map* current_map = initial_map; |
| 4287 ElementsKind kind = current_map->elements_kind(); | 4287 ElementsKind kind = current_map->elements_kind(); |
| 4288 ASSERT(kind == GetInitialFastElementsKind()); | 4288 ASSERT(kind == GetInitialFastElementsKind()); |
| 4289 maps->set(kind, current_map); | 4289 maps->set(kind, current_map); |
| 4290 for (int i = GetSequenceIndexFromFastElementsKind(kind) + 1; | 4290 for (int i = GetSequenceIndexFromFastElementsKind(kind) + 1; |
| 4291 i < kFastElementsKindCount; ++i) { | 4291 i < kFastElementsKindCount; ++i) { |
| 4292 Map* new_map; | 4292 Map* new_map; |
| 4293 ElementsKind next_kind = GetFastElementsKindFromSequenceIndex(i); | 4293 ElementsKind next_kind = GetFastElementsKindFromSequenceIndex(i); |
| 4294 MaybeObject* maybe_new_map = | 4294 MaybeObject* maybe_new_map = |
| 4295 current_map->CopyAsElementsKind(next_kind, INSERT_TRANSITION); | 4295 current_map->CopyAsElementsKind(next_kind, INSERT_TRANSITION); |
| 4296 if (!maybe_new_map->To(&new_map)) return maybe_new_map; | 4296 if (!maybe_new_map->To(&new_map)) return maybe_new_map; |
| 4297 maps->set(next_kind, new_map); | 4297 maps->set(next_kind, new_map); |
| 4298 current_map = new_map; | 4298 current_map = new_map; |
| 4299 } | 4299 } |
| 4300 global_context->set_js_array_maps(maps); | 4300 native_context->set_js_array_maps(maps); |
| 4301 } | 4301 } |
| 4302 set_initial_map(initial_map); | 4302 set_initial_map(initial_map); |
| 4303 return this; | 4303 return this; |
| 4304 } | 4304 } |
| 4305 | 4305 |
| 4306 | 4306 |
| 4307 bool JSFunction::has_initial_map() { | 4307 bool JSFunction::has_initial_map() { |
| 4308 return prototype_or_initial_map()->IsMap(); | 4308 return prototype_or_initial_map()->IsMap(); |
| 4309 } | 4309 } |
| 4310 | 4310 |
| (...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5312 #undef WRITE_UINT32_FIELD | 5312 #undef WRITE_UINT32_FIELD |
| 5313 #undef READ_SHORT_FIELD | 5313 #undef READ_SHORT_FIELD |
| 5314 #undef WRITE_SHORT_FIELD | 5314 #undef WRITE_SHORT_FIELD |
| 5315 #undef READ_BYTE_FIELD | 5315 #undef READ_BYTE_FIELD |
| 5316 #undef WRITE_BYTE_FIELD | 5316 #undef WRITE_BYTE_FIELD |
| 5317 | 5317 |
| 5318 | 5318 |
| 5319 } } // namespace v8::internal | 5319 } } // namespace v8::internal |
| 5320 | 5320 |
| 5321 #endif // V8_OBJECTS_INL_H_ | 5321 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |