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

Side by Side Diff: src/runtime.cc

Issue 1079012: Fix pop push optimization to work with partial snapshots (correct... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 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
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 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 ASSERT(args.length() == 1); 1233 ASSERT(args.length() == 1);
1234 CONVERT_ARG_CHECKED(JSArray, prototype, 0); 1234 CONVERT_ARG_CHECKED(JSArray, prototype, 0);
1235 // This is necessary to enable fast checks for absence of elements 1235 // This is necessary to enable fast checks for absence of elements
1236 // on Array.prototype and below. 1236 // on Array.prototype and below.
1237 prototype->set_elements(Heap::empty_fixed_array()); 1237 prototype->set_elements(Heap::empty_fixed_array());
1238 return Smi::FromInt(0); 1238 return Smi::FromInt(0);
1239 } 1239 }
1240 1240
1241 1241
1242 static void SetCustomCallGenerator(Handle<JSFunction> function, 1242 static void SetCustomCallGenerator(Handle<JSFunction> function,
1243 CustomCallGenerator generator) { 1243 ExternalReference* generator) {
1244 if (function->shared()->function_data()->IsUndefined()) { 1244 if (function->shared()->function_data()->IsUndefined()) {
1245 function->shared()->set_function_data(*FromCData(generator)); 1245 function->shared()->set_function_data(*FromCData(generator->address()));
1246 } 1246 }
1247 } 1247 }
1248 1248
1249 1249
1250 static Handle<JSFunction> InstallBuiltin(Handle<JSObject> holder, 1250 static Handle<JSFunction> InstallBuiltin(Handle<JSObject> holder,
1251 const char* name, 1251 const char* name,
1252 Builtins::Name builtin_name, 1252 Builtins::Name builtin_name,
1253 CustomCallGenerator generator = NULL) { 1253 ExternalReference* generator = NULL) {
1254 Handle<String> key = Factory::LookupAsciiSymbol(name); 1254 Handle<String> key = Factory::LookupAsciiSymbol(name);
1255 Handle<Code> code(Builtins::builtin(builtin_name)); 1255 Handle<Code> code(Builtins::builtin(builtin_name));
1256 Handle<JSFunction> optimized = Factory::NewFunction(key, 1256 Handle<JSFunction> optimized = Factory::NewFunction(key,
1257 JS_OBJECT_TYPE, 1257 JS_OBJECT_TYPE,
1258 JSObject::kHeaderSize, 1258 JSObject::kHeaderSize,
1259 code, 1259 code,
1260 false); 1260 false);
1261 optimized->shared()->DontAdaptArguments(); 1261 optimized->shared()->DontAdaptArguments();
1262 if (generator != NULL) { 1262 if (generator != NULL) {
1263 SetCustomCallGenerator(optimized, generator); 1263 SetCustomCallGenerator(optimized, generator);
1264 } 1264 }
1265 SetProperty(holder, key, optimized, NONE); 1265 SetProperty(holder, key, optimized, NONE);
1266 return optimized; 1266 return optimized;
1267 } 1267 }
1268 1268
1269 1269
1270 static Object* CompileArrayPushCall(CallStubCompiler* compiler, 1270 Object* CompileArrayPushCall(CallStubCompiler* compiler,
1271 Object* object, 1271 Object* object,
1272 JSObject* holder, 1272 JSObject* holder,
1273 JSFunction* function, 1273 JSFunction* function,
1274 String* name, 1274 String* name,
1275 StubCompiler::CheckType check) { 1275 StubCompiler::CheckType check) {
1276 return compiler->CompileArrayPushCall(object, holder, function, name, check); 1276 return compiler->CompileArrayPushCall(object, holder, function, name, check);
1277 } 1277 }
1278 1278
1279 1279
1280 static Object* CompileArrayPopCall(CallStubCompiler* compiler, 1280 Object* CompileArrayPopCall(CallStubCompiler* compiler,
1281 Object* object, 1281 Object* object,
1282 JSObject* holder, 1282 JSObject* holder,
1283 JSFunction* function, 1283 JSFunction* function,
1284 String* name, 1284 String* name,
1285 StubCompiler::CheckType check) { 1285 StubCompiler::CheckType check) {
1286 return compiler->CompileArrayPopCall(object, holder, function, name, check); 1286 return compiler->CompileArrayPopCall(object, holder, function, name, check);
1287 } 1287 }
1288 1288
1289 1289
1290 static Object* Runtime_SpecialArrayFunctions(Arguments args) { 1290 static Object* Runtime_SpecialArrayFunctions(Arguments args) {
1291 HandleScope scope; 1291 HandleScope scope;
1292 ASSERT(args.length() == 1); 1292 ASSERT(args.length() == 1);
1293 CONVERT_ARG_CHECKED(JSObject, holder, 0); 1293 CONVERT_ARG_CHECKED(JSObject, holder, 0);
1294 1294
1295 InstallBuiltin(holder, "pop", Builtins::ArrayPop, CompileArrayPopCall); 1295 ExternalReference pop = ExternalReference::compile_array_pop_call();
1296 InstallBuiltin(holder, "push", Builtins::ArrayPush, CompileArrayPushCall); 1296 ExternalReference push = ExternalReference::compile_array_push_call();
1297
1298 InstallBuiltin(holder, "pop", Builtins::ArrayPop, &pop);
1299 InstallBuiltin(holder, "push", Builtins::ArrayPush, &push);
1297 InstallBuiltin(holder, "shift", Builtins::ArrayShift); 1300 InstallBuiltin(holder, "shift", Builtins::ArrayShift);
1298 InstallBuiltin(holder, "unshift", Builtins::ArrayUnshift); 1301 InstallBuiltin(holder, "unshift", Builtins::ArrayUnshift);
1299 InstallBuiltin(holder, "slice", Builtins::ArraySlice); 1302 InstallBuiltin(holder, "slice", Builtins::ArraySlice);
1300 InstallBuiltin(holder, "splice", Builtins::ArraySplice); 1303 InstallBuiltin(holder, "splice", Builtins::ArraySplice);
1301 InstallBuiltin(holder, "concat", Builtins::ArrayConcat); 1304 InstallBuiltin(holder, "concat", Builtins::ArrayConcat);
1302 1305
1303 return *holder; 1306 return *holder;
1304 } 1307 }
1305 1308
1306 1309
(...skipping 8118 matching lines...) Expand 10 before | Expand all | Expand 10 after
9425 } else { 9428 } else {
9426 // Handle last resort GC and make sure to allow future allocations 9429 // Handle last resort GC and make sure to allow future allocations
9427 // to grow the heap without causing GCs (if possible). 9430 // to grow the heap without causing GCs (if possible).
9428 Counters::gc_last_resort_from_js.Increment(); 9431 Counters::gc_last_resort_from_js.Increment();
9429 Heap::CollectAllGarbage(false); 9432 Heap::CollectAllGarbage(false);
9430 } 9433 }
9431 } 9434 }
9432 9435
9433 9436
9434 } } // namespace v8::internal 9437 } } // namespace v8::internal
OLDNEW
« src/assembler.h ('K') | « src/ia32/stub-cache-ia32.cc ('k') | src/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698