OLD | NEW |
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 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1337 } | 1337 } |
1338 | 1338 |
1339 #ifdef DEBUG | 1339 #ifdef DEBUG |
1340 builtins->Verify(); | 1340 builtins->Verify(); |
1341 #endif | 1341 #endif |
1342 | 1342 |
1343 return true; | 1343 return true; |
1344 } | 1344 } |
1345 | 1345 |
1346 | 1346 |
1347 static void InstallCustomCallGenerator( | 1347 static Handle<JSObject> ResolveCustomCallGeneratorHolder( |
1348 Handle<JSFunction> holder_function, | 1348 Handle<Context> global_context, |
1349 CallStubCompiler::CustomGeneratorOwner owner_flag, | 1349 const char* holder_expr) { |
1350 const char* function_name, | 1350 Handle<GlobalObject> global(global_context->global()); |
1351 int id) { | 1351 const char* period_pos = strchr(holder_expr, '.'); |
1352 Handle<JSObject> owner; | 1352 if (period_pos == NULL) { |
1353 if (owner_flag == CallStubCompiler::FUNCTION) { | 1353 return Handle<JSObject>::cast( |
1354 owner = Handle<JSObject>::cast(holder_function); | 1354 GetProperty(global, Factory::LookupAsciiSymbol(holder_expr))); |
1355 } else { | |
1356 ASSERT(owner_flag == CallStubCompiler::INSTANCE_PROTOTYPE); | |
1357 owner = Handle<JSObject>( | |
1358 JSObject::cast(holder_function->instance_prototype())); | |
1359 } | 1355 } |
| 1356 ASSERT_EQ(".prototype", period_pos); |
| 1357 Vector<const char> property(holder_expr, period_pos - holder_expr); |
| 1358 Handle<JSFunction> function = Handle<JSFunction>::cast( |
| 1359 GetProperty(global, Factory::LookupSymbol(property))); |
| 1360 return Handle<JSObject>(JSObject::cast(function->prototype())); |
| 1361 } |
| 1362 |
| 1363 |
| 1364 static void InstallCustomCallGenerator(Handle<JSObject> holder, |
| 1365 const char* function_name, |
| 1366 int id) { |
1360 Handle<String> name = Factory::LookupAsciiSymbol(function_name); | 1367 Handle<String> name = Factory::LookupAsciiSymbol(function_name); |
1361 Handle<JSFunction> function(JSFunction::cast(owner->GetProperty(*name))); | 1368 Handle<JSFunction> function(JSFunction::cast(holder->GetProperty(*name))); |
1362 function->shared()->set_function_data(Smi::FromInt(id)); | 1369 function->shared()->set_function_data(Smi::FromInt(id)); |
1363 } | 1370 } |
1364 | 1371 |
1365 | 1372 |
1366 void Genesis::InstallCustomCallGenerators() { | 1373 void Genesis::InstallCustomCallGenerators() { |
1367 HandleScope scope; | 1374 HandleScope scope; |
1368 #define INSTALL_CALL_GENERATOR(holder_fun, owner_flag, fun_name, name) \ | 1375 #define INSTALL_CALL_GENERATOR(holder_expr, fun_name, name) \ |
1369 { \ | 1376 { \ |
1370 Handle<JSFunction> holder(global_context()->holder_fun##_function()); \ | 1377 Handle<JSObject> holder = ResolveCustomCallGeneratorHolder( \ |
1371 const int id = CallStubCompiler::k##name##CallGenerator; \ | 1378 global_context(), #holder_expr); \ |
1372 InstallCustomCallGenerator(holder, CallStubCompiler::owner_flag, \ | 1379 const int id = CallStubCompiler::k##name##CallGenerator; \ |
1373 #fun_name, id); \ | 1380 InstallCustomCallGenerator(holder, #fun_name, id); \ |
1374 } | 1381 } |
1375 CUSTOM_CALL_IC_GENERATORS(INSTALL_CALL_GENERATOR) | 1382 CUSTOM_CALL_IC_GENERATORS(INSTALL_CALL_GENERATOR) |
1376 #undef INSTALL_CALL_GENERATOR | 1383 #undef INSTALL_CALL_GENERATOR |
1377 } | 1384 } |
1378 | 1385 |
1379 | 1386 |
1380 // Do not forget to update macros.py with named constant | 1387 // Do not forget to update macros.py with named constant |
1381 // of cache id. | 1388 // of cache id. |
1382 #define JSFUNCTION_RESULT_CACHE_LIST(F) \ | 1389 #define JSFUNCTION_RESULT_CACHE_LIST(F) \ |
1383 F(16, global_context()->regexp_function()) | 1390 F(16, global_context()->regexp_function()) |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1841 } | 1848 } |
1842 | 1849 |
1843 | 1850 |
1844 // Restore statics that are thread local. | 1851 // Restore statics that are thread local. |
1845 char* BootstrapperActive::RestoreState(char* from) { | 1852 char* BootstrapperActive::RestoreState(char* from) { |
1846 nesting_ = *reinterpret_cast<int*>(from); | 1853 nesting_ = *reinterpret_cast<int*>(from); |
1847 return from + sizeof(nesting_); | 1854 return from + sizeof(nesting_); |
1848 } | 1855 } |
1849 | 1856 |
1850 } } // namespace v8::internal | 1857 } } // namespace v8::internal |
OLD | NEW |