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

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

Issue 2445333002: Ensure slow properties for simple {__proto__:null} literals. (Closed)
Patch Set: fixing compilation issue Created 3 years, 7 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 isolate, NewTypeError(MessageTemplate::kProtoObjectOrNull, prototype)); 244 isolate, NewTypeError(MessageTemplate::kProtoObjectOrNull, prototype));
245 } 245 }
246 246
247 // Generate the map with the specified {prototype} based on the Object 247 // Generate the map with the specified {prototype} based on the Object
248 // function's initial map from the current native context. 248 // function's initial map from the current native context.
249 // TODO(bmeurer): Use a dedicated cache for Object.create; think about 249 // TODO(bmeurer): Use a dedicated cache for Object.create; think about
250 // slack tracking for Object.create. 250 // slack tracking for Object.create.
251 Handle<Map> map = 251 Handle<Map> map =
252 Map::GetObjectCreateMap(Handle<HeapObject>::cast(prototype)); 252 Map::GetObjectCreateMap(Handle<HeapObject>::cast(prototype));
253 253
254 bool is_dictionary_map = map->is_dictionary_map();
255 Handle<FixedArray> object_properties;
256 if (is_dictionary_map) {
257 // Allocate the actual properties dictionay up front to avoid invalid object
258 // state.
259 object_properties =
260 NameDictionary::New(isolate, NameDictionary::kInitialCapacity);
261 }
262 // Actually allocate the object. 254 // Actually allocate the object.
263 Handle<JSObject> object = isolate->factory()->NewJSObjectFromMap(map); 255 Handle<JSObject> object;
264 if (is_dictionary_map) { 256 if (map->is_dictionary_map()) {
265 object->set_properties(*object_properties); 257 object = isolate->factory()->NewSlowJSObjectFromMap(map);
258 } else {
259 object = isolate->factory()->NewJSObjectFromMap(map);
266 } 260 }
267 261
268 // Define the properties if properties was specified and is not undefined. 262 // Define the properties if properties was specified and is not undefined.
269 Handle<Object> properties = args.at(1); 263 Handle<Object> properties = args.at(1);
270 if (!properties->IsUndefined(isolate)) { 264 if (!properties->IsUndefined(isolate)) {
271 RETURN_FAILURE_ON_EXCEPTION( 265 RETURN_FAILURE_ON_EXCEPTION(
272 isolate, JSReceiver::DefineProperties(isolate, object, properties)); 266 isolate, JSReceiver::DefineProperties(isolate, object, properties));
273 } 267 }
274 268
275 return *object; 269 return *object;
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 // While iteration alone may not have observable side-effects, calling 1037 // While iteration alone may not have observable side-effects, calling
1044 // toNumber on an object will. Make sure the arg is not an array of objects. 1038 // toNumber on an object will. Make sure the arg is not an array of objects.
1045 ElementsKind kind = JSObject::cast(*obj)->GetElementsKind(); 1039 ElementsKind kind = JSObject::cast(*obj)->GetElementsKind();
1046 if (!IsFastNumberElementsKind(kind)) return isolate->heap()->ToBoolean(false); 1040 if (!IsFastNumberElementsKind(kind)) return isolate->heap()->ToBoolean(false);
1047 1041
1048 return isolate->heap()->ToBoolean(!obj->IterationHasObservableEffects()); 1042 return isolate->heap()->ToBoolean(!obj->IterationHasObservableEffects());
1049 } 1043 }
1050 1044
1051 } // namespace internal 1045 } // namespace internal
1052 } // namespace v8 1046 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-literals.cc ('k') | test/cctest/interpreter/bytecode_expectations/ArrayLiterals.golden » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698