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

Side by Side Diff: src/bootstrapper.cc

Issue 586673002: Use the initial map of the Object function for empty object literals (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Make unused properties of Object be inobject Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/factory.cc » ('j') | src/hydrogen.cc » ('J')
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/bootstrapper.h" 5 #include "src/bootstrapper.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/extensions/externalize-string-extension.h" 9 #include "src/extensions/externalize-string-extension.h"
10 #include "src/extensions/free-buffer-extension.h" 10 #include "src/extensions/free-buffer-extension.h"
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 // This map is installed in MakeFunctionInstancePrototypeWritable. 476 // This map is installed in MakeFunctionInstancePrototypeWritable.
477 sloppy_function_map_writable_prototype_ = 477 sloppy_function_map_writable_prototype_ =
478 CreateFunctionMap(FUNCTION_WITH_WRITEABLE_PROTOTYPE); 478 CreateFunctionMap(FUNCTION_WITH_WRITEABLE_PROTOTYPE);
479 479
480 Factory* factory = isolate->factory(); 480 Factory* factory = isolate->factory();
481 481
482 Handle<String> object_name = factory->Object_string(); 482 Handle<String> object_name = factory->Object_string();
483 483
484 { // --- O b j e c t --- 484 { // --- O b j e c t ---
485 Handle<JSFunction> object_fun = factory->NewFunction(object_name); 485 Handle<JSFunction> object_fun = factory->NewFunction(object_name);
486 int unused = JSObject::kInitialGlobalObjectUnusedPropertiesCount;
487 int instance_size = JSObject::kHeaderSize + kPointerSize * unused;
486 Handle<Map> object_function_map = 488 Handle<Map> object_function_map =
487 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); 489 factory->NewMap(JS_OBJECT_TYPE, instance_size);
490 object_function_map->set_inobject_properties(unused);
488 JSFunction::SetInitialMap(object_fun, object_function_map, 491 JSFunction::SetInitialMap(object_fun, object_function_map,
489 isolate->factory()->null_value()); 492 isolate->factory()->null_value());
490 object_function_map->set_unused_property_fields( 493 object_function_map->set_unused_property_fields(unused);
491 JSObject::kInitialGlobalObjectUnusedPropertiesCount);
492 494
493 native_context()->set_object_function(*object_fun); 495 native_context()->set_object_function(*object_fun);
494 496
495 // Allocate a new prototype for the object function. 497 // Allocate a new prototype for the object function.
496 Handle<JSObject> prototype = factory->NewJSObject( 498 Handle<JSObject> prototype = factory->NewJSObject(
497 isolate->object_function(), 499 isolate->object_function(),
498 TENURED); 500 TENURED);
499 Handle<Map> map = Map::Copy(handle(prototype->map())); 501 Handle<Map> map = Map::Copy(handle(prototype->map()));
500 map->set_is_prototype_map(true); 502 map->set_is_prototype_map(true);
501 prototype->set_map(*map); 503 prototype->set_map(*map);
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 InstallFunction(global, "Map", JS_MAP_TYPE, JSMap::kSize, 1148 InstallFunction(global, "Map", JS_MAP_TYPE, JSMap::kSize,
1147 isolate->initial_object_prototype(), Builtins::kIllegal); 1149 isolate->initial_object_prototype(), Builtins::kIllegal);
1148 1150
1149 // -- S e t 1151 // -- S e t
1150 InstallFunction(global, "Set", JS_SET_TYPE, JSSet::kSize, 1152 InstallFunction(global, "Set", JS_SET_TYPE, JSSet::kSize,
1151 isolate->initial_object_prototype(), Builtins::kIllegal); 1153 isolate->initial_object_prototype(), Builtins::kIllegal);
1152 1154
1153 { // Set up the iterator result object 1155 { // Set up the iterator result object
1154 STATIC_ASSERT(JSGeneratorObject::kResultPropertyCount == 2); 1156 STATIC_ASSERT(JSGeneratorObject::kResultPropertyCount == 2);
1155 Handle<JSFunction> object_function(native_context()->object_function()); 1157 Handle<JSFunction> object_function(native_context()->object_function());
1156 DCHECK(object_function->initial_map()->inobject_properties() == 0);
1157 Handle<Map> iterator_result_map = 1158 Handle<Map> iterator_result_map =
1158 Map::Create(object_function, JSGeneratorObject::kResultPropertyCount); 1159 Map::Create(object_function, JSGeneratorObject::kResultPropertyCount);
1159 DCHECK(iterator_result_map->inobject_properties() ==
1160 JSGeneratorObject::kResultPropertyCount);
1161 Map::EnsureDescriptorSlack(iterator_result_map, 1160 Map::EnsureDescriptorSlack(iterator_result_map,
1162 JSGeneratorObject::kResultPropertyCount); 1161 JSGeneratorObject::kResultPropertyCount);
1163 1162
1164 FieldDescriptor value_descr(factory->value_string(), 1163 FieldDescriptor value_descr(factory->value_string(),
1165 JSGeneratorObject::kResultValuePropertyIndex, 1164 JSGeneratorObject::kResultValuePropertyIndex,
1166 NONE, Representation::Tagged()); 1165 NONE, Representation::Tagged());
1167 iterator_result_map->AppendDescriptor(&value_descr); 1166 iterator_result_map->AppendDescriptor(&value_descr);
1168 1167
1169 FieldDescriptor done_descr(factory->done_string(), 1168 FieldDescriptor done_descr(factory->done_string(),
1170 JSGeneratorObject::kResultDonePropertyIndex, 1169 JSGeneratorObject::kResultDonePropertyIndex,
1171 NONE, Representation::Tagged()); 1170 NONE, Representation::Tagged());
1172 iterator_result_map->AppendDescriptor(&done_descr); 1171 iterator_result_map->AppendDescriptor(&done_descr);
1173 1172
1173 iterator_result_map->set_instance_size(JSGeneratorObject::kResultSize);
1174 iterator_result_map->set_unused_property_fields(0); 1174 iterator_result_map->set_unused_property_fields(0);
1175 iterator_result_map->set_inobject_properties(
1176 JSGeneratorObject::kResultPropertyCount);
1177 iterator_result_map->set_pre_allocated_property_fields(
1178 JSGeneratorObject::kResultPropertyCount);
1175 DCHECK_EQ(JSGeneratorObject::kResultSize, 1179 DCHECK_EQ(JSGeneratorObject::kResultSize,
1176 iterator_result_map->instance_size()); 1180 iterator_result_map->instance_size());
1177 native_context()->set_iterator_result_map(*iterator_result_map); 1181 native_context()->set_iterator_result_map(*iterator_result_map);
1178 } 1182 }
1179 1183
1180 // -- W e a k M a p 1184 // -- W e a k M a p
1181 InstallFunction(global, "WeakMap", JS_WEAK_MAP_TYPE, JSWeakMap::kSize, 1185 InstallFunction(global, "WeakMap", JS_WEAK_MAP_TYPE, JSWeakMap::kSize,
1182 isolate->initial_object_prototype(), Builtins::kIllegal); 1186 isolate->initial_object_prototype(), Builtins::kIllegal);
1183 // -- W e a k S e t 1187 // -- W e a k S e t
1184 InstallFunction(global, "WeakSet", JS_WEAK_SET_TYPE, JSWeakSet::kSize, 1188 InstallFunction(global, "WeakSet", JS_WEAK_SET_TYPE, JSWeakSet::kSize,
(...skipping 1544 matching lines...) Expand 10 before | Expand all | Expand 10 after
2729 return from + sizeof(NestingCounterType); 2733 return from + sizeof(NestingCounterType);
2730 } 2734 }
2731 2735
2732 2736
2733 // Called when the top-level V8 mutex is destroyed. 2737 // Called when the top-level V8 mutex is destroyed.
2734 void Bootstrapper::FreeThreadResources() { 2738 void Bootstrapper::FreeThreadResources() {
2735 DCHECK(!IsActive()); 2739 DCHECK(!IsActive());
2736 } 2740 }
2737 2741
2738 } } // namespace v8::internal 2742 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/factory.cc » ('j') | src/hydrogen.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698