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

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

Issue 1181733002: Revert of Replace SetObjectProperty / DefineObjectProperty with less powerful alternatives where relevant. (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 | « src/api.cc ('k') | src/bootstrapper.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 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, key), Object);
82 82
83 uint32_t index = 0;
84 LookupIterator::Configuration c = LookupIterator::OWN_SKIP_INTERCEPTOR;
85 LookupIterator it = key->AsArrayIndex(&index)
86 ? LookupIterator(isolate, object, index, c)
87 : LookupIterator(object, key, c);
88
89 #ifdef DEBUG 83 #ifdef DEBUG
90 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); 84 bool duplicate;
91 DCHECK(maybe.IsJust()); 85 if (key->IsName()) {
92 if (it.IsFound()) { 86 LookupIterator it(object, Handle<Name>::cast(key),
87 LookupIterator::OWN_SKIP_INTERCEPTOR);
88 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
89 DCHECK(maybe.IsJust());
90 duplicate = it.IsFound();
91 } else {
92 uint32_t index = 0;
93 key->ToArrayIndex(&index);
94 Maybe<bool> maybe = JSReceiver::HasOwnElement(object, index);
95 if (!maybe.IsJust()) return MaybeHandle<Object>();
96 duplicate = maybe.FromJust();
97 }
98 if (duplicate) {
93 THROW_NEW_ERROR( 99 THROW_NEW_ERROR(
94 isolate, NewTypeError(MessageTemplate::kDuplicateTemplateProperty, key), 100 isolate, NewTypeError(MessageTemplate::kDuplicateTemplateProperty, key),
95 Object); 101 Object);
96 } 102 }
97 #endif 103 #endif
98 104
99 return Object::AddDataProperty(&it, value, attributes, STRICT, 105 RETURN_ON_EXCEPTION(
100 Object::CERTAINLY_NOT_STORE_FROM_KEYED); 106 isolate, Runtime::DefineObjectProperty(object, key, value, attributes),
107 Object);
108 return object;
101 } 109 }
102 110
103 111
104 void DisableAccessChecks(Isolate* isolate, Handle<JSObject> object) { 112 void DisableAccessChecks(Isolate* isolate, Handle<JSObject> object) {
105 Handle<Map> old_map(object->map()); 113 Handle<Map> old_map(object->map());
106 // Copy map so it won't interfere constructor's initial map. 114 // Copy map so it won't interfere constructor's initial map.
107 Handle<Map> new_map = Map::Copy(old_map, "DisableAccessChecks"); 115 Handle<Map> new_map = Map::Copy(old_map, "DisableAccessChecks");
108 new_map->set_is_access_check_needed(false); 116 new_map->set_is_access_check_needed(false);
109 JSObject::MigrateToMap(Handle<JSObject>::cast(object), new_map); 117 JSObject::MigrateToMap(Handle<JSObject>::cast(object), new_map);
110 } 118 }
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 Handle<AccessorInfo> accessor(AccessorInfo::cast(array->get(i))); 579 Handle<AccessorInfo> accessor(AccessorInfo::cast(array->get(i)));
572 JSObject::SetAccessor(result, accessor).Assert(); 580 JSObject::SetAccessor(result, accessor).Assert();
573 } 581 }
574 582
575 DCHECK(result->shared()->IsApiFunction()); 583 DCHECK(result->shared()->IsApiFunction());
576 return result; 584 return result;
577 } 585 }
578 586
579 } // namespace internal 587 } // namespace internal
580 } // namespace v8 588 } // namespace v8
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698