| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #include "src/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
| 6 | 6 |
| 7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
| 8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
| 9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
| 10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // prototype including own lookups. | 49 // prototype including own lookups. |
| 50 // | 50 // |
| 51 // Additionally, we need to make sure that we do not cache results | 51 // Additionally, we need to make sure that we do not cache results |
| 52 // for objects that require access checks. | 52 // for objects that require access checks. |
| 53 if (receiver_obj->IsJSObject()) { | 53 if (receiver_obj->IsJSObject()) { |
| 54 if (!receiver_obj->IsJSGlobalProxy() && | 54 if (!receiver_obj->IsJSGlobalProxy() && |
| 55 !receiver_obj->IsAccessCheckNeeded() && key_obj->IsName()) { | 55 !receiver_obj->IsAccessCheckNeeded() && key_obj->IsName()) { |
| 56 DisallowHeapAllocation no_allocation; | 56 DisallowHeapAllocation no_allocation; |
| 57 Handle<JSObject> receiver = Handle<JSObject>::cast(receiver_obj); | 57 Handle<JSObject> receiver = Handle<JSObject>::cast(receiver_obj); |
| 58 Handle<Name> key = Handle<Name>::cast(key_obj); | 58 Handle<Name> key = Handle<Name>::cast(key_obj); |
| 59 if (receiver->IsGlobalObject()) { | 59 if (receiver->IsJSGlobalObject()) { |
| 60 // Attempt dictionary lookup. | 60 // Attempt dictionary lookup. |
| 61 GlobalDictionary* dictionary = receiver->global_dictionary(); | 61 GlobalDictionary* dictionary = receiver->global_dictionary(); |
| 62 int entry = dictionary->FindEntry(key); | 62 int entry = dictionary->FindEntry(key); |
| 63 if (entry != GlobalDictionary::kNotFound) { | 63 if (entry != GlobalDictionary::kNotFound) { |
| 64 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell()); | 64 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell()); |
| 65 PropertyCell* cell = PropertyCell::cast(dictionary->ValueAt(entry)); | 65 PropertyCell* cell = PropertyCell::cast(dictionary->ValueAt(entry)); |
| 66 if (cell->property_details().type() == DATA) { | 66 if (cell->property_details().type() == DATA) { |
| 67 Object* value = cell->value(); | 67 Object* value = cell->value(); |
| 68 if (!value->IsTheHole()) return Handle<Object>(value, isolate); | 68 if (!value->IsTheHole()) return Handle<Object>(value, isolate); |
| 69 // If value is the hole (meaning, absent) do the general lookup. | 69 // If value is the hole (meaning, absent) do the general lookup. |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 CONVERT_SMI_ARG_CHECKED(slot, 0); | 331 CONVERT_SMI_ARG_CHECKED(slot, 0); |
| 332 | 332 |
| 333 // Go up context chain to the script context. | 333 // Go up context chain to the script context. |
| 334 Handle<Context> script_context(isolate->context()->script_context(), isolate); | 334 Handle<Context> script_context(isolate->context()->script_context(), isolate); |
| 335 DCHECK(script_context->IsScriptContext()); | 335 DCHECK(script_context->IsScriptContext()); |
| 336 DCHECK(script_context->get(slot)->IsPropertyCell()); | 336 DCHECK(script_context->get(slot)->IsPropertyCell()); |
| 337 | 337 |
| 338 // Lookup the named property on the global object. | 338 // Lookup the named property on the global object. |
| 339 Handle<ScopeInfo> scope_info(script_context->scope_info(), isolate); | 339 Handle<ScopeInfo> scope_info(script_context->scope_info(), isolate); |
| 340 Handle<Name> name(scope_info->ContextSlotName(slot), isolate); | 340 Handle<Name> name(scope_info->ContextSlotName(slot), isolate); |
| 341 Handle<GlobalObject> global_object(script_context->global_object(), isolate); | 341 Handle<JSGlobalObject> global_object(script_context->global_object(), |
| 342 isolate); |
| 342 LookupIterator it(global_object, name, LookupIterator::HIDDEN); | 343 LookupIterator it(global_object, name, LookupIterator::HIDDEN); |
| 343 | 344 |
| 344 // Switch to fast mode only if there is a data property and it's not on | 345 // Switch to fast mode only if there is a data property and it's not on |
| 345 // a hidden prototype. | 346 // a hidden prototype. |
| 346 if (it.state() == LookupIterator::DATA && | 347 if (it.state() == LookupIterator::DATA && |
| 347 it.GetHolder<Object>().is_identical_to(global_object)) { | 348 it.GetHolder<Object>().is_identical_to(global_object)) { |
| 348 // Now update the cell in the script context. | 349 // Now update the cell in the script context. |
| 349 Handle<PropertyCell> cell = it.GetPropertyCell(); | 350 Handle<PropertyCell> cell = it.GetPropertyCell(); |
| 350 script_context->set(slot, *cell); | 351 script_context->set(slot, *cell); |
| 351 } else { | 352 } else { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 365 Object* StoreGlobalViaContext(Isolate* isolate, int slot, Handle<Object> value, | 366 Object* StoreGlobalViaContext(Isolate* isolate, int slot, Handle<Object> value, |
| 366 LanguageMode language_mode) { | 367 LanguageMode language_mode) { |
| 367 // Go up context chain to the script context. | 368 // Go up context chain to the script context. |
| 368 Handle<Context> script_context(isolate->context()->script_context(), isolate); | 369 Handle<Context> script_context(isolate->context()->script_context(), isolate); |
| 369 DCHECK(script_context->IsScriptContext()); | 370 DCHECK(script_context->IsScriptContext()); |
| 370 DCHECK(script_context->get(slot)->IsPropertyCell()); | 371 DCHECK(script_context->get(slot)->IsPropertyCell()); |
| 371 | 372 |
| 372 // Lookup the named property on the global object. | 373 // Lookup the named property on the global object. |
| 373 Handle<ScopeInfo> scope_info(script_context->scope_info(), isolate); | 374 Handle<ScopeInfo> scope_info(script_context->scope_info(), isolate); |
| 374 Handle<Name> name(scope_info->ContextSlotName(slot), isolate); | 375 Handle<Name> name(scope_info->ContextSlotName(slot), isolate); |
| 375 Handle<GlobalObject> global_object(script_context->global_object(), isolate); | 376 Handle<JSGlobalObject> global_object(script_context->global_object(), |
| 377 isolate); |
| 376 LookupIterator it(global_object, name, LookupIterator::HIDDEN); | 378 LookupIterator it(global_object, name, LookupIterator::HIDDEN); |
| 377 | 379 |
| 378 // Switch to fast mode only if there is a data property and it's not on | 380 // Switch to fast mode only if there is a data property and it's not on |
| 379 // a hidden prototype. | 381 // a hidden prototype. |
| 380 if (it.state() == LookupIterator::DATA && | 382 if (it.state() == LookupIterator::DATA && |
| 381 it.GetHolder<Object>().is_identical_to(global_object)) { | 383 it.GetHolder<Object>().is_identical_to(global_object)) { |
| 382 // Now update cell in the script context. | 384 // Now update cell in the script context. |
| 383 Handle<PropertyCell> cell = it.GetPropertyCell(); | 385 Handle<PropertyCell> cell = it.GetPropertyCell(); |
| 384 script_context->set(slot, *cell); | 386 script_context->set(slot, *cell); |
| 385 } else { | 387 } else { |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 942 isolate, contents, JSReceiver::GetKeys(object, JSReceiver::OWN_ONLY, | 944 isolate, contents, JSReceiver::GetKeys(object, JSReceiver::OWN_ONLY, |
| 943 SKIP_SYMBOLS, CONVERT_TO_STRING)); | 945 SKIP_SYMBOLS, CONVERT_TO_STRING)); |
| 944 return *isolate->factory()->NewJSArrayWithElements(contents); | 946 return *isolate->factory()->NewJSArrayWithElements(contents); |
| 945 } | 947 } |
| 946 | 948 |
| 947 | 949 |
| 948 RUNTIME_FUNCTION(Runtime_ToFastProperties) { | 950 RUNTIME_FUNCTION(Runtime_ToFastProperties) { |
| 949 HandleScope scope(isolate); | 951 HandleScope scope(isolate); |
| 950 DCHECK(args.length() == 1); | 952 DCHECK(args.length() == 1); |
| 951 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 953 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
| 952 if (object->IsJSObject() && !object->IsGlobalObject()) { | 954 if (object->IsJSObject() && !object->IsJSGlobalObject()) { |
| 953 JSObject::MigrateSlowToFast(Handle<JSObject>::cast(object), 0, | 955 JSObject::MigrateSlowToFast(Handle<JSObject>::cast(object), 0, |
| 954 "RuntimeToFastProperties"); | 956 "RuntimeToFastProperties"); |
| 955 } | 957 } |
| 956 return *object; | 958 return *object; |
| 957 } | 959 } |
| 958 | 960 |
| 959 | 961 |
| 960 RUNTIME_FUNCTION(Runtime_AllocateHeapNumber) { | 962 RUNTIME_FUNCTION(Runtime_AllocateHeapNumber) { |
| 961 HandleScope scope(isolate); | 963 HandleScope scope(isolate); |
| 962 DCHECK(args.length() == 0); | 964 DCHECK(args.length() == 0); |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1558 | 1560 |
| 1559 RUNTIME_FUNCTION(Runtime_ObjectDefineProperties) { | 1561 RUNTIME_FUNCTION(Runtime_ObjectDefineProperties) { |
| 1560 HandleScope scope(isolate); | 1562 HandleScope scope(isolate); |
| 1561 DCHECK(args.length() == 2); | 1563 DCHECK(args.length() == 2); |
| 1562 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0); | 1564 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0); |
| 1563 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1); | 1565 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1); |
| 1564 return JSReceiver::DefineProperties(isolate, o, properties); | 1566 return JSReceiver::DefineProperties(isolate, o, properties); |
| 1565 } | 1567 } |
| 1566 } // namespace internal | 1568 } // namespace internal |
| 1567 } // namespace v8 | 1569 } // namespace v8 |
| OLD | NEW |