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

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: 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 1791 matching lines...) Expand 10 before | Expand all | Expand 10 after
1802 // more than one access failure here. 1802 // more than one access failure here.
1803 AccessCheckResult access_check_result = 1803 AccessCheckResult access_check_result =
1804 CheckPropertyAccess(obj, name, v8::ACCESS_HAS); 1804 CheckPropertyAccess(obj, name, v8::ACCESS_HAS);
1805 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); 1805 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object);
1806 switch (access_check_result) { 1806 switch (access_check_result) {
1807 case ACCESS_FORBIDDEN: return factory->false_value(); 1807 case ACCESS_FORBIDDEN: return factory->false_value();
1808 case ACCESS_ALLOWED: break; 1808 case ACCESS_ALLOWED: break;
1809 case ACCESS_ABSENT: return factory->undefined_value(); 1809 case ACCESS_ABSENT: return factory->undefined_value();
1810 } 1810 }
1811 1811
1812 PropertyAttributes attrs = obj->GetLocalPropertyAttribute(*name); 1812 PropertyAttributes attrs = JSReceiver::GetLocalPropertyAttribute(obj, name);
1813 if (attrs == ABSENT) { 1813 if (attrs == ABSENT) {
1814 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); 1814 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object);
1815 return factory->undefined_value(); 1815 return factory->undefined_value();
1816 } 1816 }
1817 ASSERT(!isolate->has_scheduled_exception()); 1817 ASSERT(!isolate->has_scheduled_exception());
1818 AccessorPair* raw_accessors = obj->GetLocalPropertyAccessorPair(*name); 1818 AccessorPair* raw_accessors = obj->GetLocalPropertyAccessorPair(*name);
1819 Handle<AccessorPair> accessors(raw_accessors, isolate); 1819 Handle<AccessorPair> accessors(raw_accessors, isolate);
1820 Handle<FixedArray> elms = isolate->factory()->NewFixedArray(DESCRIPTOR_SIZE); 1820 Handle<FixedArray> elms = isolate->factory()->NewFixedArray(DESCRIPTOR_SIZE);
1821 elms->set(ENUMERABLE_INDEX, heap->ToBoolean((attrs & DONT_ENUM) == 0)); 1821 elms->set(ENUMERABLE_INDEX, heap->ToBoolean((attrs & DONT_ENUM) == 0));
1822 elms->set(CONFIGURABLE_INDEX, heap->ToBoolean((attrs & DONT_DELETE) == 0)); 1822 elms->set(CONFIGURABLE_INDEX, heap->ToBoolean((attrs & DONT_DELETE) == 0));
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
2050 if (is_var || is_const) { 2050 if (is_var || is_const) {
2051 // Lookup the property in the global object, and don't set the 2051 // Lookup the property in the global object, and don't set the
2052 // value of the variable if the property is already there. 2052 // value of the variable if the property is already there.
2053 // Do the lookup locally only, see ES5 erratum. 2053 // Do the lookup locally only, see ES5 erratum.
2054 LookupResult lookup(isolate); 2054 LookupResult lookup(isolate);
2055 global->LocalLookup(*name, &lookup, true); 2055 global->LocalLookup(*name, &lookup, true);
2056 if (lookup.IsFound()) { 2056 if (lookup.IsFound()) {
2057 // We found an existing property. Unless it was an interceptor 2057 // We found an existing property. Unless it was an interceptor
2058 // that claims the property is absent, skip this declaration. 2058 // that claims the property is absent, skip this declaration.
2059 if (!lookup.IsInterceptor()) continue; 2059 if (!lookup.IsInterceptor()) continue;
2060 PropertyAttributes attributes = global->GetPropertyAttribute(*name); 2060 if (JSReceiver::GetPropertyAttribute(global, name) != ABSENT) continue;
2061 if (attributes != ABSENT) continue;
2062 // Fall-through and introduce the absent property by using 2061 // Fall-through and introduce the absent property by using
2063 // SetProperty. 2062 // SetProperty.
2064 } 2063 }
2065 } else if (is_function) { 2064 } else if (is_function) {
2066 // Copy the function and update its context. Use it as value. 2065 // Copy the function and update its context. Use it as value.
2067 Handle<SharedFunctionInfo> shared = 2066 Handle<SharedFunctionInfo> shared =
2068 Handle<SharedFunctionInfo>::cast(value); 2067 Handle<SharedFunctionInfo>::cast(value);
2069 Handle<JSFunction> function = 2068 Handle<JSFunction> function =
2070 isolate->factory()->NewFunctionFromSharedFunctionInfo( 2069 isolate->factory()->NewFunctionFromSharedFunctionInfo(
2071 shared, context, TENURED); 2070 shared, context, TENURED);
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
2242 // there, there is a property with this name in the prototype chain. 2241 // there, there is a property with this name in the prototype chain.
2243 // We follow Safari and Firefox behavior and only set the property 2242 // We follow Safari and Firefox behavior and only set the property
2244 // locally if there is an explicit initialization value that we have 2243 // locally if there is an explicit initialization value that we have
2245 // to assign to the property. 2244 // to assign to the property.
2246 // Note that objects can have hidden prototypes, so we need to traverse 2245 // Note that objects can have hidden prototypes, so we need to traverse
2247 // the whole chain of hidden prototypes to do a 'local' lookup. 2246 // the whole chain of hidden prototypes to do a 'local' lookup.
2248 LookupResult lookup(isolate); 2247 LookupResult lookup(isolate);
2249 isolate->context()->global_object()->LocalLookup(*name, &lookup, true); 2248 isolate->context()->global_object()->LocalLookup(*name, &lookup, true);
2250 if (lookup.IsInterceptor()) { 2249 if (lookup.IsInterceptor()) {
2251 PropertyAttributes intercepted = 2250 PropertyAttributes intercepted =
2252 lookup.holder()->GetPropertyAttribute(*name); 2251 JSReceiver::GetPropertyAttribute(handle(lookup.holder()), name);
Igor Sheludko 2014/03/13 09:17:42 LookupResult seems to be GC-safe but we still allo
2253 if (intercepted != ABSENT && (intercepted & READ_ONLY) == 0) { 2252 if (intercepted != ABSENT && (intercepted & READ_ONLY) == 0) {
2254 // Found an interceptor that's not read only. 2253 // Found an interceptor that's not read only.
2255 if (assign) { 2254 if (assign) {
2256 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); 2255 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
2257 Handle<Object> result = JSObject::SetPropertyForResult( 2256 Handle<Object> result = JSObject::SetPropertyForResult(
2258 handle(lookup.holder()), &lookup, name, value, attributes, 2257 handle(lookup.holder()), &lookup, name, value, attributes,
2259 strict_mode); 2258 strict_mode);
2260 RETURN_IF_EMPTY_HANDLE(isolate, result); 2259 RETURN_IF_EMPTY_HANDLE(isolate, result);
2261 return *result; 2260 return *result;
2262 } else { 2261 } else {
(...skipping 3370 matching lines...) Expand 10 before | Expand all | Expand 10 after
5633 CONVERT_SMI_ARG_CHECKED(index, 1); 5632 CONVERT_SMI_ARG_CHECKED(index, 1);
5634 5633
5635 bool result = JSReceiver::HasElement(receiver, index); 5634 bool result = JSReceiver::HasElement(receiver, index);
5636 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 5635 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
5637 if (isolate->has_pending_exception()) return Failure::Exception(); 5636 if (isolate->has_pending_exception()) return Failure::Exception();
5638 return isolate->heap()->ToBoolean(result); 5637 return isolate->heap()->ToBoolean(result);
5639 } 5638 }
5640 5639
5641 5640
5642 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsPropertyEnumerable) { 5641 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsPropertyEnumerable) {
5643 SealHandleScope shs(isolate); 5642 HandleScope scope(isolate);
5644 ASSERT(args.length() == 2); 5643 ASSERT(args.length() == 2);
5645 5644
5646 CONVERT_ARG_CHECKED(JSObject, object, 0); 5645 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
5647 CONVERT_ARG_CHECKED(Name, key, 1); 5646 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1);
5648 5647
5649 PropertyAttributes att = object->GetLocalPropertyAttribute(key); 5648 PropertyAttributes att = JSReceiver::GetLocalPropertyAttribute(object, key);
5650 if (att == ABSENT || (att & DONT_ENUM) != 0) { 5649 if (att == ABSENT || (att & DONT_ENUM) != 0) {
5651 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 5650 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
5652 return isolate->heap()->false_value(); 5651 return isolate->heap()->false_value();
5653 } 5652 }
5654 ASSERT(!isolate->has_scheduled_exception()); 5653 ASSERT(!isolate->has_scheduled_exception());
5655 return isolate->heap()->true_value(); 5654 return isolate->heap()->true_value();
5656 } 5655 }
5657 5656
5658 5657
5659 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNames) { 5658 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNames) {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
5789 hidden_strings++; 5788 hidden_strings++;
5790 break; 5789 break;
5791 } 5790 }
5792 } 5791 }
5793 } 5792 }
5794 } 5793 }
5795 } 5794 }
5796 next_copy_index += local_property_count[i]; 5795 next_copy_index += local_property_count[i];
5797 5796
5798 // Hidden properties only show up if the filter does not skip strings. 5797 // Hidden properties only show up if the filter does not skip strings.
5799 if ((filter & STRING) == 0 && jsproto->HasHiddenProperties()) { 5798 if ((filter & STRING) == 0 && JSObject::HasHiddenProperties(jsproto)) {
5800 hidden_strings++; 5799 hidden_strings++;
5801 } 5800 }
5802 if (i < length - 1) { 5801 if (i < length - 1) {
5803 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); 5802 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype()));
5804 } 5803 }
5805 } 5804 }
5806 5805
5807 // Filter out name of hidden properties object and 5806 // Filter out name of hidden properties object and
5808 // hidden prototype duplicates. 5807 // hidden prototype duplicates.
5809 if (hidden_strings > 0) { 5808 if (hidden_strings > 0) {
(...skipping 3518 matching lines...) Expand 10 before | Expand all | Expand 10 after
9328 "not_defined", HandleVector(&name, 1)); 9327 "not_defined", HandleVector(&name, 1));
9329 return isolate->Throw(*error); 9328 return isolate->Throw(*error);
9330 } 9329 }
9331 // In sloppy mode, the property is added to the global object. 9330 // In sloppy mode, the property is added to the global object.
9332 attributes = NONE; 9331 attributes = NONE;
9333 object = Handle<JSReceiver>(isolate->context()->global_object()); 9332 object = Handle<JSReceiver>(isolate->context()->global_object());
9334 } 9333 }
9335 9334
9336 // Set the property if it's not read only or doesn't yet exist. 9335 // Set the property if it's not read only or doesn't yet exist.
9337 if ((attributes & READ_ONLY) == 0 || 9336 if ((attributes & READ_ONLY) == 0 ||
9338 (object->GetLocalPropertyAttribute(*name) == ABSENT)) { 9337 (JSReceiver::GetLocalPropertyAttribute(object, name) == ABSENT)) {
9339 RETURN_IF_EMPTY_HANDLE( 9338 RETURN_IF_EMPTY_HANDLE(
9340 isolate, 9339 isolate,
9341 JSReceiver::SetProperty(object, name, value, NONE, strict_mode)); 9340 JSReceiver::SetProperty(object, name, value, NONE, strict_mode));
9342 } else if (strict_mode == STRICT && (attributes & READ_ONLY) != 0) { 9341 } else if (strict_mode == STRICT && (attributes & READ_ONLY) != 0) {
9343 // Setting read only property in strict mode. 9342 // Setting read only property in strict mode.
9344 Handle<Object> error = 9343 Handle<Object> error =
9345 isolate->factory()->NewTypeError( 9344 isolate->factory()->NewTypeError(
9346 "strict_cannot_assign", HandleVector(&name, 1)); 9345 "strict_cannot_assign", HandleVector(&name, 1));
9347 return isolate->Throw(*error); 9346 return isolate->Throw(*error);
9348 } 9347 }
(...skipping 5622 matching lines...) Expand 10 before | Expand all | Expand 10 after
14971 // Handle last resort GC and make sure to allow future allocations 14970 // Handle last resort GC and make sure to allow future allocations
14972 // to grow the heap without causing GCs (if possible). 14971 // to grow the heap without causing GCs (if possible).
14973 isolate->counters()->gc_last_resort_from_js()->Increment(); 14972 isolate->counters()->gc_last_resort_from_js()->Increment();
14974 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14973 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14975 "Runtime::PerformGC"); 14974 "Runtime::PerformGC");
14976 } 14975 }
14977 } 14976 }
14978 14977
14979 14978
14980 } } // namespace v8::internal 14979 } } // 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