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

Side by Side Diff: src/api-natives.cc

Issue 1178893002: Introduce LookupIterator::PropertyOrElement which converts name to index if possible. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | src/json-stringifier.h » ('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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/api-natives.h" 5 #include "src/api-natives.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/isolate.h" 8 #include "src/isolate.h"
9 #include "src/lookup.h" 9 #include "src/lookup.h"
10 #include "src/messages.h" 10 #include "src/messages.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 JSObject::DefineAccessor( 60 JSObject::DefineAccessor(
61 object, name, getter, setter, 61 object, name, getter, setter,
62 static_cast<PropertyAttributes>(attributes->value())), 62 static_cast<PropertyAttributes>(attributes->value())),
63 Object); 63 Object);
64 return object; 64 return object;
65 } 65 }
66 66
67 67
68 MaybeHandle<Object> DefineDataProperty(Isolate* isolate, 68 MaybeHandle<Object> DefineDataProperty(Isolate* isolate,
69 Handle<JSObject> object, 69 Handle<JSObject> object,
70 Handle<Name> key, 70 Handle<Name> name,
71 Handle<Object> prop_data, 71 Handle<Object> prop_data,
72 Smi* unchecked_attributes) { 72 Smi* unchecked_attributes) {
73 DCHECK((unchecked_attributes->value() & 73 DCHECK((unchecked_attributes->value() &
74 ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); 74 ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
75 // Compute attributes. 75 // Compute attributes.
76 PropertyAttributes attributes = 76 PropertyAttributes attributes =
77 static_cast<PropertyAttributes>(unchecked_attributes->value()); 77 static_cast<PropertyAttributes>(unchecked_attributes->value());
78 78
79 Handle<Object> value; 79 Handle<Object> value;
80 ASSIGN_RETURN_ON_EXCEPTION(isolate, value, 80 ASSIGN_RETURN_ON_EXCEPTION(isolate, value,
81 Instantiate(isolate, prop_data, key), Object); 81 Instantiate(isolate, prop_data, name), Object);
82 82
83 uint32_t index = 0; 83 LookupIterator it = LookupIterator::PropertyOrElement(
84 LookupIterator::Configuration c = LookupIterator::OWN_SKIP_INTERCEPTOR; 84 isolate, object, name, LookupIterator::OWN_SKIP_INTERCEPTOR);
85 LookupIterator it = key->AsArrayIndex(&index)
86 ? LookupIterator(isolate, object, index, c)
87 : LookupIterator(object, key, c);
88 85
89 #ifdef DEBUG 86 #ifdef DEBUG
90 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); 87 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
91 DCHECK(maybe.IsJust()); 88 DCHECK(maybe.IsJust());
92 if (it.IsFound()) { 89 if (it.IsFound()) {
93 THROW_NEW_ERROR( 90 THROW_NEW_ERROR(
94 isolate, NewTypeError(MessageTemplate::kDuplicateTemplateProperty, key), 91 isolate,
92 NewTypeError(MessageTemplate::kDuplicateTemplateProperty, name),
95 Object); 93 Object);
96 } 94 }
97 #endif 95 #endif
98 96
99 return Object::AddDataProperty(&it, value, attributes, STRICT, 97 return Object::AddDataProperty(&it, value, attributes, STRICT,
100 Object::CERTAINLY_NOT_STORE_FROM_KEYED); 98 Object::CERTAINLY_NOT_STORE_FROM_KEYED);
101 } 99 }
102 100
103 101
104 void DisableAccessChecks(Isolate* isolate, Handle<JSObject> object) { 102 void DisableAccessChecks(Isolate* isolate, Handle<JSObject> object) {
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 Handle<AccessorInfo> accessor(AccessorInfo::cast(array->get(i))); 569 Handle<AccessorInfo> accessor(AccessorInfo::cast(array->get(i)));
572 JSObject::SetAccessor(result, accessor).Assert(); 570 JSObject::SetAccessor(result, accessor).Assert();
573 } 571 }
574 572
575 DCHECK(result->shared()->IsApiFunction()); 573 DCHECK(result->shared()->IsApiFunction());
576 return result; 574 return result;
577 } 575 }
578 576
579 } // namespace internal 577 } // namespace internal
580 } // namespace v8 578 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/json-stringifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698