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

Side by Side Diff: src/runtime.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/objects-inl.h ('k') | src/serialize.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-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after
1318 HandleScope scope; 1318 HandleScope scope;
1319 ASSERT(args.length() == 1); 1319 ASSERT(args.length() == 1);
1320 CONVERT_ARG_CHECKED(JSArray, prototype, 0); 1320 CONVERT_ARG_CHECKED(JSArray, prototype, 0);
1321 // This is necessary to enable fast checks for absence of elements 1321 // This is necessary to enable fast checks for absence of elements
1322 // on Array.prototype and below. 1322 // on Array.prototype and below.
1323 prototype->set_elements(Heap::empty_fixed_array()); 1323 prototype->set_elements(Heap::empty_fixed_array());
1324 return Smi::FromInt(0); 1324 return Smi::FromInt(0);
1325 } 1325 }
1326 1326
1327 1327
1328 static void SetCustomCallGenerator(Handle<JSFunction> function,
1329 ExternalReference* generator) {
1330 if (function->shared()->function_data()->IsUndefined()) {
1331 function->shared()->set_function_data(*FromCData(generator->address()));
1332 }
1333 }
1334
1335
1336 static Handle<JSFunction> InstallBuiltin(Handle<JSObject> holder, 1328 static Handle<JSFunction> InstallBuiltin(Handle<JSObject> holder,
1337 const char* name, 1329 const char* name,
1338 Builtins::Name builtin_name, 1330 Builtins::Name builtin_name) {
1339 ExternalReference* generator = NULL) {
1340 Handle<String> key = Factory::LookupAsciiSymbol(name); 1331 Handle<String> key = Factory::LookupAsciiSymbol(name);
1341 Handle<Code> code(Builtins::builtin(builtin_name)); 1332 Handle<Code> code(Builtins::builtin(builtin_name));
1342 Handle<JSFunction> optimized = Factory::NewFunction(key, 1333 Handle<JSFunction> optimized = Factory::NewFunction(key,
1343 JS_OBJECT_TYPE, 1334 JS_OBJECT_TYPE,
1344 JSObject::kHeaderSize, 1335 JSObject::kHeaderSize,
1345 code, 1336 code,
1346 false); 1337 false);
1347 optimized->shared()->DontAdaptArguments(); 1338 optimized->shared()->DontAdaptArguments();
1348 if (generator != NULL) {
1349 SetCustomCallGenerator(optimized, generator);
1350 }
1351 SetProperty(holder, key, optimized, NONE); 1339 SetProperty(holder, key, optimized, NONE);
1352 return optimized; 1340 return optimized;
1353 } 1341 }
1354 1342
1355 1343
1356 Object* CompileArrayPushCall(CallStubCompiler* compiler,
1357 Object* object,
1358 JSObject* holder,
1359 JSFunction* function,
1360 String* name,
1361 StubCompiler::CheckType check) {
1362 return compiler->CompileArrayPushCall(object, holder, function, name, check);
1363 }
1364
1365
1366 Object* CompileArrayPopCall(CallStubCompiler* compiler,
1367 Object* object,
1368 JSObject* holder,
1369 JSFunction* function,
1370 String* name,
1371 StubCompiler::CheckType check) {
1372 return compiler->CompileArrayPopCall(object, holder, function, name, check);
1373 }
1374
1375
1376 static Object* Runtime_SpecialArrayFunctions(Arguments args) { 1344 static Object* Runtime_SpecialArrayFunctions(Arguments args) {
1377 HandleScope scope; 1345 HandleScope scope;
1378 ASSERT(args.length() == 1); 1346 ASSERT(args.length() == 1);
1379 CONVERT_ARG_CHECKED(JSObject, holder, 0); 1347 CONVERT_ARG_CHECKED(JSObject, holder, 0);
1380 1348
1381 ExternalReference pop = ExternalReference::compile_array_pop_call(); 1349 InstallBuiltin(holder, "pop", Builtins::ArrayPop);
1382 ExternalReference push = ExternalReference::compile_array_push_call(); 1350 InstallBuiltin(holder, "push", Builtins::ArrayPush);
1383
1384 InstallBuiltin(holder, "pop", Builtins::ArrayPop, &pop);
1385 InstallBuiltin(holder, "push", Builtins::ArrayPush, &push);
1386 InstallBuiltin(holder, "shift", Builtins::ArrayShift); 1351 InstallBuiltin(holder, "shift", Builtins::ArrayShift);
1387 InstallBuiltin(holder, "unshift", Builtins::ArrayUnshift); 1352 InstallBuiltin(holder, "unshift", Builtins::ArrayUnshift);
1388 InstallBuiltin(holder, "slice", Builtins::ArraySlice); 1353 InstallBuiltin(holder, "slice", Builtins::ArraySlice);
1389 InstallBuiltin(holder, "splice", Builtins::ArraySplice); 1354 InstallBuiltin(holder, "splice", Builtins::ArraySplice);
1390 InstallBuiltin(holder, "concat", Builtins::ArrayConcat); 1355 InstallBuiltin(holder, "concat", Builtins::ArrayConcat);
1391 1356
1392 return *holder; 1357 return *holder;
1393 } 1358 }
1394 1359
1395 1360
(...skipping 8868 matching lines...) Expand 10 before | Expand all | Expand 10 after
10264 } else { 10229 } else {
10265 // Handle last resort GC and make sure to allow future allocations 10230 // Handle last resort GC and make sure to allow future allocations
10266 // to grow the heap without causing GCs (if possible). 10231 // to grow the heap without causing GCs (if possible).
10267 Counters::gc_last_resort_from_js.Increment(); 10232 Counters::gc_last_resort_from_js.Increment();
10268 Heap::CollectAllGarbage(false); 10233 Heap::CollectAllGarbage(false);
10269 } 10234 }
10270 } 10235 }
10271 10236
10272 10237
10273 } } // namespace v8::internal 10238 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | src/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698