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

Side by Side Diff: src/bootstrapper.cc

Issue 5767002: Merge math function ids and custom call generator ids. (Closed)
Patch Set: arm and x64 fixes. Created 10 years 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/ast.cc ('k') | src/hydrogen.cc » ('j') | src/objects-inl.h » ('J')
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 20 matching lines...) Expand all
31 #include "api.h" 31 #include "api.h"
32 #include "bootstrapper.h" 32 #include "bootstrapper.h"
33 #include "compiler.h" 33 #include "compiler.h"
34 #include "debug.h" 34 #include "debug.h"
35 #include "execution.h" 35 #include "execution.h"
36 #include "global-handles.h" 36 #include "global-handles.h"
37 #include "macro-assembler.h" 37 #include "macro-assembler.h"
38 #include "natives.h" 38 #include "natives.h"
39 #include "objects-visiting.h" 39 #include "objects-visiting.h"
40 #include "snapshot.h" 40 #include "snapshot.h"
41 #include "stub-cache.h"
42 #include "extensions/externalize-string-extension.h" 41 #include "extensions/externalize-string-extension.h"
43 #include "extensions/gc-extension.h" 42 #include "extensions/gc-extension.h"
44 43
45 namespace v8 { 44 namespace v8 {
46 namespace internal { 45 namespace internal {
47 46
48 // A SourceCodeCache uses a FixedArray to store pairs of 47 // A SourceCodeCache uses a FixedArray to store pairs of
49 // (AsciiString*, JSFunction*), mapping names of native code files 48 // (AsciiString*, JSFunction*), mapping names of native code files
50 // (runtime.js, etc.) to precompiled functions. Instead of mapping 49 // (runtime.js, etc.) to precompiled functions. Instead of mapping
51 // names to functions it might make sense to let the JS2C tool 50 // names to functions it might make sense to let the JS2C tool
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 // templates passed through the API. The inner global from the snapshot is 226 // templates passed through the API. The inner global from the snapshot is
228 // detached from the other objects in the snapshot. 227 // detached from the other objects in the snapshot.
229 void HookUpInnerGlobal(Handle<GlobalObject> inner_global); 228 void HookUpInnerGlobal(Handle<GlobalObject> inner_global);
230 // New context initialization. Used for creating a context from scratch. 229 // New context initialization. Used for creating a context from scratch.
231 void InitializeGlobal(Handle<GlobalObject> inner_global, 230 void InitializeGlobal(Handle<GlobalObject> inner_global,
232 Handle<JSFunction> empty_function); 231 Handle<JSFunction> empty_function);
233 // Installs the contents of the native .js files on the global objects. 232 // Installs the contents of the native .js files on the global objects.
234 // Used for creating a context from scratch. 233 // Used for creating a context from scratch.
235 void InstallNativeFunctions(); 234 void InstallNativeFunctions();
236 bool InstallNatives(); 235 bool InstallNatives();
237 void InstallCustomCallGenerators(); 236 void InstallBuiltinFunctionIds();
238 void InstallJSFunctionResultCaches(); 237 void InstallJSFunctionResultCaches();
239 void InitializeNormalizedMapCaches(); 238 void InitializeNormalizedMapCaches();
240 // Used both for deserialized and from-scratch contexts to add the extensions 239 // Used both for deserialized and from-scratch contexts to add the extensions
241 // provided. 240 // provided.
242 static bool InstallExtensions(Handle<Context> global_context, 241 static bool InstallExtensions(Handle<Context> global_context,
243 v8::ExtensionConfiguration* extensions); 242 v8::ExtensionConfiguration* extensions);
244 static bool InstallExtension(const char* name); 243 static bool InstallExtension(const char* name);
245 static bool InstallExtension(v8::RegisteredExtension* current); 244 static bool InstallExtension(v8::RegisteredExtension* current);
246 static void InstallSpecialObjects(Handle<Context> global_context); 245 static void InstallSpecialObjects(Handle<Context> global_context);
247 bool InstallJSBuiltins(Handle<JSBuiltinsObject> builtins); 246 bool InstallJSBuiltins(Handle<JSBuiltinsObject> builtins);
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 InstallNativeFunctions(); 1262 InstallNativeFunctions();
1264 1263
1265 // Store the map for the string prototype after the natives has been compiled 1264 // Store the map for the string prototype after the natives has been compiled
1266 // and the String function has been setup. 1265 // and the String function has been setup.
1267 Handle<JSFunction> string_function(global_context()->string_function()); 1266 Handle<JSFunction> string_function(global_context()->string_function());
1268 ASSERT(JSObject::cast( 1267 ASSERT(JSObject::cast(
1269 string_function->initial_map()->prototype())->HasFastProperties()); 1268 string_function->initial_map()->prototype())->HasFastProperties());
1270 global_context()->set_string_function_prototype_map( 1269 global_context()->set_string_function_prototype_map(
1271 HeapObject::cast(string_function->initial_map()->prototype())->map()); 1270 HeapObject::cast(string_function->initial_map()->prototype())->map());
1272 1271
1273 InstallCustomCallGenerators(); 1272 InstallBuiltinFunctionIds();
1274 1273
1275 // Install Function.prototype.call and apply. 1274 // Install Function.prototype.call and apply.
1276 { Handle<String> key = Factory::function_class_symbol(); 1275 { Handle<String> key = Factory::function_class_symbol();
1277 Handle<JSFunction> function = 1276 Handle<JSFunction> function =
1278 Handle<JSFunction>::cast(GetProperty(Top::global(), key)); 1277 Handle<JSFunction>::cast(GetProperty(Top::global(), key));
1279 Handle<JSObject> proto = 1278 Handle<JSObject> proto =
1280 Handle<JSObject>(JSObject::cast(function->instance_prototype())); 1279 Handle<JSObject>(JSObject::cast(function->instance_prototype()));
1281 1280
1282 // Install the call and the apply functions. 1281 // Install the call and the apply functions.
1283 Handle<JSFunction> call = 1282 Handle<JSFunction> call =
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1362 } 1361 }
1363 1362
1364 #ifdef DEBUG 1363 #ifdef DEBUG
1365 builtins->Verify(); 1364 builtins->Verify();
1366 #endif 1365 #endif
1367 1366
1368 return true; 1367 return true;
1369 } 1368 }
1370 1369
1371 1370
1372 static Handle<JSObject> ResolveCustomCallGeneratorHolder( 1371 static Handle<JSObject> ResolveBuiltinIdHolder(
1373 Handle<Context> global_context, 1372 Handle<Context> global_context,
1374 const char* holder_expr) { 1373 const char* holder_expr) {
1375 Handle<GlobalObject> global(global_context->global()); 1374 Handle<GlobalObject> global(global_context->global());
1376 const char* period_pos = strchr(holder_expr, '.'); 1375 const char* period_pos = strchr(holder_expr, '.');
1377 if (period_pos == NULL) { 1376 if (period_pos == NULL) {
1378 return Handle<JSObject>::cast( 1377 return Handle<JSObject>::cast(
1379 GetProperty(global, Factory::LookupAsciiSymbol(holder_expr))); 1378 GetProperty(global, Factory::LookupAsciiSymbol(holder_expr)));
1380 } 1379 }
1381 ASSERT_EQ(".prototype", period_pos); 1380 ASSERT_EQ(".prototype", period_pos);
1382 Vector<const char> property(holder_expr, 1381 Vector<const char> property(holder_expr,
1383 static_cast<int>(period_pos - holder_expr)); 1382 static_cast<int>(period_pos - holder_expr));
1384 Handle<JSFunction> function = Handle<JSFunction>::cast( 1383 Handle<JSFunction> function = Handle<JSFunction>::cast(
1385 GetProperty(global, Factory::LookupSymbol(property))); 1384 GetProperty(global, Factory::LookupSymbol(property)));
1386 return Handle<JSObject>(JSObject::cast(function->prototype())); 1385 return Handle<JSObject>(JSObject::cast(function->prototype()));
1387 } 1386 }
1388 1387
1389 1388
1390 static void InstallCustomCallGenerator(Handle<JSObject> holder, 1389 static void InstallBuiltinFunctionId(Handle<JSObject> holder,
1391 const char* function_name, 1390 const char* function_name,
1392 int id) { 1391 BuiltinFunctionId id) {
1393 Handle<String> name = Factory::LookupAsciiSymbol(function_name); 1392 Handle<String> name = Factory::LookupAsciiSymbol(function_name);
1394 Object* function_object = holder->GetProperty(*name)->ToObjectUnchecked(); 1393 Object* function_object = holder->GetProperty(*name)->ToObjectUnchecked();
1395 Handle<JSFunction> function(JSFunction::cast(function_object)); 1394 Handle<JSFunction> function(JSFunction::cast(function_object));
1396 function->shared()->set_function_data(Smi::FromInt(id)); 1395 function->shared()->set_function_data(Smi::FromInt(id));
1397 } 1396 }
1398 1397
1399 1398
1400 void Genesis::InstallCustomCallGenerators() { 1399 void Genesis::InstallBuiltinFunctionIds() {
1401 HandleScope scope; 1400 HandleScope scope;
1402 #define INSTALL_CALL_GENERATOR(holder_expr, fun_name, name) \ 1401 #define INSTALL_BUILTIN_ID(holder_expr, fun_name, name) \
1403 { \ 1402 { \
1404 Handle<JSObject> holder = ResolveCustomCallGeneratorHolder( \ 1403 Handle<JSObject> holder = ResolveBuiltinIdHolder( \
1405 global_context(), #holder_expr); \ 1404 global_context(), #holder_expr); \
1406 const int id = CallStubCompiler::k##name##CallGenerator; \ 1405 BuiltinFunctionId id = k##name; \
1407 InstallCustomCallGenerator(holder, #fun_name, id); \ 1406 InstallBuiltinFunctionId(holder, #fun_name, id); \
1408 } 1407 }
1409 CUSTOM_CALL_IC_GENERATORS(INSTALL_CALL_GENERATOR) 1408 FUNCTIONS_WITH_ID_LIST(INSTALL_BUILTIN_ID)
1410 #undef INSTALL_CALL_GENERATOR 1409 #undef INSTALL_BUILTIN_ID
1411 } 1410 }
1412 1411
1413 1412
1414 // Do not forget to update macros.py with named constant 1413 // Do not forget to update macros.py with named constant
1415 // of cache id. 1414 // of cache id.
1416 #define JSFUNCTION_RESULT_CACHE_LIST(F) \ 1415 #define JSFUNCTION_RESULT_CACHE_LIST(F) \
1417 F(16, global_context()->regexp_function()) 1416 F(16, global_context()->regexp_function())
1418 1417
1419 1418
1420 static FixedArray* CreateCache(int size, JSFunction* factory) { 1419 static FixedArray* CreateCache(int size, JSFunction* factory) {
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1883 } 1882 }
1884 1883
1885 1884
1886 // Restore statics that are thread local. 1885 // Restore statics that are thread local.
1887 char* BootstrapperActive::RestoreState(char* from) { 1886 char* BootstrapperActive::RestoreState(char* from) {
1888 nesting_ = *reinterpret_cast<int*>(from); 1887 nesting_ = *reinterpret_cast<int*>(from);
1889 return from + sizeof(nesting_); 1888 return from + sizeof(nesting_);
1890 } 1889 }
1891 1890
1892 } } // namespace v8::internal 1891 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.cc ('k') | src/hydrogen.cc » ('j') | src/objects-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698