OLD | NEW |
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 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1245 __ Call(construct_builtin, RelocInfo::CONSTRUCT_CALL); | 1245 __ Call(construct_builtin, RelocInfo::CONSTRUCT_CALL); |
1246 | 1246 |
1247 // Replace function on TOS with result in rax, or pop it. | 1247 // Replace function on TOS with result in rax, or pop it. |
1248 DropAndMove(expr->context(), rax); | 1248 DropAndMove(expr->context(), rax); |
1249 } | 1249 } |
1250 | 1250 |
1251 | 1251 |
1252 void FastCodeGenerator::VisitCallRuntime(CallRuntime* expr) { | 1252 void FastCodeGenerator::VisitCallRuntime(CallRuntime* expr) { |
1253 Comment cmnt(masm_, "[ CallRuntime"); | 1253 Comment cmnt(masm_, "[ CallRuntime"); |
1254 ZoneList<Expression*>* args = expr->arguments(); | 1254 ZoneList<Expression*>* args = expr->arguments(); |
1255 Runtime::Function* function = expr->function(); | |
1256 | 1255 |
1257 ASSERT(function != NULL); | 1256 if (expr->is_jsruntime()) { |
| 1257 // Prepare for calling JS runtime function. |
| 1258 __ Push(expr->name()); |
| 1259 __ movq(rax, CodeGenerator::GlobalObject()); |
| 1260 __ push(FieldOperand(rax, GlobalObject::kBuiltinsOffset)); |
| 1261 } |
1258 | 1262 |
1259 // Push the arguments ("left-to-right"). | 1263 // Push the arguments ("left-to-right"). |
1260 int arg_count = args->length(); | 1264 int arg_count = args->length(); |
1261 for (int i = 0; i < arg_count; i++) { | 1265 for (int i = 0; i < arg_count; i++) { |
1262 Visit(args->at(i)); | 1266 Visit(args->at(i)); |
1263 ASSERT_EQ(Expression::kValue, args->at(i)->context()); | 1267 ASSERT_EQ(Expression::kValue, args->at(i)->context()); |
1264 } | 1268 } |
1265 | 1269 |
1266 __ CallRuntime(function, arg_count); | 1270 if (expr->is_jsruntime()) { |
1267 Move(expr->context(), rax); | 1271 // Call the JS runtime function. |
| 1272 Handle<Code> ic = CodeGenerator::ComputeCallInitialize(arg_count, |
| 1273 NOT_IN_LOOP); |
| 1274 __ call(ic, RelocInfo::CODE_TARGET); |
| 1275 // Restore context register. |
| 1276 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
| 1277 // Discard the function left on TOS. |
| 1278 DropAndMove(expr->context(), rax); |
| 1279 } else { |
| 1280 __ CallRuntime(expr->function(), arg_count); |
| 1281 Move(expr->context(), rax); |
| 1282 } |
1268 } | 1283 } |
1269 | 1284 |
1270 void FastCodeGenerator::VisitCountOperation(CountOperation* expr) { | 1285 void FastCodeGenerator::VisitCountOperation(CountOperation* expr) { |
1271 Comment cmnt(masm_, "[ CountOperation"); | 1286 Comment cmnt(masm_, "[ CountOperation"); |
1272 VariableProxy* proxy = expr->expression()->AsVariableProxy(); | 1287 VariableProxy* proxy = expr->expression()->AsVariableProxy(); |
1273 ASSERT(proxy->AsVariable() != NULL); | 1288 ASSERT(proxy->AsVariable() != NULL); |
1274 ASSERT(proxy->AsVariable()->is_global()); | 1289 ASSERT(proxy->AsVariable()->is_global()); |
1275 | 1290 |
1276 Visit(proxy); | 1291 Visit(proxy); |
1277 __ InvokeBuiltin(Builtins::TO_NUMBER, CALL_FUNCTION); | 1292 __ InvokeBuiltin(Builtins::TO_NUMBER, CALL_FUNCTION); |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1666 true_label_ = saved_true; | 1681 true_label_ = saved_true; |
1667 false_label_ = saved_false; | 1682 false_label_ = saved_false; |
1668 // Convert current context to test context: End post-test code. | 1683 // Convert current context to test context: End post-test code. |
1669 } | 1684 } |
1670 | 1685 |
1671 | 1686 |
1672 #undef __ | 1687 #undef __ |
1673 | 1688 |
1674 | 1689 |
1675 } } // namespace v8::internal | 1690 } } // namespace v8::internal |
OLD | NEW |