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

Side by Side Diff: src/runtime.cc

Issue 10779012: Removing LookupTransition from LookupRealNamedProperty and related utility functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « src/profile-generator.cc ('k') | src/stub-cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 935 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 } 946 }
947 } 947 }
948 948
949 949
950 // Recursively traverses hidden prototypes if property is not found 950 // Recursively traverses hidden prototypes if property is not found
951 static void GetOwnPropertyImplementation(JSObject* obj, 951 static void GetOwnPropertyImplementation(JSObject* obj,
952 String* name, 952 String* name,
953 LookupResult* result) { 953 LookupResult* result) {
954 obj->LocalLookupRealNamedProperty(name, result); 954 obj->LocalLookupRealNamedProperty(name, result);
955 955
956 if (!result->IsProperty()) { 956 if (result->IsFound()) return;
957 Object* proto = obj->GetPrototype(); 957
958 if (proto->IsJSObject() && 958 Object* proto = obj->GetPrototype();
959 JSObject::cast(proto)->map()->is_hidden_prototype()) 959 if (proto->IsJSObject() &&
960 GetOwnPropertyImplementation(JSObject::cast(proto), 960 JSObject::cast(proto)->map()->is_hidden_prototype())
961 name, result); 961 GetOwnPropertyImplementation(JSObject::cast(proto),
962 } 962 name, result);
963 } 963 }
964 964
965 965
966 static bool CheckAccessException(LookupResult* result, 966 static bool CheckAccessException(LookupResult* result,
967 v8::AccessType access_type) { 967 v8::AccessType access_type) {
968 if (result->type() == CALLBACKS) { 968 if (result->type() == CALLBACKS) {
969 Object* callback = result->GetCallbackObject(); 969 Object* callback = result->GetCallbackObject();
970 if (callback->IsAccessorInfo()) { 970 if (callback->IsAccessorInfo()) {
971 AccessorInfo* info = AccessorInfo::cast(callback); 971 AccessorInfo* info = AccessorInfo::cast(callback);
972 bool can_access = 972 bool can_access =
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 1366
1367 if (is_var || is_const) { 1367 if (is_var || is_const) {
1368 // Lookup the property in the global object, and don't set the 1368 // Lookup the property in the global object, and don't set the
1369 // value of the variable if the property is already there. 1369 // value of the variable if the property is already there.
1370 // Do the lookup locally only, see ES5 erratum. 1370 // Do the lookup locally only, see ES5 erratum.
1371 LookupResult lookup(isolate); 1371 LookupResult lookup(isolate);
1372 if (FLAG_es52_globals) { 1372 if (FLAG_es52_globals) {
1373 Object* obj = *global; 1373 Object* obj = *global;
1374 do { 1374 do {
1375 JSObject::cast(obj)->LocalLookup(*name, &lookup); 1375 JSObject::cast(obj)->LocalLookup(*name, &lookup);
1376 if (lookup.IsProperty()) break; 1376 if (lookup.IsFound()) break;
1377 obj = obj->GetPrototype(); 1377 obj = obj->GetPrototype();
1378 } while (obj->IsJSObject() && 1378 } while (obj->IsJSObject() &&
1379 JSObject::cast(obj)->map()->is_hidden_prototype()); 1379 JSObject::cast(obj)->map()->is_hidden_prototype());
1380 } else { 1380 } else {
1381 global->Lookup(*name, &lookup); 1381 global->Lookup(*name, &lookup);
1382 } 1382 }
1383 if (lookup.IsProperty()) { 1383 if (lookup.IsFound()) {
1384 // We found an existing property. Unless it was an interceptor 1384 // We found an existing property. Unless it was an interceptor
1385 // that claims the property is absent, skip this declaration. 1385 // that claims the property is absent, skip this declaration.
1386 if (!lookup.IsInterceptor()) continue; 1386 if (!lookup.IsInterceptor()) continue;
1387 PropertyAttributes attributes = global->GetPropertyAttribute(*name); 1387 PropertyAttributes attributes = global->GetPropertyAttribute(*name);
1388 if (attributes != ABSENT) continue; 1388 if (attributes != ABSENT) continue;
1389 // Fall-through and introduce the absent property by using 1389 // Fall-through and introduce the absent property by using
1390 // SetProperty. 1390 // SetProperty.
1391 } 1391 }
1392 } else if (is_function) { 1392 } else if (is_function) {
1393 // Copy the function and update its context. Use it as value. 1393 // Copy the function and update its context. Use it as value.
(...skipping 15 matching lines...) Expand all
1409 if (!is_eval || is_module) { 1409 if (!is_eval || is_module) {
1410 attr |= DONT_DELETE; 1410 attr |= DONT_DELETE;
1411 } 1411 }
1412 bool is_native = DeclareGlobalsNativeFlag::decode(flags); 1412 bool is_native = DeclareGlobalsNativeFlag::decode(flags);
1413 if (is_const || is_module || (is_native && is_function)) { 1413 if (is_const || is_module || (is_native && is_function)) {
1414 attr |= READ_ONLY; 1414 attr |= READ_ONLY;
1415 } 1415 }
1416 1416
1417 LanguageMode language_mode = DeclareGlobalsLanguageMode::decode(flags); 1417 LanguageMode language_mode = DeclareGlobalsLanguageMode::decode(flags);
1418 1418
1419 if (!lookup.IsProperty() || is_function || is_module) { 1419 if (!lookup.IsFound() || is_function || is_module) {
1420 // If the local property exists, check that we can reconfigure it 1420 // If the local property exists, check that we can reconfigure it
1421 // as required for function declarations. 1421 // as required for function declarations.
1422 if (lookup.IsProperty() && lookup.IsDontDelete()) { 1422 if (lookup.IsFound() && lookup.IsDontDelete()) {
1423 if (lookup.IsReadOnly() || lookup.IsDontEnum() || 1423 if (lookup.IsReadOnly() || lookup.IsDontEnum() ||
1424 lookup.IsPropertyCallbacks()) { 1424 lookup.IsPropertyCallbacks()) {
1425 return ThrowRedeclarationError( 1425 return ThrowRedeclarationError(
1426 isolate, is_function ? "function" : "module", name); 1426 isolate, is_function ? "function" : "module", name);
1427 } 1427 }
1428 // If the existing property is not configurable, keep its attributes. 1428 // If the existing property is not configurable, keep its attributes.
1429 attr = lookup.GetAttributes(); 1429 attr = lookup.GetAttributes();
1430 } 1430 }
1431 // Define or redefine own property. 1431 // Define or redefine own property.
1432 RETURN_IF_EMPTY_HANDLE(isolate, 1432 RETURN_IF_EMPTY_HANDLE(isolate,
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1627 PropertyAttributes attributes = 1627 PropertyAttributes attributes =
1628 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY); 1628 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY);
1629 1629
1630 // Lookup the property locally in the global object. If it isn't 1630 // Lookup the property locally in the global object. If it isn't
1631 // there, we add the property and take special precautions to always 1631 // there, we add the property and take special precautions to always
1632 // add it as a local property even in case of callbacks in the 1632 // add it as a local property even in case of callbacks in the
1633 // prototype chain (this rules out using SetProperty). 1633 // prototype chain (this rules out using SetProperty).
1634 // We use SetLocalPropertyIgnoreAttributes instead 1634 // We use SetLocalPropertyIgnoreAttributes instead
1635 LookupResult lookup(isolate); 1635 LookupResult lookup(isolate);
1636 global->LocalLookup(*name, &lookup); 1636 global->LocalLookup(*name, &lookup);
1637 if (!lookup.IsProperty()) { 1637 if (!lookup.IsFound()) {
1638 return global->SetLocalPropertyIgnoreAttributes(*name, 1638 return global->SetLocalPropertyIgnoreAttributes(*name,
1639 *value, 1639 *value,
1640 attributes); 1640 attributes);
1641 } 1641 }
1642 1642
1643 if (!lookup.IsReadOnly()) { 1643 if (!lookup.IsReadOnly()) {
1644 // Restore global object from context (in case of GC) and continue 1644 // Restore global object from context (in case of GC) and continue
1645 // with setting the value. 1645 // with setting the value.
1646 HandleScope handle_scope(isolate); 1646 HandleScope handle_scope(isolate);
1647 Handle<GlobalObject> global(isolate->context()->global()); 1647 Handle<GlobalObject> global(isolate->context()->global());
(...skipping 2903 matching lines...) Expand 10 before | Expand all | Expand 10 after
4551 kStrictMode); 4551 kStrictMode);
4552 } 4552 }
4553 } 4553 }
4554 4554
4555 // Take special care when attributes are different and there is already 4555 // Take special care when attributes are different and there is already
4556 // a property. For simplicity we normalize the property which enables us 4556 // a property. For simplicity we normalize the property which enables us
4557 // to not worry about changing the instance_descriptor and creating a new 4557 // to not worry about changing the instance_descriptor and creating a new
4558 // map. The current version of SetObjectProperty does not handle attributes 4558 // map. The current version of SetObjectProperty does not handle attributes
4559 // correctly in the case where a property is a field and is reset with 4559 // correctly in the case where a property is a field and is reset with
4560 // new attributes. 4560 // new attributes.
4561 if (result.IsProperty() && 4561 if (result.IsFound() &&
4562 (attr != result.GetAttributes() || result.IsPropertyCallbacks())) { 4562 (attr != result.GetAttributes() || result.IsPropertyCallbacks())) {
4563 // New attributes - normalize to avoid writing to instance descriptor 4563 // New attributes - normalize to avoid writing to instance descriptor
4564 if (js_object->IsJSGlobalProxy()) { 4564 if (js_object->IsJSGlobalProxy()) {
4565 // Since the result is a property, the prototype will exist so 4565 // Since the result is a property, the prototype will exist so
4566 // we don't have to check for null. 4566 // we don't have to check for null.
4567 js_object = Handle<JSObject>(JSObject::cast(js_object->GetPrototype())); 4567 js_object = Handle<JSObject>(JSObject::cast(js_object->GetPrototype()));
4568 } 4568 }
4569 JSObject::NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0); 4569 JSObject::NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0);
4570 // Use IgnoreAttributes version since a readonly property may be 4570 // Use IgnoreAttributes version since a readonly property may be
4571 // overridden and SetProperty does not allow this. 4571 // overridden and SetProperty does not allow this.
(...skipping 5842 matching lines...) Expand 10 before | Expand all | Expand 10 after
10414 } 10414 }
10415 10415
10416 // Find the number of objects making up this. 10416 // Find the number of objects making up this.
10417 int length = LocalPrototypeChainLength(*obj); 10417 int length = LocalPrototypeChainLength(*obj);
10418 10418
10419 // Try local lookup on each of the objects. 10419 // Try local lookup on each of the objects.
10420 Handle<JSObject> jsproto = obj; 10420 Handle<JSObject> jsproto = obj;
10421 for (int i = 0; i < length; i++) { 10421 for (int i = 0; i < length; i++) {
10422 LookupResult result(isolate); 10422 LookupResult result(isolate);
10423 jsproto->LocalLookup(*name, &result); 10423 jsproto->LocalLookup(*name, &result);
10424 if (result.IsProperty()) { 10424 if (result.IsFound()) {
10425 // LookupResult is not GC safe as it holds raw object pointers. 10425 // LookupResult is not GC safe as it holds raw object pointers.
10426 // GC can happen later in this code so put the required fields into 10426 // GC can happen later in this code so put the required fields into
10427 // local variables using handles when required for later use. 10427 // local variables using handles when required for later use.
10428 Handle<Object> result_callback_obj; 10428 Handle<Object> result_callback_obj;
10429 if (result.IsPropertyCallbacks()) { 10429 if (result.IsPropertyCallbacks()) {
10430 result_callback_obj = Handle<Object>(result.GetCallbackObject(), 10430 result_callback_obj = Handle<Object>(result.GetCallbackObject(),
10431 isolate); 10431 isolate);
10432 } 10432 }
10433 Smi* property_details = result.GetPropertyDetails().AsSmi(); 10433 Smi* property_details = result.GetPropertyDetails().AsSmi();
10434 // DebugLookupResultValue can cause GC so details from LookupResult needs 10434 // DebugLookupResultValue can cause GC so details from LookupResult needs
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
10471 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetProperty) { 10471 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetProperty) {
10472 HandleScope scope(isolate); 10472 HandleScope scope(isolate);
10473 10473
10474 ASSERT(args.length() == 2); 10474 ASSERT(args.length() == 2);
10475 10475
10476 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); 10476 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
10477 CONVERT_ARG_HANDLE_CHECKED(String, name, 1); 10477 CONVERT_ARG_HANDLE_CHECKED(String, name, 1);
10478 10478
10479 LookupResult result(isolate); 10479 LookupResult result(isolate);
10480 obj->Lookup(*name, &result); 10480 obj->Lookup(*name, &result);
10481 if (result.IsProperty()) { 10481 if (result.IsFound()) {
10482 return DebugLookupResultValue(isolate->heap(), *obj, *name, &result, NULL); 10482 return DebugLookupResultValue(isolate->heap(), *obj, *name, &result, NULL);
10483 } 10483 }
10484 return isolate->heap()->undefined_value(); 10484 return isolate->heap()->undefined_value();
10485 } 10485 }
10486 10486
10487 10487
10488 // Return the property type calculated from the property details. 10488 // Return the property type calculated from the property details.
10489 // args[0]: smi with property details. 10489 // args[0]: smi with property details.
10490 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyTypeFromDetails) { 10490 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyTypeFromDetails) {
10491 ASSERT(args.length() == 1); 10491 ASSERT(args.length() == 1);
(...skipping 3220 matching lines...) Expand 10 before | Expand all | Expand 10 after
13712 // Handle last resort GC and make sure to allow future allocations 13712 // Handle last resort GC and make sure to allow future allocations
13713 // to grow the heap without causing GCs (if possible). 13713 // to grow the heap without causing GCs (if possible).
13714 isolate->counters()->gc_last_resort_from_js()->Increment(); 13714 isolate->counters()->gc_last_resort_from_js()->Increment();
13715 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13715 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13716 "Runtime::PerformGC"); 13716 "Runtime::PerformGC");
13717 } 13717 }
13718 } 13718 }
13719 13719
13720 13720
13721 } } // namespace v8::internal 13721 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/profile-generator.cc ('k') | src/stub-cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698