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

Side by Side Diff: src/runtime.cc

Issue 197813004: Handlify PropertyAttribute lookups. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comment Created 6 years, 9 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/objects-inl.h ('k') | no next file » | 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 1795 matching lines...) Expand 10 before | Expand all | Expand 10 after
1806 // more than one access failure here. 1806 // more than one access failure here.
1807 AccessCheckResult access_check_result = 1807 AccessCheckResult access_check_result =
1808 CheckPropertyAccess(obj, name, v8::ACCESS_HAS); 1808 CheckPropertyAccess(obj, name, v8::ACCESS_HAS);
1809 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); 1809 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object);
1810 switch (access_check_result) { 1810 switch (access_check_result) {
1811 case ACCESS_FORBIDDEN: return factory->false_value(); 1811 case ACCESS_FORBIDDEN: return factory->false_value();
1812 case ACCESS_ALLOWED: break; 1812 case ACCESS_ALLOWED: break;
1813 case ACCESS_ABSENT: return factory->undefined_value(); 1813 case ACCESS_ABSENT: return factory->undefined_value();
1814 } 1814 }
1815 1815
1816 PropertyAttributes attrs = obj->GetLocalPropertyAttribute(*name); 1816 PropertyAttributes attrs = JSReceiver::GetLocalPropertyAttribute(obj, name);
1817 if (attrs == ABSENT) { 1817 if (attrs == ABSENT) {
1818 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); 1818 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object);
1819 return factory->undefined_value(); 1819 return factory->undefined_value();
1820 } 1820 }
1821 ASSERT(!isolate->has_scheduled_exception()); 1821 ASSERT(!isolate->has_scheduled_exception());
1822 AccessorPair* raw_accessors = obj->GetLocalPropertyAccessorPair(*name); 1822 AccessorPair* raw_accessors = obj->GetLocalPropertyAccessorPair(*name);
1823 Handle<AccessorPair> accessors(raw_accessors, isolate); 1823 Handle<AccessorPair> accessors(raw_accessors, isolate);
1824 Handle<FixedArray> elms = isolate->factory()->NewFixedArray(DESCRIPTOR_SIZE); 1824 Handle<FixedArray> elms = isolate->factory()->NewFixedArray(DESCRIPTOR_SIZE);
1825 elms->set(ENUMERABLE_INDEX, heap->ToBoolean((attrs & DONT_ENUM) == 0)); 1825 elms->set(ENUMERABLE_INDEX, heap->ToBoolean((attrs & DONT_ENUM) == 0));
1826 elms->set(CONFIGURABLE_INDEX, heap->ToBoolean((attrs & DONT_DELETE) == 0)); 1826 elms->set(CONFIGURABLE_INDEX, heap->ToBoolean((attrs & DONT_DELETE) == 0));
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
2054 if (is_var || is_const) { 2054 if (is_var || is_const) {
2055 // Lookup the property in the global object, and don't set the 2055 // Lookup the property in the global object, and don't set the
2056 // value of the variable if the property is already there. 2056 // value of the variable if the property is already there.
2057 // Do the lookup locally only, see ES5 erratum. 2057 // Do the lookup locally only, see ES5 erratum.
2058 LookupResult lookup(isolate); 2058 LookupResult lookup(isolate);
2059 global->LocalLookup(*name, &lookup, true); 2059 global->LocalLookup(*name, &lookup, true);
2060 if (lookup.IsFound()) { 2060 if (lookup.IsFound()) {
2061 // We found an existing property. Unless it was an interceptor 2061 // We found an existing property. Unless it was an interceptor
2062 // that claims the property is absent, skip this declaration. 2062 // that claims the property is absent, skip this declaration.
2063 if (!lookup.IsInterceptor()) continue; 2063 if (!lookup.IsInterceptor()) continue;
2064 PropertyAttributes attributes = global->GetPropertyAttribute(*name); 2064 if (JSReceiver::GetPropertyAttribute(global, name) != ABSENT) continue;
2065 if (attributes != ABSENT) continue;
2066 // Fall-through and introduce the absent property by using 2065 // Fall-through and introduce the absent property by using
2067 // SetProperty. 2066 // SetProperty.
2068 } 2067 }
2069 } else if (is_function) { 2068 } else if (is_function) {
2070 // Copy the function and update its context. Use it as value. 2069 // Copy the function and update its context. Use it as value.
2071 Handle<SharedFunctionInfo> shared = 2070 Handle<SharedFunctionInfo> shared =
2072 Handle<SharedFunctionInfo>::cast(value); 2071 Handle<SharedFunctionInfo>::cast(value);
2073 Handle<JSFunction> function = 2072 Handle<JSFunction> function =
2074 isolate->factory()->NewFunctionFromSharedFunctionInfo( 2073 isolate->factory()->NewFunctionFromSharedFunctionInfo(
2075 shared, context, TENURED); 2074 shared, context, TENURED);
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
2245 // Lookup the property locally in the global object. If it isn't 2244 // Lookup the property locally in the global object. If it isn't
2246 // there, there is a property with this name in the prototype chain. 2245 // there, there is a property with this name in the prototype chain.
2247 // We follow Safari and Firefox behavior and only set the property 2246 // We follow Safari and Firefox behavior and only set the property
2248 // locally if there is an explicit initialization value that we have 2247 // locally if there is an explicit initialization value that we have
2249 // to assign to the property. 2248 // to assign to the property.
2250 // Note that objects can have hidden prototypes, so we need to traverse 2249 // Note that objects can have hidden prototypes, so we need to traverse
2251 // the whole chain of hidden prototypes to do a 'local' lookup. 2250 // the whole chain of hidden prototypes to do a 'local' lookup.
2252 LookupResult lookup(isolate); 2251 LookupResult lookup(isolate);
2253 isolate->context()->global_object()->LocalLookup(*name, &lookup, true); 2252 isolate->context()->global_object()->LocalLookup(*name, &lookup, true);
2254 if (lookup.IsInterceptor()) { 2253 if (lookup.IsInterceptor()) {
2254 Handle<JSObject> holder(lookup.holder());
2255 PropertyAttributes intercepted = 2255 PropertyAttributes intercepted =
2256 lookup.holder()->GetPropertyAttribute(*name); 2256 JSReceiver::GetPropertyAttribute(holder, name);
2257 if (intercepted != ABSENT && (intercepted & READ_ONLY) == 0) { 2257 if (intercepted != ABSENT && (intercepted & READ_ONLY) == 0) {
2258 // Found an interceptor that's not read only. 2258 // Found an interceptor that's not read only.
2259 if (assign) { 2259 if (assign) {
2260 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); 2260 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
2261 Handle<Object> result = JSObject::SetPropertyForResult( 2261 Handle<Object> result = JSObject::SetPropertyForResult(
2262 handle(lookup.holder()), &lookup, name, value, attributes, 2262 holder, &lookup, name, value, attributes, strict_mode);
2263 strict_mode);
2264 RETURN_IF_EMPTY_HANDLE(isolate, result); 2263 RETURN_IF_EMPTY_HANDLE(isolate, result);
2265 return *result; 2264 return *result;
2266 } else { 2265 } else {
2267 return isolate->heap()->undefined_value(); 2266 return isolate->heap()->undefined_value();
2268 } 2267 }
2269 } 2268 }
2270 } 2269 }
2271 2270
2272 if (assign) { 2271 if (assign) {
2273 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); 2272 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
(...skipping 3363 matching lines...) Expand 10 before | Expand all | Expand 10 after
5637 CONVERT_SMI_ARG_CHECKED(index, 1); 5636 CONVERT_SMI_ARG_CHECKED(index, 1);
5638 5637
5639 bool result = JSReceiver::HasElement(receiver, index); 5638 bool result = JSReceiver::HasElement(receiver, index);
5640 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 5639 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
5641 if (isolate->has_pending_exception()) return Failure::Exception(); 5640 if (isolate->has_pending_exception()) return Failure::Exception();
5642 return isolate->heap()->ToBoolean(result); 5641 return isolate->heap()->ToBoolean(result);
5643 } 5642 }
5644 5643
5645 5644
5646 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsPropertyEnumerable) { 5645 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsPropertyEnumerable) {
5647 SealHandleScope shs(isolate); 5646 HandleScope scope(isolate);
5648 ASSERT(args.length() == 2); 5647 ASSERT(args.length() == 2);
5649 5648
5650 CONVERT_ARG_CHECKED(JSObject, object, 0); 5649 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
5651 CONVERT_ARG_CHECKED(Name, key, 1); 5650 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1);
5652 5651
5653 PropertyAttributes att = object->GetLocalPropertyAttribute(key); 5652 PropertyAttributes att = JSReceiver::GetLocalPropertyAttribute(object, key);
5654 if (att == ABSENT || (att & DONT_ENUM) != 0) { 5653 if (att == ABSENT || (att & DONT_ENUM) != 0) {
5655 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 5654 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
5656 return isolate->heap()->false_value(); 5655 return isolate->heap()->false_value();
5657 } 5656 }
5658 ASSERT(!isolate->has_scheduled_exception()); 5657 ASSERT(!isolate->has_scheduled_exception());
5659 return isolate->heap()->true_value(); 5658 return isolate->heap()->true_value();
5660 } 5659 }
5661 5660
5662 5661
5663 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNames) { 5662 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNames) {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
5793 hidden_strings++; 5792 hidden_strings++;
5794 break; 5793 break;
5795 } 5794 }
5796 } 5795 }
5797 } 5796 }
5798 } 5797 }
5799 } 5798 }
5800 next_copy_index += local_property_count[i]; 5799 next_copy_index += local_property_count[i];
5801 5800
5802 // Hidden properties only show up if the filter does not skip strings. 5801 // Hidden properties only show up if the filter does not skip strings.
5803 if ((filter & STRING) == 0 && jsproto->HasHiddenProperties()) { 5802 if ((filter & STRING) == 0 && JSObject::HasHiddenProperties(jsproto)) {
5804 hidden_strings++; 5803 hidden_strings++;
5805 } 5804 }
5806 if (i < length - 1) { 5805 if (i < length - 1) {
5807 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); 5806 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype()));
5808 } 5807 }
5809 } 5808 }
5810 5809
5811 // Filter out name of hidden properties object and 5810 // Filter out name of hidden properties object and
5812 // hidden prototype duplicates. 5811 // hidden prototype duplicates.
5813 if (hidden_strings > 0) { 5812 if (hidden_strings > 0) {
(...skipping 3518 matching lines...) Expand 10 before | Expand all | Expand 10 after
9332 "not_defined", HandleVector(&name, 1)); 9331 "not_defined", HandleVector(&name, 1));
9333 return isolate->Throw(*error); 9332 return isolate->Throw(*error);
9334 } 9333 }
9335 // In sloppy mode, the property is added to the global object. 9334 // In sloppy mode, the property is added to the global object.
9336 attributes = NONE; 9335 attributes = NONE;
9337 object = Handle<JSReceiver>(isolate->context()->global_object()); 9336 object = Handle<JSReceiver>(isolate->context()->global_object());
9338 } 9337 }
9339 9338
9340 // Set the property if it's not read only or doesn't yet exist. 9339 // Set the property if it's not read only or doesn't yet exist.
9341 if ((attributes & READ_ONLY) == 0 || 9340 if ((attributes & READ_ONLY) == 0 ||
9342 (object->GetLocalPropertyAttribute(*name) == ABSENT)) { 9341 (JSReceiver::GetLocalPropertyAttribute(object, name) == ABSENT)) {
9343 RETURN_IF_EMPTY_HANDLE( 9342 RETURN_IF_EMPTY_HANDLE(
9344 isolate, 9343 isolate,
9345 JSReceiver::SetProperty(object, name, value, NONE, strict_mode)); 9344 JSReceiver::SetProperty(object, name, value, NONE, strict_mode));
9346 } else if (strict_mode == STRICT && (attributes & READ_ONLY) != 0) { 9345 } else if (strict_mode == STRICT && (attributes & READ_ONLY) != 0) {
9347 // Setting read only property in strict mode. 9346 // Setting read only property in strict mode.
9348 Handle<Object> error = 9347 Handle<Object> error =
9349 isolate->factory()->NewTypeError( 9348 isolate->factory()->NewTypeError(
9350 "strict_cannot_assign", HandleVector(&name, 1)); 9349 "strict_cannot_assign", HandleVector(&name, 1));
9351 return isolate->Throw(*error); 9350 return isolate->Throw(*error);
9352 } 9351 }
(...skipping 5622 matching lines...) Expand 10 before | Expand all | Expand 10 after
14975 // Handle last resort GC and make sure to allow future allocations 14974 // Handle last resort GC and make sure to allow future allocations
14976 // to grow the heap without causing GCs (if possible). 14975 // to grow the heap without causing GCs (if possible).
14977 isolate->counters()->gc_last_resort_from_js()->Increment(); 14976 isolate->counters()->gc_last_resort_from_js()->Increment();
14978 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14977 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14979 "Runtime::PerformGC"); 14978 "Runtime::PerformGC");
14980 } 14979 }
14981 } 14980 }
14982 14981
14983 14982
14984 } } // namespace v8::internal 14983 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698