Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 } else { | 240 } else { |
| 241 map = Map::CopyInitialMap(map); | 241 map = Map::CopyInitialMap(map); |
| 242 Map::SetPrototype(map, prototype, FAST_PROTOTYPE); | 242 Map::SetPrototype(map, prototype, FAST_PROTOTYPE); |
| 243 PrototypeInfo::SetObjectCreateMap(info, map); | 243 PrototypeInfo::SetObjectCreateMap(info, map); |
| 244 } | 244 } |
| 245 } else { | 245 } else { |
| 246 map = Map::TransitionToPrototype(map, prototype, REGULAR_PROTOTYPE); | 246 map = Map::TransitionToPrototype(map, prototype, REGULAR_PROTOTYPE); |
| 247 } | 247 } |
| 248 } | 248 } |
| 249 | 249 |
| 250 bool is_dictionary_map = map->is_dictionary_map(); | |
| 251 Handle<FixedArray> object_properties; | |
| 252 if (is_dictionary_map) { | |
| 253 // Allocate the actual dictionay properties uppfront to avoid invalid object | |
|
Jakob Kummerow
2016/10/25 19:41:37
nit: s/actual dictionay properties/properties dict
| |
| 254 // state. | |
| 255 object_properties = | |
| 256 NameDictionary::New(isolate, NameDictionary::kInitialCapacity); | |
| 257 } | |
| 250 // Actually allocate the object. | 258 // Actually allocate the object. |
| 251 Handle<JSObject> object = isolate->factory()->NewJSObjectFromMap(map); | 259 Handle<JSObject> object = isolate->factory()->NewJSObjectFromMap(map); |
| 252 | 260 if (is_dictionary_map) { |
| 253 if (map->is_dictionary_map()) { | 261 object->set_properties(*object_properties); |
| 254 Handle<NameDictionary> properties = | |
| 255 NameDictionary::New(isolate, NameDictionary::kInitialCapacity); | |
| 256 object->set_properties(*properties); | |
| 257 } | 262 } |
| 258 | 263 |
| 259 // Define the properties if properties was specified and is not undefined. | 264 // Define the properties if properties was specified and is not undefined. |
| 260 Handle<Object> properties = args.at<Object>(1); | 265 Handle<Object> properties = args.at<Object>(1); |
| 261 if (!properties->IsUndefined(isolate)) { | 266 if (!properties->IsUndefined(isolate)) { |
| 262 RETURN_FAILURE_ON_EXCEPTION( | 267 RETURN_FAILURE_ON_EXCEPTION( |
| 263 isolate, JSReceiver::DefineProperties(isolate, object, properties)); | 268 isolate, JSReceiver::DefineProperties(isolate, object, properties)); |
| 264 } | 269 } |
| 265 | 270 |
| 266 return *object; | 271 return *object; |
| (...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 941 if (!success) return isolate->heap()->exception(); | 946 if (!success) return isolate->heap()->exception(); |
| 942 MAYBE_RETURN( | 947 MAYBE_RETURN( |
| 943 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), | 948 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), |
| 944 isolate->heap()->exception()); | 949 isolate->heap()->exception()); |
| 945 return *value; | 950 return *value; |
| 946 } | 951 } |
| 947 | 952 |
| 948 | 953 |
| 949 } // namespace internal | 954 } // namespace internal |
| 950 } // namespace v8 | 955 } // namespace v8 |
| OLD | NEW |