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

Side by Side Diff: src/runtime.cc

Issue 321543004: Rewrite GetPropertyAttribute to use the LookupIterator (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Remove bogus asserts Created 6 years, 6 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 // 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 <stdlib.h> 5 #include <stdlib.h>
6 #include <limits> 6 #include <limits>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 2004 matching lines...) Expand 10 before | Expand all | Expand 10 after
2015 // more than one access failure here. 2015 // more than one access failure here.
2016 AccessCheckResult access_check_result = 2016 AccessCheckResult access_check_result =
2017 CheckPropertyAccess(obj, name, v8::ACCESS_HAS); 2017 CheckPropertyAccess(obj, name, v8::ACCESS_HAS);
2018 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); 2018 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
2019 switch (access_check_result) { 2019 switch (access_check_result) {
2020 case ACCESS_FORBIDDEN: return factory->false_value(); 2020 case ACCESS_FORBIDDEN: return factory->false_value();
2021 case ACCESS_ALLOWED: break; 2021 case ACCESS_ALLOWED: break;
2022 case ACCESS_ABSENT: return factory->undefined_value(); 2022 case ACCESS_ABSENT: return factory->undefined_value();
2023 } 2023 }
2024 2024
2025 PropertyAttributes attrs = JSReceiver::GetOwnPropertyAttribute(obj, name); 2025 PropertyAttributes attrs = JSReceiver::GetOwnPropertyAttributes(obj, name);
2026 if (attrs == ABSENT) { 2026 if (attrs == ABSENT) {
2027 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); 2027 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
2028 return factory->undefined_value(); 2028 return factory->undefined_value();
2029 } 2029 }
2030 ASSERT(!isolate->has_scheduled_exception()); 2030 ASSERT(!isolate->has_scheduled_exception());
2031 Handle<AccessorPair> accessors; 2031 Handle<AccessorPair> accessors;
2032 bool has_accessors = 2032 bool has_accessors =
2033 JSObject::GetOwnPropertyAccessorPair(obj, name).ToHandle(&accessors); 2033 JSObject::GetOwnPropertyAccessorPair(obj, name).ToHandle(&accessors);
2034 Handle<FixedArray> elms = isolate->factory()->NewFixedArray(DESCRIPTOR_SIZE); 2034 Handle<FixedArray> elms = isolate->factory()->NewFixedArray(DESCRIPTOR_SIZE);
2035 elms->set(ENUMERABLE_INDEX, heap->ToBoolean((attrs & DONT_ENUM) == 0)); 2035 elms->set(ENUMERABLE_INDEX, heap->ToBoolean((attrs & DONT_ENUM) == 0));
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
2272 if (is_var || is_const) { 2272 if (is_var || is_const) {
2273 // Lookup the property in the global object, and don't set the 2273 // Lookup the property in the global object, and don't set the
2274 // value of the variable if the property is already there. 2274 // value of the variable if the property is already there.
2275 // Do the lookup own properties only, see ES5 erratum. 2275 // Do the lookup own properties only, see ES5 erratum.
2276 LookupResult lookup(isolate); 2276 LookupResult lookup(isolate);
2277 global->LookupOwn(name, &lookup, true); 2277 global->LookupOwn(name, &lookup, true);
2278 if (lookup.IsFound()) { 2278 if (lookup.IsFound()) {
2279 // We found an existing property. Unless it was an interceptor 2279 // We found an existing property. Unless it was an interceptor
2280 // that claims the property is absent, skip this declaration. 2280 // that claims the property is absent, skip this declaration.
2281 if (!lookup.IsInterceptor()) continue; 2281 if (!lookup.IsInterceptor()) continue;
2282 if (JSReceiver::GetPropertyAttribute(global, name) != ABSENT) continue; 2282 if (JSReceiver::GetPropertyAttributes(global, name) != ABSENT) continue;
2283 // Fall-through and introduce the absent property by using 2283 // Fall-through and introduce the absent property by using
2284 // SetProperty. 2284 // SetProperty.
2285 } 2285 }
2286 } else if (is_function) { 2286 } else if (is_function) {
2287 // Copy the function and update its context. Use it as value. 2287 // Copy the function and update its context. Use it as value.
2288 Handle<SharedFunctionInfo> shared = 2288 Handle<SharedFunctionInfo> shared =
2289 Handle<SharedFunctionInfo>::cast(value); 2289 Handle<SharedFunctionInfo>::cast(value);
2290 Handle<JSFunction> function = 2290 Handle<JSFunction> function =
2291 isolate->factory()->NewFunctionFromSharedFunctionInfo( 2291 isolate->factory()->NewFunctionFromSharedFunctionInfo(
2292 shared, context, TENURED); 2292 shared, context, TENURED);
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
2463 // We follow Safari and Firefox behavior and only set the property 2463 // We follow Safari and Firefox behavior and only set the property
2464 // if there is an explicit initialization value that we have 2464 // if there is an explicit initialization value that we have
2465 // to assign to the property. 2465 // to assign to the property.
2466 // Note that objects can have hidden prototypes, so we need to traverse 2466 // Note that objects can have hidden prototypes, so we need to traverse
2467 // the whole chain of hidden prototypes to do an 'own' lookup. 2467 // the whole chain of hidden prototypes to do an 'own' lookup.
2468 LookupResult lookup(isolate); 2468 LookupResult lookup(isolate);
2469 isolate->context()->global_object()->LookupOwn(name, &lookup, true); 2469 isolate->context()->global_object()->LookupOwn(name, &lookup, true);
2470 if (lookup.IsInterceptor()) { 2470 if (lookup.IsInterceptor()) {
2471 Handle<JSObject> holder(lookup.holder()); 2471 Handle<JSObject> holder(lookup.holder());
2472 PropertyAttributes intercepted = 2472 PropertyAttributes intercepted =
2473 JSReceiver::GetPropertyAttribute(holder, name); 2473 JSReceiver::GetPropertyAttributes(holder, name);
2474 if (intercepted != ABSENT && (intercepted & READ_ONLY) == 0) { 2474 if (intercepted != ABSENT && (intercepted & READ_ONLY) == 0) {
2475 // Found an interceptor that's not read only. 2475 // Found an interceptor that's not read only.
2476 if (assign) { 2476 if (assign) {
2477 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); 2477 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
2478 Handle<Object> result; 2478 Handle<Object> result;
2479 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 2479 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
2480 isolate, result, 2480 isolate, result,
2481 JSObject::SetPropertyForResult( 2481 JSObject::SetPropertyForResult(
2482 holder, &lookup, name, value, attributes, strict_mode)); 2482 holder, &lookup, name, value, attributes, strict_mode));
2483 return *result; 2483 return *result;
(...skipping 3275 matching lines...) Expand 10 before | Expand all | Expand 10 after
5759 } 5759 }
5760 5760
5761 5761
5762 RUNTIME_FUNCTION(Runtime_IsPropertyEnumerable) { 5762 RUNTIME_FUNCTION(Runtime_IsPropertyEnumerable) {
5763 HandleScope scope(isolate); 5763 HandleScope scope(isolate);
5764 ASSERT(args.length() == 2); 5764 ASSERT(args.length() == 2);
5765 5765
5766 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); 5766 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
5767 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); 5767 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1);
5768 5768
5769 PropertyAttributes att = JSReceiver::GetOwnPropertyAttribute(object, key); 5769 PropertyAttributes att = JSReceiver::GetOwnPropertyAttributes(object, key);
5770 if (att == ABSENT || (att & DONT_ENUM) != 0) { 5770 if (att == ABSENT || (att & DONT_ENUM) != 0) {
5771 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); 5771 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
5772 return isolate->heap()->false_value(); 5772 return isolate->heap()->false_value();
5773 } 5773 }
5774 ASSERT(!isolate->has_scheduled_exception()); 5774 ASSERT(!isolate->has_scheduled_exception());
5775 return isolate->heap()->true_value(); 5775 return isolate->heap()->true_value();
5776 } 5776 }
5777 5777
5778 5778
5779 RUNTIME_FUNCTION(Runtime_GetPropertyNames) { 5779 RUNTIME_FUNCTION(Runtime_GetPropertyNames) {
(...skipping 3666 matching lines...) Expand 10 before | Expand all | Expand 10 after
9446 "not_defined", HandleVector(&name, 1)); 9446 "not_defined", HandleVector(&name, 1));
9447 return isolate->Throw(*error); 9447 return isolate->Throw(*error);
9448 } 9448 }
9449 // In sloppy mode, the property is added to the global object. 9449 // In sloppy mode, the property is added to the global object.
9450 attributes = NONE; 9450 attributes = NONE;
9451 object = Handle<JSReceiver>(isolate->context()->global_object()); 9451 object = Handle<JSReceiver>(isolate->context()->global_object());
9452 } 9452 }
9453 9453
9454 // Set the property if it's not read only or doesn't yet exist. 9454 // Set the property if it's not read only or doesn't yet exist.
9455 if ((attributes & READ_ONLY) == 0 || 9455 if ((attributes & READ_ONLY) == 0 ||
9456 (JSReceiver::GetOwnPropertyAttribute(object, name) == ABSENT)) { 9456 (JSReceiver::GetOwnPropertyAttributes(object, name) == ABSENT)) {
9457 RETURN_FAILURE_ON_EXCEPTION( 9457 RETURN_FAILURE_ON_EXCEPTION(
9458 isolate, 9458 isolate,
9459 JSReceiver::SetProperty(object, name, value, NONE, strict_mode)); 9459 JSReceiver::SetProperty(object, name, value, NONE, strict_mode));
9460 } else if (strict_mode == STRICT && (attributes & READ_ONLY) != 0) { 9460 } else if (strict_mode == STRICT && (attributes & READ_ONLY) != 0) {
9461 // Setting read only property in strict mode. 9461 // Setting read only property in strict mode.
9462 Handle<Object> error = 9462 Handle<Object> error =
9463 isolate->factory()->NewTypeError( 9463 isolate->factory()->NewTypeError(
9464 "strict_cannot_assign", HandleVector(&name, 1)); 9464 "strict_cannot_assign", HandleVector(&name, 1));
9465 return isolate->Throw(*error); 9465 return isolate->Throw(*error);
9466 } 9466 }
(...skipping 5676 matching lines...) Expand 10 before | Expand all | Expand 10 after
15143 } 15143 }
15144 return NULL; 15144 return NULL;
15145 } 15145 }
15146 15146
15147 15147
15148 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { 15148 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) {
15149 return &(kIntrinsicFunctions[static_cast<int>(id)]); 15149 return &(kIntrinsicFunctions[static_cast<int>(id)]);
15150 } 15150 }
15151 15151
15152 } } // namespace v8::internal 15152 } } // 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