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

Side by Side Diff: src/bootstrapper.cc

Issue 6603028: Merge revisions 7030:7051 from bleeding_edge to isolates branch.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 9 years, 9 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 | « src/array.js ('k') | src/extensions/experimental/break-iterator.h » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 configure_instance_fun); 1023 configure_instance_fun);
1024 INSTALL_NATIVE(JSFunction, "GetStackTraceLine", get_stack_trace_line_fun); 1024 INSTALL_NATIVE(JSFunction, "GetStackTraceLine", get_stack_trace_line_fun);
1025 INSTALL_NATIVE(JSObject, "functionCache", function_cache); 1025 INSTALL_NATIVE(JSObject, "functionCache", function_cache);
1026 } 1026 }
1027 1027
1028 #undef INSTALL_NATIVE 1028 #undef INSTALL_NATIVE
1029 1029
1030 1030
1031 bool Genesis::InstallNatives() { 1031 bool Genesis::InstallNatives() {
1032 HandleScope scope; 1032 HandleScope scope;
1033 Isolate* isolate = Isolate::Current();
1034 Factory* factory = isolate->factory();
1033 1035
1034 // Create a function for the builtins object. Allocate space for the 1036 // Create a function for the builtins object. Allocate space for the
1035 // JavaScript builtins, a reference to the builtins object 1037 // JavaScript builtins, a reference to the builtins object
1036 // (itself) and a reference to the global_context directly in the object. 1038 // (itself) and a reference to the global_context directly in the object.
1037 Handle<Code> code = Handle<Code>( 1039 Handle<Code> code = Handle<Code>(
1038 Isolate::Current()->builtins()->builtin(Builtins::Illegal)); 1040 isolate->builtins()->builtin(Builtins::Illegal));
1039 Handle<JSFunction> builtins_fun = 1041 Handle<JSFunction> builtins_fun =
1040 FACTORY->NewFunction(FACTORY->empty_symbol(), JS_BUILTINS_OBJECT_TYPE, 1042 factory->NewFunction(factory->empty_symbol(), JS_BUILTINS_OBJECT_TYPE,
1041 JSBuiltinsObject::kSize, code, true); 1043 JSBuiltinsObject::kSize, code, true);
1042 1044
1043 Handle<String> name = FACTORY->LookupAsciiSymbol("builtins"); 1045 Handle<String> name = factory->LookupAsciiSymbol("builtins");
1044 builtins_fun->shared()->set_instance_class_name(*name); 1046 builtins_fun->shared()->set_instance_class_name(*name);
1045 1047
1046 // Allocate the builtins object. 1048 // Allocate the builtins object.
1047 Handle<JSBuiltinsObject> builtins = 1049 Handle<JSBuiltinsObject> builtins =
1048 Handle<JSBuiltinsObject>::cast(FACTORY->NewGlobalObject(builtins_fun)); 1050 Handle<JSBuiltinsObject>::cast(factory->NewGlobalObject(builtins_fun));
1049 builtins->set_builtins(*builtins); 1051 builtins->set_builtins(*builtins);
1050 builtins->set_global_context(*global_context()); 1052 builtins->set_global_context(*global_context());
1051 builtins->set_global_receiver(*builtins); 1053 builtins->set_global_receiver(*builtins);
1052 1054
1053 // Setup the 'global' properties of the builtins object. The 1055 // Setup the 'global' properties of the builtins object. The
1054 // 'global' property that refers to the global object is the only 1056 // 'global' property that refers to the global object is the only
1055 // way to get from code running in the builtins context to the 1057 // way to get from code running in the builtins context to the
1056 // global object. 1058 // global object.
1057 static const PropertyAttributes attributes = 1059 static const PropertyAttributes attributes =
1058 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); 1060 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);
1059 Handle<String> global_symbol = FACTORY->LookupAsciiSymbol("global"); 1061 Handle<String> global_symbol = factory->LookupAsciiSymbol("global");
1060 Handle<Object> global_obj(global_context()->global()); 1062 Handle<Object> global_obj(global_context()->global());
1061 SetLocalPropertyNoThrow(builtins, global_symbol, global_obj, attributes); 1063 SetLocalPropertyNoThrow(builtins, global_symbol, global_obj, attributes);
1062 1064
1063 // Setup the reference from the global object to the builtins object. 1065 // Setup the reference from the global object to the builtins object.
1064 JSGlobalObject::cast(global_context()->global())->set_builtins(*builtins); 1066 JSGlobalObject::cast(global_context()->global())->set_builtins(*builtins);
1065 1067
1066 // Create a bridge function that has context in the global context. 1068 // Create a bridge function that has context in the global context.
1067 Handle<JSFunction> bridge = 1069 Handle<JSFunction> bridge =
1068 FACTORY->NewFunction(FACTORY->empty_symbol(), FACTORY->undefined_value()); 1070 factory->NewFunction(factory->empty_symbol(), factory->undefined_value());
1069 ASSERT(bridge->context() == *Isolate::Current()->global_context()); 1071 ASSERT(bridge->context() == *isolate->global_context());
1070 1072
1071 // Allocate the builtins context. 1073 // Allocate the builtins context.
1072 Handle<Context> context = 1074 Handle<Context> context =
1073 FACTORY->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, bridge); 1075 factory->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, bridge);
1074 context->set_global(*builtins); // override builtins global object 1076 context->set_global(*builtins); // override builtins global object
1075 1077
1076 global_context()->set_runtime_context(*context); 1078 global_context()->set_runtime_context(*context);
1077 1079
1078 { // -- S c r i p t 1080 { // -- S c r i p t
1079 // Builtin functions for Script. 1081 // Builtin functions for Script.
1080 Handle<JSFunction> script_fun = 1082 Handle<JSFunction> script_fun =
1081 InstallFunction(builtins, "Script", JS_VALUE_TYPE, JSValue::kSize, 1083 InstallFunction(builtins, "Script", JS_VALUE_TYPE, JSValue::kSize,
1082 Isolate::Current()->initial_object_prototype(), 1084 isolate->initial_object_prototype(),
1083 Builtins::Illegal, false); 1085 Builtins::Illegal, false);
1084 Handle<JSObject> prototype = 1086 Handle<JSObject> prototype =
1085 FACTORY->NewJSObject(Isolate::Current()->object_function(), TENURED); 1087 factory->NewJSObject(isolate->object_function(), TENURED);
1086 SetPrototype(script_fun, prototype); 1088 SetPrototype(script_fun, prototype);
1087 global_context()->set_script_function(*script_fun); 1089 global_context()->set_script_function(*script_fun);
1088 1090
1089 // Add 'source' and 'data' property to scripts. 1091 // Add 'source' and 'data' property to scripts.
1090 PropertyAttributes common_attributes = 1092 PropertyAttributes common_attributes =
1091 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 1093 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
1092 Handle<Proxy> proxy_source = FACTORY->NewProxy(&Accessors::ScriptSource); 1094 Handle<Proxy> proxy_source = factory->NewProxy(&Accessors::ScriptSource);
1093 Handle<DescriptorArray> script_descriptors = 1095 Handle<DescriptorArray> script_descriptors =
1094 FACTORY->CopyAppendProxyDescriptor( 1096 factory->CopyAppendProxyDescriptor(
1095 FACTORY->empty_descriptor_array(), 1097 factory->empty_descriptor_array(),
1096 FACTORY->LookupAsciiSymbol("source"), 1098 factory->LookupAsciiSymbol("source"),
1097 proxy_source, 1099 proxy_source,
1098 common_attributes); 1100 common_attributes);
1099 Handle<Proxy> proxy_name = FACTORY->NewProxy(&Accessors::ScriptName); 1101 Handle<Proxy> proxy_name = factory->NewProxy(&Accessors::ScriptName);
1100 script_descriptors = 1102 script_descriptors =
1101 FACTORY->CopyAppendProxyDescriptor( 1103 factory->CopyAppendProxyDescriptor(
1102 script_descriptors, 1104 script_descriptors,
1103 FACTORY->LookupAsciiSymbol("name"), 1105 factory->LookupAsciiSymbol("name"),
1104 proxy_name, 1106 proxy_name,
1105 common_attributes); 1107 common_attributes);
1106 Handle<Proxy> proxy_id = FACTORY->NewProxy(&Accessors::ScriptId); 1108 Handle<Proxy> proxy_id = factory->NewProxy(&Accessors::ScriptId);
1107 script_descriptors = 1109 script_descriptors =
1108 FACTORY->CopyAppendProxyDescriptor( 1110 factory->CopyAppendProxyDescriptor(
1109 script_descriptors, 1111 script_descriptors,
1110 FACTORY->LookupAsciiSymbol("id"), 1112 factory->LookupAsciiSymbol("id"),
1111 proxy_id, 1113 proxy_id,
1112 common_attributes); 1114 common_attributes);
1113 Handle<Proxy> proxy_line_offset = 1115 Handle<Proxy> proxy_line_offset =
1114 FACTORY->NewProxy(&Accessors::ScriptLineOffset); 1116 factory->NewProxy(&Accessors::ScriptLineOffset);
1115 script_descriptors = 1117 script_descriptors =
1116 FACTORY->CopyAppendProxyDescriptor( 1118 factory->CopyAppendProxyDescriptor(
1117 script_descriptors, 1119 script_descriptors,
1118 FACTORY->LookupAsciiSymbol("line_offset"), 1120 factory->LookupAsciiSymbol("line_offset"),
1119 proxy_line_offset, 1121 proxy_line_offset,
1120 common_attributes); 1122 common_attributes);
1121 Handle<Proxy> proxy_column_offset = 1123 Handle<Proxy> proxy_column_offset =
1122 FACTORY->NewProxy(&Accessors::ScriptColumnOffset); 1124 factory->NewProxy(&Accessors::ScriptColumnOffset);
1123 script_descriptors = 1125 script_descriptors =
1124 FACTORY->CopyAppendProxyDescriptor( 1126 factory->CopyAppendProxyDescriptor(
1125 script_descriptors, 1127 script_descriptors,
1126 FACTORY->LookupAsciiSymbol("column_offset"), 1128 factory->LookupAsciiSymbol("column_offset"),
1127 proxy_column_offset, 1129 proxy_column_offset,
1128 common_attributes); 1130 common_attributes);
1129 Handle<Proxy> proxy_data = FACTORY->NewProxy(&Accessors::ScriptData); 1131 Handle<Proxy> proxy_data = factory->NewProxy(&Accessors::ScriptData);
1130 script_descriptors = 1132 script_descriptors =
1131 FACTORY->CopyAppendProxyDescriptor( 1133 factory->CopyAppendProxyDescriptor(
1132 script_descriptors, 1134 script_descriptors,
1133 FACTORY->LookupAsciiSymbol("data"), 1135 factory->LookupAsciiSymbol("data"),
1134 proxy_data, 1136 proxy_data,
1135 common_attributes); 1137 common_attributes);
1136 Handle<Proxy> proxy_type = FACTORY->NewProxy(&Accessors::ScriptType); 1138 Handle<Proxy> proxy_type = factory->NewProxy(&Accessors::ScriptType);
1137 script_descriptors = 1139 script_descriptors =
1138 FACTORY->CopyAppendProxyDescriptor( 1140 factory->CopyAppendProxyDescriptor(
1139 script_descriptors, 1141 script_descriptors,
1140 FACTORY->LookupAsciiSymbol("type"), 1142 factory->LookupAsciiSymbol("type"),
1141 proxy_type, 1143 proxy_type,
1142 common_attributes); 1144 common_attributes);
1143 Handle<Proxy> proxy_compilation_type = 1145 Handle<Proxy> proxy_compilation_type =
1144 FACTORY->NewProxy(&Accessors::ScriptCompilationType); 1146 factory->NewProxy(&Accessors::ScriptCompilationType);
1145 script_descriptors = 1147 script_descriptors =
1146 FACTORY->CopyAppendProxyDescriptor( 1148 factory->CopyAppendProxyDescriptor(
1147 script_descriptors, 1149 script_descriptors,
1148 FACTORY->LookupAsciiSymbol("compilation_type"), 1150 factory->LookupAsciiSymbol("compilation_type"),
1149 proxy_compilation_type, 1151 proxy_compilation_type,
1150 common_attributes); 1152 common_attributes);
1151 Handle<Proxy> proxy_line_ends = 1153 Handle<Proxy> proxy_line_ends =
1152 FACTORY->NewProxy(&Accessors::ScriptLineEnds); 1154 factory->NewProxy(&Accessors::ScriptLineEnds);
1153 script_descriptors = 1155 script_descriptors =
1154 FACTORY->CopyAppendProxyDescriptor( 1156 factory->CopyAppendProxyDescriptor(
1155 script_descriptors, 1157 script_descriptors,
1156 FACTORY->LookupAsciiSymbol("line_ends"), 1158 factory->LookupAsciiSymbol("line_ends"),
1157 proxy_line_ends, 1159 proxy_line_ends,
1158 common_attributes); 1160 common_attributes);
1159 Handle<Proxy> proxy_context_data = 1161 Handle<Proxy> proxy_context_data =
1160 FACTORY->NewProxy(&Accessors::ScriptContextData); 1162 factory->NewProxy(&Accessors::ScriptContextData);
1161 script_descriptors = 1163 script_descriptors =
1162 FACTORY->CopyAppendProxyDescriptor( 1164 factory->CopyAppendProxyDescriptor(
1163 script_descriptors, 1165 script_descriptors,
1164 FACTORY->LookupAsciiSymbol("context_data"), 1166 factory->LookupAsciiSymbol("context_data"),
1165 proxy_context_data, 1167 proxy_context_data,
1166 common_attributes); 1168 common_attributes);
1167 Handle<Proxy> proxy_eval_from_script = 1169 Handle<Proxy> proxy_eval_from_script =
1168 FACTORY->NewProxy(&Accessors::ScriptEvalFromScript); 1170 factory->NewProxy(&Accessors::ScriptEvalFromScript);
1169 script_descriptors = 1171 script_descriptors =
1170 FACTORY->CopyAppendProxyDescriptor( 1172 factory->CopyAppendProxyDescriptor(
1171 script_descriptors, 1173 script_descriptors,
1172 FACTORY->LookupAsciiSymbol("eval_from_script"), 1174 factory->LookupAsciiSymbol("eval_from_script"),
1173 proxy_eval_from_script, 1175 proxy_eval_from_script,
1174 common_attributes); 1176 common_attributes);
1175 Handle<Proxy> proxy_eval_from_script_position = 1177 Handle<Proxy> proxy_eval_from_script_position =
1176 FACTORY->NewProxy(&Accessors::ScriptEvalFromScriptPosition); 1178 factory->NewProxy(&Accessors::ScriptEvalFromScriptPosition);
1177 script_descriptors = 1179 script_descriptors =
1178 FACTORY->CopyAppendProxyDescriptor( 1180 factory->CopyAppendProxyDescriptor(
1179 script_descriptors, 1181 script_descriptors,
1180 FACTORY->LookupAsciiSymbol("eval_from_script_position"), 1182 factory->LookupAsciiSymbol("eval_from_script_position"),
1181 proxy_eval_from_script_position, 1183 proxy_eval_from_script_position,
1182 common_attributes); 1184 common_attributes);
1183 Handle<Proxy> proxy_eval_from_function_name = 1185 Handle<Proxy> proxy_eval_from_function_name =
1184 FACTORY->NewProxy(&Accessors::ScriptEvalFromFunctionName); 1186 factory->NewProxy(&Accessors::ScriptEvalFromFunctionName);
1185 script_descriptors = 1187 script_descriptors =
1186 FACTORY->CopyAppendProxyDescriptor( 1188 factory->CopyAppendProxyDescriptor(
1187 script_descriptors, 1189 script_descriptors,
1188 FACTORY->LookupAsciiSymbol("eval_from_function_name"), 1190 factory->LookupAsciiSymbol("eval_from_function_name"),
1189 proxy_eval_from_function_name, 1191 proxy_eval_from_function_name,
1190 common_attributes); 1192 common_attributes);
1191 1193
1192 Handle<Map> script_map = Handle<Map>(script_fun->initial_map()); 1194 Handle<Map> script_map = Handle<Map>(script_fun->initial_map());
1193 script_map->set_instance_descriptors(*script_descriptors); 1195 script_map->set_instance_descriptors(*script_descriptors);
1194 1196
1195 // Allocate the empty script. 1197 // Allocate the empty script.
1196 Handle<Script> script = FACTORY->NewScript(FACTORY->empty_string()); 1198 Handle<Script> script = factory->NewScript(factory->empty_string());
1197 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); 1199 script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
1198 HEAP->public_set_empty_script(*script); 1200 HEAP->public_set_empty_script(*script);
1199 } 1201 }
1200 { 1202 {
1201 // Builtin function for OpaqueReference -- a JSValue-based object, 1203 // Builtin function for OpaqueReference -- a JSValue-based object,
1202 // that keeps its field isolated from JavaScript code. It may store 1204 // that keeps its field isolated from JavaScript code. It may store
1203 // objects, that JavaScript code may not access. 1205 // objects, that JavaScript code may not access.
1204 Handle<JSFunction> opaque_reference_fun = 1206 Handle<JSFunction> opaque_reference_fun =
1205 InstallFunction(builtins, "OpaqueReference", JS_VALUE_TYPE, 1207 InstallFunction(builtins, "OpaqueReference", JS_VALUE_TYPE,
1206 JSValue::kSize, 1208 JSValue::kSize,
1207 Isolate::Current()->initial_object_prototype(), 1209 isolate->initial_object_prototype(),
1208 Builtins::Illegal, false); 1210 Builtins::Illegal, false);
1209 Handle<JSObject> prototype = 1211 Handle<JSObject> prototype =
1210 FACTORY->NewJSObject(Isolate::Current()->object_function(), TENURED); 1212 factory->NewJSObject(isolate->object_function(), TENURED);
1211 SetPrototype(opaque_reference_fun, prototype); 1213 SetPrototype(opaque_reference_fun, prototype);
1212 global_context()->set_opaque_reference_function(*opaque_reference_fun); 1214 global_context()->set_opaque_reference_function(*opaque_reference_fun);
1213 } 1215 }
1214 1216
1217 { // --- I n t e r n a l A r r a y ---
1218 // An array constructor on the builtins object that works like
1219 // the public Array constructor, except that its prototype
1220 // doesn't inherit from Object.prototype.
1221 // To be used only for internal work by builtins. Instances
1222 // must not be leaked to user code.
1223 // Only works correctly when called as a constructor. The normal
1224 // Array code uses Array.prototype as prototype when called as
1225 // a function.
1226 Handle<JSFunction> array_function =
1227 InstallFunction(builtins,
1228 "InternalArray",
1229 JS_ARRAY_TYPE,
1230 JSArray::kSize,
1231 isolate->initial_object_prototype(),
1232 Builtins::ArrayCode,
1233 true);
1234 Handle<JSObject> prototype =
1235 factory->NewJSObject(isolate->object_function(), TENURED);
1236 SetPrototype(array_function, prototype);
1237
1238 array_function->shared()->set_construct_stub(
1239 isolate->builtins()->builtin(Builtins::ArrayConstructCode));
1240 array_function->shared()->DontAdaptArguments();
1241
1242 // Make "length" magic on instances.
1243 Handle<DescriptorArray> array_descriptors =
1244 factory->CopyAppendProxyDescriptor(
1245 factory->empty_descriptor_array(),
1246 factory->length_symbol(),
1247 factory->NewProxy(&Accessors::ArrayLength),
1248 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE));
1249
1250 array_function->initial_map()->set_instance_descriptors(
1251 *array_descriptors);
1252 }
1253
1215 if (FLAG_disable_native_files) { 1254 if (FLAG_disable_native_files) {
1216 PrintF("Warning: Running without installed natives!\n"); 1255 PrintF("Warning: Running without installed natives!\n");
1217 return true; 1256 return true;
1218 } 1257 }
1219 1258
1220 // Install natives. 1259 // Install natives.
1221 for (int i = Natives::GetDebuggerCount(); 1260 for (int i = Natives::GetDebuggerCount();
1222 i < Natives::GetBuiltinsCount(); 1261 i < Natives::GetBuiltinsCount();
1223 i++) { 1262 i++) {
1224 Vector<const char> name = Natives::GetScriptName(i); 1263 Vector<const char> name = Natives::GetScriptName(i);
(...skipping 10 matching lines...) Expand all
1235 // and the String function has been setup. 1274 // and the String function has been setup.
1236 Handle<JSFunction> string_function(global_context()->string_function()); 1275 Handle<JSFunction> string_function(global_context()->string_function());
1237 ASSERT(JSObject::cast( 1276 ASSERT(JSObject::cast(
1238 string_function->initial_map()->prototype())->HasFastProperties()); 1277 string_function->initial_map()->prototype())->HasFastProperties());
1239 global_context()->set_string_function_prototype_map( 1278 global_context()->set_string_function_prototype_map(
1240 HeapObject::cast(string_function->initial_map()->prototype())->map()); 1279 HeapObject::cast(string_function->initial_map()->prototype())->map());
1241 1280
1242 InstallBuiltinFunctionIds(); 1281 InstallBuiltinFunctionIds();
1243 1282
1244 // Install Function.prototype.call and apply. 1283 // Install Function.prototype.call and apply.
1245 { Handle<String> key = FACTORY->function_class_symbol(); 1284 { Handle<String> key = factory->function_class_symbol();
1246 Handle<JSFunction> function = 1285 Handle<JSFunction> function =
1247 Handle<JSFunction>::cast( 1286 Handle<JSFunction>::cast(GetProperty(isolate->global(), key));
1248 GetProperty(Isolate::Current()->global(), key));
1249 Handle<JSObject> proto = 1287 Handle<JSObject> proto =
1250 Handle<JSObject>(JSObject::cast(function->instance_prototype())); 1288 Handle<JSObject>(JSObject::cast(function->instance_prototype()));
1251 1289
1252 // Install the call and the apply functions. 1290 // Install the call and the apply functions.
1253 Handle<JSFunction> call = 1291 Handle<JSFunction> call =
1254 InstallFunction(proto, "call", JS_OBJECT_TYPE, JSObject::kHeaderSize, 1292 InstallFunction(proto, "call", JS_OBJECT_TYPE, JSObject::kHeaderSize,
1255 Handle<JSObject>::null(), 1293 Handle<JSObject>::null(),
1256 Builtins::FunctionCall, 1294 Builtins::FunctionCall,
1257 false); 1295 false);
1258 Handle<JSFunction> apply = 1296 Handle<JSFunction> apply =
(...skipping 21 matching lines...) Expand all
1280 { 1318 {
1281 // RegExpResult initial map. 1319 // RegExpResult initial map.
1282 1320
1283 // Find global.Array.prototype to inherit from. 1321 // Find global.Array.prototype to inherit from.
1284 Handle<JSFunction> array_constructor(global_context()->array_function()); 1322 Handle<JSFunction> array_constructor(global_context()->array_function());
1285 Handle<JSObject> array_prototype( 1323 Handle<JSObject> array_prototype(
1286 JSObject::cast(array_constructor->instance_prototype())); 1324 JSObject::cast(array_constructor->instance_prototype()));
1287 1325
1288 // Add initial map. 1326 // Add initial map.
1289 Handle<Map> initial_map = 1327 Handle<Map> initial_map =
1290 FACTORY->NewMap(JS_ARRAY_TYPE, JSRegExpResult::kSize); 1328 factory->NewMap(JS_ARRAY_TYPE, JSRegExpResult::kSize);
1291 initial_map->set_constructor(*array_constructor); 1329 initial_map->set_constructor(*array_constructor);
1292 1330
1293 // Set prototype on map. 1331 // Set prototype on map.
1294 initial_map->set_non_instance_prototype(false); 1332 initial_map->set_non_instance_prototype(false);
1295 initial_map->set_prototype(*array_prototype); 1333 initial_map->set_prototype(*array_prototype);
1296 1334
1297 // Update map with length accessor from Array and add "index" and "input". 1335 // Update map with length accessor from Array and add "index" and "input".
1298 Handle<Map> array_map(global_context()->js_array_map()); 1336 Handle<Map> array_map(global_context()->js_array_map());
1299 Handle<DescriptorArray> array_descriptors( 1337 Handle<DescriptorArray> array_descriptors(
1300 array_map->instance_descriptors()); 1338 array_map->instance_descriptors());
1301 ASSERT_EQ(1, array_descriptors->number_of_descriptors()); 1339 ASSERT_EQ(1, array_descriptors->number_of_descriptors());
1302 1340
1303 Handle<DescriptorArray> reresult_descriptors = 1341 Handle<DescriptorArray> reresult_descriptors =
1304 FACTORY->NewDescriptorArray(3); 1342 factory->NewDescriptorArray(3);
1305 1343
1306 reresult_descriptors->CopyFrom(0, *array_descriptors, 0); 1344 reresult_descriptors->CopyFrom(0, *array_descriptors, 0);
1307 1345
1308 int enum_index = 0; 1346 int enum_index = 0;
1309 { 1347 {
1310 FieldDescriptor index_field(HEAP->index_symbol(), 1348 FieldDescriptor index_field(HEAP->index_symbol(),
1311 JSRegExpResult::kIndexIndex, 1349 JSRegExpResult::kIndexIndex,
1312 NONE, 1350 NONE,
1313 enum_index++); 1351 enum_index++);
1314 reresult_descriptors->Set(1, &index_field); 1352 reresult_descriptors->Set(1, &index_field);
1315 } 1353 }
1316 1354
1317 { 1355 {
1318 FieldDescriptor input_field(HEAP->input_symbol(), 1356 FieldDescriptor input_field(HEAP->input_symbol(),
1319 JSRegExpResult::kInputIndex, 1357 JSRegExpResult::kInputIndex,
1320 NONE, 1358 NONE,
1321 enum_index++); 1359 enum_index++);
1322 reresult_descriptors->Set(2, &input_field); 1360 reresult_descriptors->Set(2, &input_field);
1323 } 1361 }
1324 reresult_descriptors->Sort(); 1362 reresult_descriptors->Sort();
1325 1363
1326 initial_map->set_inobject_properties(2); 1364 initial_map->set_inobject_properties(2);
1327 initial_map->set_pre_allocated_property_fields(2); 1365 initial_map->set_pre_allocated_property_fields(2);
1328 initial_map->set_unused_property_fields(0); 1366 initial_map->set_unused_property_fields(0);
1329 initial_map->set_instance_descriptors(*reresult_descriptors); 1367 initial_map->set_instance_descriptors(*reresult_descriptors);
1330 1368
1331 global_context()->set_regexp_result_map(*initial_map); 1369 global_context()->set_regexp_result_map(*initial_map);
1332 } 1370 }
1333 1371
1372
1334 #ifdef DEBUG 1373 #ifdef DEBUG
1335 builtins->Verify(); 1374 builtins->Verify();
1336 #endif 1375 #endif
1337 1376
1338 return true; 1377 return true;
1339 } 1378 }
1340 1379
1341 1380
1342 static Handle<JSObject> ResolveBuiltinIdHolder( 1381 static Handle<JSObject> ResolveBuiltinIdHolder(
1343 Handle<Context> global_context, 1382 Handle<Context> global_context,
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
1841 return from + sizeof(NestingCounterType); 1880 return from + sizeof(NestingCounterType);
1842 } 1881 }
1843 1882
1844 1883
1845 // Called when the top-level V8 mutex is destroyed. 1884 // Called when the top-level V8 mutex is destroyed.
1846 void Bootstrapper::FreeThreadResources() { 1885 void Bootstrapper::FreeThreadResources() {
1847 ASSERT(!IsActive()); 1886 ASSERT(!IsActive());
1848 } 1887 }
1849 1888
1850 } } // namespace v8::internal 1889 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/array.js ('k') | src/extensions/experimental/break-iterator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698