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

Side by Side Diff: src/bootstrapper.cc

Issue 1981002: Refactored custom call IC generators: (Closed)
Patch Set: Review fixes. Created 10 years, 7 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/assembler.cc ('k') | src/ia32/stub-cache-ia32.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 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 19 matching lines...) Expand all
30 #include "accessors.h" 30 #include "accessors.h"
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 "snapshot.h" 39 #include "snapshot.h"
40 #include "stub-cache.h"
40 41
41 namespace v8 { 42 namespace v8 {
42 namespace internal { 43 namespace internal {
43 44
44 // A SourceCodeCache uses a FixedArray to store pairs of 45 // A SourceCodeCache uses a FixedArray to store pairs of
45 // (AsciiString*, JSFunction*), mapping names of native code files 46 // (AsciiString*, JSFunction*), mapping names of native code files
46 // (runtime.js, etc.) to precompiled functions. Instead of mapping 47 // (runtime.js, etc.) to precompiled functions. Instead of mapping
47 // names to functions it might make sense to let the JS2C tool 48 // names to functions it might make sense to let the JS2C tool
48 // generate an index for each native JS file. 49 // generate an index for each native JS file.
49 class SourceCodeCache BASE_EMBEDDED { 50 class SourceCodeCache BASE_EMBEDDED {
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 // templates passed through the API. The inner global from the snapshot is 222 // templates passed through the API. The inner global from the snapshot is
222 // detached from the other objects in the snapshot. 223 // detached from the other objects in the snapshot.
223 void HookUpInnerGlobal(Handle<GlobalObject> inner_global); 224 void HookUpInnerGlobal(Handle<GlobalObject> inner_global);
224 // New context initialization. Used for creating a context from scratch. 225 // New context initialization. Used for creating a context from scratch.
225 void InitializeGlobal(Handle<GlobalObject> inner_global, 226 void InitializeGlobal(Handle<GlobalObject> inner_global,
226 Handle<JSFunction> empty_function); 227 Handle<JSFunction> empty_function);
227 // Installs the contents of the native .js files on the global objects. 228 // Installs the contents of the native .js files on the global objects.
228 // Used for creating a context from scratch. 229 // Used for creating a context from scratch.
229 void InstallNativeFunctions(); 230 void InstallNativeFunctions();
230 bool InstallNatives(); 231 bool InstallNatives();
232 void InstallCustomCallGenerators();
231 void InstallJSFunctionResultCaches(); 233 void InstallJSFunctionResultCaches();
232 // Used both for deserialized and from-scratch contexts to add the extensions 234 // Used both for deserialized and from-scratch contexts to add the extensions
233 // provided. 235 // provided.
234 static bool InstallExtensions(Handle<Context> global_context, 236 static bool InstallExtensions(Handle<Context> global_context,
235 v8::ExtensionConfiguration* extensions); 237 v8::ExtensionConfiguration* extensions);
236 static bool InstallExtension(const char* name); 238 static bool InstallExtension(const char* name);
237 static bool InstallExtension(v8::RegisteredExtension* current); 239 static bool InstallExtension(v8::RegisteredExtension* current);
238 static void InstallSpecialObjects(Handle<Context> global_context); 240 static void InstallSpecialObjects(Handle<Context> global_context);
239 bool InstallJSBuiltins(Handle<JSBuiltinsObject> builtins); 241 bool InstallJSBuiltins(Handle<JSBuiltinsObject> builtins);
240 bool ConfigureApiObject(Handle<JSObject> object, 242 bool ConfigureApiObject(Handle<JSObject> object,
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 Vector<const char> name = Natives::GetScriptName(i); 1224 Vector<const char> name = Natives::GetScriptName(i);
1223 if (!CompileBuiltin(i)) return false; 1225 if (!CompileBuiltin(i)) return false;
1224 // TODO(ager): We really only need to install the JS builtin 1226 // TODO(ager): We really only need to install the JS builtin
1225 // functions on the builtins object after compiling and running 1227 // functions on the builtins object after compiling and running
1226 // runtime.js. 1228 // runtime.js.
1227 if (!InstallJSBuiltins(builtins)) return false; 1229 if (!InstallJSBuiltins(builtins)) return false;
1228 } 1230 }
1229 1231
1230 InstallNativeFunctions(); 1232 InstallNativeFunctions();
1231 1233
1234 InstallCustomCallGenerators();
1235
1232 // Install Function.prototype.call and apply. 1236 // Install Function.prototype.call and apply.
1233 { Handle<String> key = Factory::function_class_symbol(); 1237 { Handle<String> key = Factory::function_class_symbol();
1234 Handle<JSFunction> function = 1238 Handle<JSFunction> function =
1235 Handle<JSFunction>::cast(GetProperty(Top::global(), key)); 1239 Handle<JSFunction>::cast(GetProperty(Top::global(), key));
1236 Handle<JSObject> proto = 1240 Handle<JSObject> proto =
1237 Handle<JSObject>(JSObject::cast(function->instance_prototype())); 1241 Handle<JSObject>(JSObject::cast(function->instance_prototype()));
1238 1242
1239 // Install the call and the apply functions. 1243 // Install the call and the apply functions.
1240 Handle<JSFunction> call = 1244 Handle<JSFunction> call =
1241 InstallFunction(proto, "call", JS_OBJECT_TYPE, JSObject::kHeaderSize, 1245 InstallFunction(proto, "call", JS_OBJECT_TYPE, JSObject::kHeaderSize,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 } 1323 }
1320 1324
1321 #ifdef DEBUG 1325 #ifdef DEBUG
1322 builtins->Verify(); 1326 builtins->Verify();
1323 #endif 1327 #endif
1324 1328
1325 return true; 1329 return true;
1326 } 1330 }
1327 1331
1328 1332
1333 static void InstallCustomCallGenerator(Handle<JSFunction> holder_function,
1334 const char* function_name,
1335 int id) {
1336 Handle<JSObject> proto(JSObject::cast(holder_function->instance_prototype()));
1337 Handle<String> name = Factory::LookupAsciiSymbol(function_name);
1338 Handle<JSFunction> function(JSFunction::cast(proto->GetProperty(*name)));
1339 function->shared()->set_function_data(Smi::FromInt(id));
1340 }
1341
1342
1343 void Genesis::InstallCustomCallGenerators() {
1344 HandleScope scope;
1345 #define INSTALL_CALL_GENERATOR(holder_fun, fun_name, name) \
1346 { \
1347 Handle<JSFunction> holder(global_context()->holder_fun##_function()); \
1348 const int id = CallStubCompiler::k##name##CallGenerator; \
1349 InstallCustomCallGenerator(holder, #fun_name, id); \
1350 }
1351 CUSTOM_CALL_IC_GENERATORS(INSTALL_CALL_GENERATOR)
1352 #undef INSTALL_CALL_GENERATOR
1353 }
1354
1355
1329 // Do not forget to update macros.py with named constant 1356 // Do not forget to update macros.py with named constant
1330 // of cache id. 1357 // of cache id.
1331 #define JSFUNCTION_RESULT_CACHE_LIST(F) \ 1358 #define JSFUNCTION_RESULT_CACHE_LIST(F) \
1332 F(16, global_context()->regexp_function()) 1359 F(16, global_context()->regexp_function())
1333 1360
1334 1361
1335 static FixedArray* CreateCache(int size, JSFunction* factory) { 1362 static FixedArray* CreateCache(int size, JSFunction* factory) {
1336 // Caches are supposed to live for a long time, allocate in old space. 1363 // Caches are supposed to live for a long time, allocate in old space.
1337 int array_size = JSFunctionResultCache::kEntriesIndex + 2 * size; 1364 int array_size = JSFunctionResultCache::kEntriesIndex + 2 * size;
1338 // Cannot use cast as object is not fully initialized yet. 1365 // Cannot use cast as object is not fully initialized yet.
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
1779 } 1806 }
1780 1807
1781 1808
1782 // Restore statics that are thread local. 1809 // Restore statics that are thread local.
1783 char* BootstrapperActive::RestoreState(char* from) { 1810 char* BootstrapperActive::RestoreState(char* from) {
1784 nesting_ = *reinterpret_cast<int*>(from); 1811 nesting_ = *reinterpret_cast<int*>(from);
1785 return from + sizeof(nesting_); 1812 return from + sizeof(nesting_);
1786 } 1813 }
1787 1814
1788 } } // namespace v8::internal 1815 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/assembler.cc ('k') | src/ia32/stub-cache-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698