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

Side by Side Diff: src/runtime/runtime-object.cc

Issue 2445333002: Ensure slow properties for simple {__proto__:null} literals. (Closed)
Patch Set: addressing nits Created 3 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
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/debug/debug.h" 9 #include "src/debug/debug.h"
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 isolate, NewTypeError(MessageTemplate::kProtoObjectOrNull, prototype)); 237 isolate, NewTypeError(MessageTemplate::kProtoObjectOrNull, prototype));
238 } 238 }
239 239
240 // Generate the map with the specified {prototype} based on the Object 240 // Generate the map with the specified {prototype} based on the Object
241 // function's initial map from the current native context. 241 // function's initial map from the current native context.
242 // TODO(bmeurer): Use a dedicated cache for Object.create; think about 242 // TODO(bmeurer): Use a dedicated cache for Object.create; think about
243 // slack tracking for Object.create. 243 // slack tracking for Object.create.
244 Handle<Map> map = 244 Handle<Map> map =
245 Map::GetObjectCreateMap(Handle<HeapObject>::cast(prototype)); 245 Map::GetObjectCreateMap(Handle<HeapObject>::cast(prototype));
246 246
247 bool is_dictionary_map = map->is_dictionary_map();
248 Handle<FixedArray> object_properties;
249 if (is_dictionary_map) {
250 // Allocate the actual properties dictionay up front to avoid invalid object
251 // state.
252 object_properties =
253 NameDictionary::New(isolate, NameDictionary::kInitialCapacity);
254 }
255 // Actually allocate the object. 247 // Actually allocate the object.
256 Handle<JSObject> object = isolate->factory()->NewJSObjectFromMap(map); 248 Handle<JSObject> object;
257 if (is_dictionary_map) { 249 if (!map->is_dictionary_map()) {
Toon Verwaest 2017/03/14 13:27:48 swap branches and drop ! ;)
Camillo Bruni 2017/03/17 16:40:55 done.
258 object->set_properties(*object_properties); 250 object = isolate->factory()->NewJSObjectFromMap(map);
251 } else {
252 object = isolate->factory()->NewSlowJSObjectFromMap(map);
259 } 253 }
260 254
261 // Define the properties if properties was specified and is not undefined. 255 // Define the properties if properties was specified and is not undefined.
262 Handle<Object> properties = args.at(1); 256 Handle<Object> properties = args.at(1);
263 if (!properties->IsUndefined(isolate)) { 257 if (!properties->IsUndefined(isolate)) {
264 RETURN_FAILURE_ON_EXCEPTION( 258 RETURN_FAILURE_ON_EXCEPTION(
265 isolate, JSReceiver::DefineProperties(isolate, object, properties)); 259 isolate, JSReceiver::DefineProperties(isolate, object, properties));
266 } 260 }
267 261
268 return *object; 262 return *object;
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 if (!success) return isolate->heap()->exception(); 989 if (!success) return isolate->heap()->exception();
996 MAYBE_RETURN( 990 MAYBE_RETURN(
997 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), 991 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR),
998 isolate->heap()->exception()); 992 isolate->heap()->exception());
999 return *value; 993 return *value;
1000 } 994 }
1001 995
1002 996
1003 } // namespace internal 997 } // namespace internal
1004 } // namespace v8 998 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698