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

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

Issue 2636493003: Revert of [compiler] Support Object.create(null) inlining in TF (Closed)
Patch Set: Created 3 years, 11 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/runtime/runtime-array.cc ('k') | src/value-serializer.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 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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 Handle<Object> prototype = args.at(0); 223 Handle<Object> prototype = args.at(0);
224 if (!prototype->IsNull(isolate) && !prototype->IsJSReceiver()) { 224 if (!prototype->IsNull(isolate) && !prototype->IsJSReceiver()) {
225 THROW_NEW_ERROR_RETURN_FAILURE( 225 THROW_NEW_ERROR_RETURN_FAILURE(
226 isolate, NewTypeError(MessageTemplate::kProtoObjectOrNull, prototype)); 226 isolate, NewTypeError(MessageTemplate::kProtoObjectOrNull, prototype));
227 } 227 }
228 228
229 // Generate the map with the specified {prototype} based on the Object 229 // Generate the map with the specified {prototype} based on the Object
230 // function's initial map from the current native context. 230 // function's initial map from the current native context.
231 // TODO(bmeurer): Use a dedicated cache for Object.create; think about 231 // TODO(bmeurer): Use a dedicated cache for Object.create; think about
232 // slack tracking for Object.create. 232 // slack tracking for Object.create.
233 Handle<Map> map = 233 Handle<Map> map(isolate->native_context()->object_function()->initial_map(),
234 Map::GetObjectCreateMap(Handle<HeapObject>::cast(prototype)); 234 isolate);
235 if (map->prototype() != *prototype) {
236 if (prototype->IsNull(isolate)) {
237 map = isolate->slow_object_with_null_prototype_map();
238 } else if (prototype->IsJSObject()) {
239 Handle<JSObject> js_prototype = Handle<JSObject>::cast(prototype);
240 if (!js_prototype->map()->is_prototype_map()) {
241 JSObject::OptimizeAsPrototype(js_prototype, FAST_PROTOTYPE);
242 }
243 Handle<PrototypeInfo> info =
244 Map::GetOrCreatePrototypeInfo(js_prototype, isolate);
245 // TODO(verwaest): Use inobject slack tracking for this map.
246 if (info->HasObjectCreateMap()) {
247 map = handle(info->ObjectCreateMap(), isolate);
248 } else {
249 map = Map::CopyInitialMap(map);
250 Map::SetPrototype(map, prototype, FAST_PROTOTYPE);
251 PrototypeInfo::SetObjectCreateMap(info, map);
252 }
253 } else {
254 map = Map::TransitionToPrototype(map, prototype, REGULAR_PROTOTYPE);
255 }
256 }
235 257
236 bool is_dictionary_map = map->is_dictionary_map(); 258 bool is_dictionary_map = map->is_dictionary_map();
237 Handle<FixedArray> object_properties; 259 Handle<FixedArray> object_properties;
238 if (is_dictionary_map) { 260 if (is_dictionary_map) {
239 // Allocate the actual properties dictionay up front to avoid invalid object 261 // Allocate the actual properties dictionay up front to avoid invalid object
240 // state. 262 // state.
241 object_properties = 263 object_properties =
242 NameDictionary::New(isolate, NameDictionary::kInitialCapacity); 264 NameDictionary::New(isolate, NameDictionary::kInitialCapacity);
243 } 265 }
244 // Actually allocate the object. 266 // Actually allocate the object.
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 if (!success) return isolate->heap()->exception(); 971 if (!success) return isolate->heap()->exception();
950 MAYBE_RETURN( 972 MAYBE_RETURN(
951 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), 973 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR),
952 isolate->heap()->exception()); 974 isolate->heap()->exception());
953 return *value; 975 return *value;
954 } 976 }
955 977
956 978
957 } // namespace internal 979 } // namespace internal
958 } // namespace v8 980 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-array.cc ('k') | src/value-serializer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698