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

Side by Side Diff: src/bootstrapper.cc

Issue 358363003: Only create arguments-maps in the bootstrapper, remove now obsolete ValueType flag. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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
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 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 native_context()->set_data_view_fun(*data_view_fun); 1126 native_context()->set_data_view_fun(*data_view_fun);
1127 } 1127 }
1128 1128
1129 // -- W e a k M a p 1129 // -- W e a k M a p
1130 InstallFunction(global, "WeakMap", JS_WEAK_MAP_TYPE, JSWeakMap::kSize, 1130 InstallFunction(global, "WeakMap", JS_WEAK_MAP_TYPE, JSWeakMap::kSize,
1131 isolate->initial_object_prototype(), Builtins::kIllegal); 1131 isolate->initial_object_prototype(), Builtins::kIllegal);
1132 // -- W e a k S e t 1132 // -- W e a k S e t
1133 InstallFunction(global, "WeakSet", JS_WEAK_SET_TYPE, JSWeakSet::kSize, 1133 InstallFunction(global, "WeakSet", JS_WEAK_SET_TYPE, JSWeakSet::kSize,
1134 isolate->initial_object_prototype(), Builtins::kIllegal); 1134 isolate->initial_object_prototype(), Builtins::kIllegal);
1135 1135
1136 { // --- arguments_boilerplate_ 1136 { // --- sloppy arguments map
1137 // Make sure we can recognize argument objects at runtime. 1137 // Make sure we can recognize argument objects at runtime.
1138 // This is done by introducing an anonymous function with 1138 // This is done by introducing an anonymous function with
1139 // class_name equals 'Arguments'. 1139 // class_name equals 'Arguments'.
1140 Handle<String> arguments_string = factory->InternalizeOneByteString( 1140 Handle<String> arguments_string = factory->InternalizeOneByteString(
1141 STATIC_ASCII_VECTOR("Arguments")); 1141 STATIC_ASCII_VECTOR("Arguments"));
1142 Handle<Code> code(isolate->builtins()->builtin(Builtins::kIllegal)); 1142 Handle<Code> code(isolate->builtins()->builtin(Builtins::kIllegal));
1143
1144 Handle<JSFunction> function = factory->NewFunctionWithoutPrototype( 1143 Handle<JSFunction> function = factory->NewFunctionWithoutPrototype(
1145 arguments_string, code); 1144 arguments_string, code);
1145 function->shared()->set_instance_class_name(*arguments_string);
1146
1147 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE,
1148 Heap::kSloppyArgumentsObjectSize);
1149 // Create the descriptor array for the arguments object.
1150 Map::EnsureDescriptorSlack(map, 2);
1151
1152 { // length
1153 FieldDescriptor d(factory->length_string(), Heap::kArgumentsLengthIndex,
1154 DONT_ENUM, Representation::Tagged());
1155 map->AppendDescriptor(&d);
1156 }
1157 { // callee
1158 FieldDescriptor d(factory->callee_string(), Heap::kArgumentsCalleeIndex,
1159 DONT_ENUM, Representation::Tagged());
1160 map->AppendDescriptor(&d);
1161 }
1162
1163 map->set_function_with_prototype(true);
1164 map->set_prototype(native_context()->object_function()->prototype());
1165 map->set_pre_allocated_property_fields(2);
1166 map->set_inobject_properties(2);
1167 native_context()->set_sloppy_arguments_map(*map);
1168
1146 ASSERT(!function->has_initial_map()); 1169 ASSERT(!function->has_initial_map());
1147 function->shared()->set_instance_class_name(*arguments_string); 1170 function->set_initial_map(*map);
1148 function->shared()->set_expected_nof_properties(2); 1171 map->set_constructor(*function);
1149 function->set_prototype_or_initial_map(
1150 native_context()->object_function()->prototype());
1151 Handle<JSObject> result = factory->NewJSObject(function);
1152
1153 native_context()->set_sloppy_arguments_boilerplate(*result);
1154 // Note: length must be added as the first property and
1155 // callee must be added as the second property.
1156 JSObject::AddProperty(
1157 result, factory->length_string(),
1158 factory->undefined_value(), DONT_ENUM,
1159 Object::FORCE_TAGGED, FORCE_FIELD);
1160 JSObject::AddProperty(
1161 result, factory->callee_string(),
1162 factory->undefined_value(), DONT_ENUM,
1163 Object::FORCE_TAGGED, FORCE_FIELD);
1164 1172
1165 #ifdef DEBUG 1173 #ifdef DEBUG
Igor Sheludko 2014/07/02 14:17:14 Probably we don't need #ifdef DEBUG anymore
1166 LookupResult lookup(isolate); 1174 ASSERT(map->inobject_properties() > Heap::kArgumentsCalleeIndex);
1167 result->LookupOwn(factory->callee_string(), &lookup); 1175 ASSERT(map->inobject_properties() > Heap::kArgumentsLengthIndex);
1168 ASSERT(lookup.IsField()); 1176 ASSERT(!map->is_dictionary_map());
1169 ASSERT(lookup.GetFieldIndex().property_index() == 1177 ASSERT(IsFastObjectElementsKind(map->elements_kind()));
1170 Heap::kArgumentsCalleeIndex);
1171
1172 result->LookupOwn(factory->length_string(), &lookup);
1173 ASSERT(lookup.IsField());
1174 ASSERT(lookup.GetFieldIndex().property_index() ==
1175 Heap::kArgumentsLengthIndex);
1176
1177 ASSERT(result->map()->inobject_properties() > Heap::kArgumentsCalleeIndex);
1178 ASSERT(result->map()->inobject_properties() > Heap::kArgumentsLengthIndex);
1179
1180 // Check the state of the object.
1181 ASSERT(result->HasFastProperties());
1182 ASSERT(result->HasFastObjectElements());
1183 #endif 1178 #endif
1184 } 1179 }
1185 1180
1186 { // --- aliased_arguments_boilerplate_ 1181 { // --- aliased arguments map
1187 // Set up a well-formed parameter map to make assertions happy. 1182 Handle<Map> map = Map::Copy(isolate->sloppy_arguments_map());
1188 Handle<FixedArray> elements = factory->NewFixedArray(2); 1183 map->set_elements_kind(SLOPPY_ARGUMENTS_ELEMENTS);
1189 elements->set_map(heap->sloppy_arguments_elements_map()); 1184 ASSERT_EQ(2, map->pre_allocated_property_fields());
1190 Handle<FixedArray> array; 1185 native_context()->set_aliased_arguments_map(*map);
1191 array = factory->NewFixedArray(0);
1192 elements->set(0, *array);
1193 array = factory->NewFixedArray(0);
1194 elements->set(1, *array);
1195
1196 Handle<Map> old_map(
1197 native_context()->sloppy_arguments_boilerplate()->map());
1198 Handle<Map> new_map = Map::Copy(old_map);
1199 new_map->set_pre_allocated_property_fields(2);
1200 Handle<JSObject> result = factory->NewJSObjectFromMap(new_map);
1201 // Set elements kind after allocating the object because
1202 // NewJSObjectFromMap assumes a fast elements map.
1203 new_map->set_elements_kind(SLOPPY_ARGUMENTS_ELEMENTS);
1204 result->set_elements(*elements);
1205 ASSERT(result->HasSloppyArgumentsElements());
1206 native_context()->set_aliased_arguments_boilerplate(*result);
1207 } 1186 }
1208 1187
1209 { // --- strict mode arguments boilerplate 1188 { // --- strict mode arguments map
1210 const PropertyAttributes attributes = 1189 const PropertyAttributes attributes =
1211 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 1190 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
1212 1191
1213 // Create the ThrowTypeError functions. 1192 // Create the ThrowTypeError functions.
1214 Handle<AccessorPair> callee = factory->NewAccessorPair(); 1193 Handle<AccessorPair> callee = factory->NewAccessorPair();
1215 Handle<AccessorPair> caller = factory->NewAccessorPair(); 1194 Handle<AccessorPair> caller = factory->NewAccessorPair();
1216 1195
1217 Handle<JSFunction> poison = GetStrictPoisonFunction(); 1196 Handle<JSFunction> poison = GetStrictPoisonFunction();
1218 1197
1219 // Install the ThrowTypeError functions. 1198 // Install the ThrowTypeError functions.
1220 callee->set_getter(*poison); 1199 callee->set_getter(*poison);
1221 callee->set_setter(*poison); 1200 callee->set_setter(*poison);
1222 caller->set_getter(*poison); 1201 caller->set_getter(*poison);
1223 caller->set_setter(*poison); 1202 caller->set_setter(*poison);
1224 1203
1225 // Create the map. Allocate one in-object field for length. 1204 // Create the map. Allocate one in-object field for length.
1226 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, 1205 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE,
1227 Heap::kStrictArgumentsObjectSize); 1206 Heap::kStrictArgumentsObjectSize);
1228 // Create the descriptor array for the arguments object. 1207 // Create the descriptor array for the arguments object.
1229 Map::EnsureDescriptorSlack(map, 3); 1208 Map::EnsureDescriptorSlack(map, 3);
1230 1209
1231 { // length 1210 { // length
1232 FieldDescriptor d( 1211 FieldDescriptor d(factory->length_string(), Heap::kArgumentsLengthIndex,
1233 factory->length_string(), 0, DONT_ENUM, Representation::Tagged()); 1212 DONT_ENUM, Representation::Tagged());
1234 map->AppendDescriptor(&d); 1213 map->AppendDescriptor(&d);
1235 } 1214 }
1236 { // callee 1215 { // callee
1237 CallbacksDescriptor d(factory->callee_string(), 1216 CallbacksDescriptor d(factory->callee_string(), callee, attributes);
1238 callee,
1239 attributes);
1240 map->AppendDescriptor(&d); 1217 map->AppendDescriptor(&d);
1241 } 1218 }
1242 { // caller 1219 { // caller
1243 CallbacksDescriptor d(factory->caller_string(), 1220 CallbacksDescriptor d(factory->caller_string(), caller, attributes);
1244 caller,
1245 attributes);
1246 map->AppendDescriptor(&d); 1221 map->AppendDescriptor(&d);
1247 } 1222 }
1248 1223
1249 map->set_function_with_prototype(true); 1224 map->set_function_with_prototype(true);
1250 map->set_prototype(native_context()->object_function()->prototype()); 1225 map->set_prototype(native_context()->object_function()->prototype());
1251 map->set_pre_allocated_property_fields(1); 1226 map->set_pre_allocated_property_fields(1);
1252 map->set_inobject_properties(1); 1227 map->set_inobject_properties(1);
1253 1228
1254 // Copy constructor from the sloppy arguments boilerplate. 1229 // Copy constructor from the sloppy arguments boilerplate.
1255 map->set_constructor( 1230 map->set_constructor(
1256 native_context()->sloppy_arguments_boilerplate()->map()->constructor()); 1231 native_context()->sloppy_arguments_map()->constructor());
1257 1232
1258 // Allocate the arguments boilerplate object. 1233 native_context()->set_strict_arguments_map(*map);
1259 Handle<JSObject> result = factory->NewJSObjectFromMap(map);
1260 native_context()->set_strict_arguments_boilerplate(*result);
1261 1234
1262 #ifdef DEBUG 1235 #ifdef DEBUG
Igor Sheludko 2014/07/02 14:17:14 Same here.
1263 LookupResult lookup(isolate); 1236 ASSERT(map->inobject_properties() > Heap::kArgumentsLengthIndex);
1264 result->LookupOwn(factory->length_string(), &lookup); 1237 ASSERT(!map->is_dictionary_map());
1265 ASSERT(lookup.IsField()); 1238 ASSERT(IsFastObjectElementsKind(map->elements_kind()));
1266 ASSERT(lookup.GetFieldIndex().property_index() ==
1267 Heap::kArgumentsLengthIndex);
1268
1269 Handle<Object> length_value = Object::GetProperty(
1270 result, factory->length_string()).ToHandleChecked();
1271 ASSERT_EQ(heap->undefined_value(), *length_value);
1272
1273 ASSERT(result->map()->inobject_properties() > Heap::kArgumentsLengthIndex);
1274
1275 // Check the state of the object.
1276 ASSERT(result->HasFastProperties());
1277 ASSERT(result->HasFastObjectElements());
1278 #endif 1239 #endif
1279 } 1240 }
1280 1241
1281 { // --- context extension 1242 { // --- context extension
1282 // Create a function for the context extension objects. 1243 // Create a function for the context extension objects.
1283 Handle<Code> code = Handle<Code>( 1244 Handle<Code> code = Handle<Code>(
1284 isolate->builtins()->builtin(Builtins::kIllegal)); 1245 isolate->builtins()->builtin(Builtins::kIllegal));
1285 Handle<JSFunction> context_extension_fun = factory->NewFunction( 1246 Handle<JSFunction> context_extension_fun = factory->NewFunction(
1286 factory->empty_string(), code, JS_CONTEXT_EXTENSION_OBJECT_TYPE, 1247 factory->empty_string(), code, JS_CONTEXT_EXTENSION_OBJECT_TYPE,
1287 JSObject::kHeaderSize); 1248 JSObject::kHeaderSize);
(...skipping 1441 matching lines...) Expand 10 before | Expand all | Expand 10 after
2729 return from + sizeof(NestingCounterType); 2690 return from + sizeof(NestingCounterType);
2730 } 2691 }
2731 2692
2732 2693
2733 // Called when the top-level V8 mutex is destroyed. 2694 // Called when the top-level V8 mutex is destroyed.
2734 void Bootstrapper::FreeThreadResources() { 2695 void Bootstrapper::FreeThreadResources() {
2735 ASSERT(!IsActive()); 2696 ASSERT(!IsActive());
2736 } 2697 }
2737 2698
2738 } } // namespace v8::internal 2699 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698