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

Side by Side Diff: src/ia32/fast-codegen-ia32.cc

Issue 437081: Added fast compiler support for calling JS runtime functions.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« no previous file with comments | « src/compiler.cc ('k') | src/x64/fast-codegen-x64.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 2009 the V8 project authors. All rights reserved. 1 // Copyright 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 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 __ call(construct_builtin, RelocInfo::CONSTRUCT_CALL); 1241 __ call(construct_builtin, RelocInfo::CONSTRUCT_CALL);
1242 1242
1243 // Replace function on TOS with result in eax, or pop it. 1243 // Replace function on TOS with result in eax, or pop it.
1244 DropAndMove(expr->context(), eax); 1244 DropAndMove(expr->context(), eax);
1245 } 1245 }
1246 1246
1247 1247
1248 void FastCodeGenerator::VisitCallRuntime(CallRuntime* expr) { 1248 void FastCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
1249 Comment cmnt(masm_, "[ CallRuntime"); 1249 Comment cmnt(masm_, "[ CallRuntime");
1250 ZoneList<Expression*>* args = expr->arguments(); 1250 ZoneList<Expression*>* args = expr->arguments();
1251 Runtime::Function* function = expr->function();
1252 1251
1253 ASSERT(function != NULL); 1252 if (expr->is_jsruntime()) {
1253 // Prepare for calling JS runtime function.
1254 __ push(Immediate(expr->name()));
1255 __ mov(eax, CodeGenerator::GlobalObject());
1256 __ push(FieldOperand(eax, GlobalObject::kBuiltinsOffset));
1257 }
1254 1258
1255 // Push the arguments ("left-to-right"). 1259 // Push the arguments ("left-to-right").
1256 int arg_count = args->length(); 1260 int arg_count = args->length();
1257 for (int i = 0; i < arg_count; i++) { 1261 for (int i = 0; i < arg_count; i++) {
1258 Visit(args->at(i)); 1262 Visit(args->at(i));
1259 ASSERT_EQ(Expression::kValue, args->at(i)->context()); 1263 ASSERT_EQ(Expression::kValue, args->at(i)->context());
1260 } 1264 }
1261 1265
1262 __ CallRuntime(function, arg_count); 1266 if (expr->is_jsruntime()) {
1263 Move(expr->context(), eax); 1267 // Call the JS runtime function.
1268 Handle<Code> ic = CodeGenerator::ComputeCallInitialize(arg_count,
1269 NOT_IN_LOOP);
1270 __ call(ic, RelocInfo::CODE_TARGET);
1271 // Restore context register.
1272 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
1273 // Discard the function left on TOS.
1274 DropAndMove(expr->context(), eax);
1275 } else {
1276 // Call the C runtime function.
1277 __ CallRuntime(expr->function(), arg_count);
1278 Move(expr->context(), eax);
1279 }
1264 } 1280 }
1265 1281
1266 1282
1267 void FastCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) { 1283 void FastCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) {
1268 switch (expr->op()) { 1284 switch (expr->op()) {
1269 case Token::VOID: { 1285 case Token::VOID: {
1270 Comment cmnt(masm_, "[ UnaryOperation (VOID)"); 1286 Comment cmnt(masm_, "[ UnaryOperation (VOID)");
1271 Visit(expr->expression()); 1287 Visit(expr->expression());
1272 ASSERT_EQ(Expression::kEffect, expr->expression()->context()); 1288 ASSERT_EQ(Expression::kEffect, expr->expression()->context());
1273 switch (expr->context()) { 1289 switch (expr->context()) {
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
1666 true_label_ = saved_true; 1682 true_label_ = saved_true;
1667 false_label_ = saved_false; 1683 false_label_ = saved_false;
1668 // Convert current context to test context: End post-test code. 1684 // Convert current context to test context: End post-test code.
1669 } 1685 }
1670 1686
1671 1687
1672 #undef __ 1688 #undef __
1673 1689
1674 1690
1675 } } // namespace v8::internal 1691 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.cc ('k') | src/x64/fast-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698