| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 5078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5089 } | 5089 } |
| 5090 return; | 5090 return; |
| 5091 } else { | 5091 } else { |
| 5092 call = PreProcessCall(new(zone()) HInvokeFunction(context, | 5092 call = PreProcessCall(new(zone()) HInvokeFunction(context, |
| 5093 function, | 5093 function, |
| 5094 argument_count)); | 5094 argument_count)); |
| 5095 Drop(1); // The function. | 5095 Drop(1); // The function. |
| 5096 } | 5096 } |
| 5097 | 5097 |
| 5098 } else { | 5098 } else { |
| 5099 CHECK_ALIVE(VisitArgument(expr->expression())); | 5099 CHECK_ALIVE(VisitForValue(expr->expression())); |
| 5100 HValue* function = Top(); |
| 5100 HValue* context = environment()->LookupContext(); | 5101 HValue* context = environment()->LookupContext(); |
| 5101 HGlobalObject* global_object = new(zone()) HGlobalObject(context); | 5102 HGlobalObject* global_object = new(zone()) HGlobalObject(context); |
| 5102 HGlobalReceiver* receiver = new(zone()) HGlobalReceiver(global_object); | 5103 HGlobalReceiver* receiver = new(zone()) HGlobalReceiver(global_object); |
| 5103 AddInstruction(global_object); | 5104 AddInstruction(global_object); |
| 5104 AddInstruction(receiver); | 5105 AddInstruction(receiver); |
| 5105 PushAndAdd(new(zone()) HPushArgument(receiver)); | 5106 PushAndAdd(new(zone()) HPushArgument(receiver)); |
| 5106 CHECK_ALIVE(VisitArgumentList(expr->arguments())); | 5107 CHECK_ALIVE(VisitArgumentList(expr->arguments())); |
| 5107 | 5108 |
| 5108 // The function to call is treated as an argument to the call function | 5109 call = new(zone()) HCallFunction(context, function, argument_count); |
| 5109 // stub. | |
| 5110 call = new(zone()) HCallFunction(context, argument_count + 1); | |
| 5111 Drop(argument_count + 1); | 5110 Drop(argument_count + 1); |
| 5112 } | 5111 } |
| 5113 } | 5112 } |
| 5114 | 5113 |
| 5115 call->set_position(expr->position()); | 5114 call->set_position(expr->position()); |
| 5116 return ast_context()->ReturnInstruction(call, expr->id()); | 5115 return ast_context()->ReturnInstruction(call, expr->id()); |
| 5117 } | 5116 } |
| 5118 | 5117 |
| 5119 | 5118 |
| 5120 void HGraphBuilder::VisitCallNew(CallNew* expr) { | 5119 void HGraphBuilder::VisitCallNew(CallNew* expr) { |
| (...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6322 // Fast call for custom callbacks. | 6321 // Fast call for custom callbacks. |
| 6323 void HGraphBuilder::GenerateCallFunction(CallRuntime* call) { | 6322 void HGraphBuilder::GenerateCallFunction(CallRuntime* call) { |
| 6324 // 1 ~ The function to call is not itself an argument to the call. | 6323 // 1 ~ The function to call is not itself an argument to the call. |
| 6325 int arg_count = call->arguments()->length() - 1; | 6324 int arg_count = call->arguments()->length() - 1; |
| 6326 ASSERT(arg_count >= 1); // There's always at least a receiver. | 6325 ASSERT(arg_count >= 1); // There's always at least a receiver. |
| 6327 | 6326 |
| 6328 for (int i = 0; i < arg_count; ++i) { | 6327 for (int i = 0; i < arg_count; ++i) { |
| 6329 CHECK_ALIVE(VisitArgument(call->arguments()->at(i))); | 6328 CHECK_ALIVE(VisitArgument(call->arguments()->at(i))); |
| 6330 } | 6329 } |
| 6331 CHECK_ALIVE(VisitForValue(call->arguments()->last())); | 6330 CHECK_ALIVE(VisitForValue(call->arguments()->last())); |
| 6331 |
| 6332 HValue* function = Pop(); | 6332 HValue* function = Pop(); |
| 6333 HValue* context = environment()->LookupContext(); | 6333 HValue* context = environment()->LookupContext(); |
| 6334 HInvokeFunction* result = | 6334 |
| 6335 new(zone()) HInvokeFunction(context, function, arg_count); | 6335 // Branch for function proxies, or other non-functions. |
| 6336 HHasInstanceTypeAndBranch* typecheck = |
| 6337 new(zone()) HHasInstanceTypeAndBranch(function, JS_FUNCTION_TYPE); |
| 6338 HBasicBlock* if_jsfunction = graph()->CreateBasicBlock(); |
| 6339 HBasicBlock* if_nonfunction = graph()->CreateBasicBlock(); |
| 6340 HBasicBlock* join = graph()->CreateBasicBlock(); |
| 6341 typecheck->SetSuccessorAt(0, if_jsfunction); |
| 6342 typecheck->SetSuccessorAt(1, if_nonfunction); |
| 6343 current_block()->Finish(typecheck); |
| 6344 |
| 6345 set_current_block(if_jsfunction); |
| 6346 HInstruction* invoke_result = AddInstruction( |
| 6347 new(zone()) HInvokeFunction(context, function, arg_count)); |
| 6336 Drop(arg_count); | 6348 Drop(arg_count); |
| 6337 return ast_context()->ReturnInstruction(result, call->id()); | 6349 Push(invoke_result); |
| 6350 if_jsfunction->Goto(join); |
| 6351 |
| 6352 set_current_block(if_nonfunction); |
| 6353 HInstruction* call_result = AddInstruction( |
| 6354 new(zone()) HCallFunction(context, function, arg_count)); |
| 6355 Drop(arg_count); |
| 6356 Push(call_result); |
| 6357 if_nonfunction->Goto(join); |
| 6358 |
| 6359 set_current_block(join); |
| 6360 join->SetJoinId(call->id()); |
| 6361 return ast_context()->ReturnValue(Pop()); |
| 6338 } | 6362 } |
| 6339 | 6363 |
| 6340 | 6364 |
| 6341 // Fast call to math functions. | 6365 // Fast call to math functions. |
| 6342 void HGraphBuilder::GenerateMathPow(CallRuntime* call) { | 6366 void HGraphBuilder::GenerateMathPow(CallRuntime* call) { |
| 6343 ASSERT_EQ(2, call->arguments()->length()); | 6367 ASSERT_EQ(2, call->arguments()->length()); |
| 6344 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | 6368 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
| 6345 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); | 6369 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); |
| 6346 HValue* right = Pop(); | 6370 HValue* right = Pop(); |
| 6347 HValue* left = Pop(); | 6371 HValue* left = Pop(); |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6937 } | 6961 } |
| 6938 } | 6962 } |
| 6939 | 6963 |
| 6940 #ifdef DEBUG | 6964 #ifdef DEBUG |
| 6941 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 6965 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
| 6942 if (allocator_ != NULL) allocator_->Verify(); | 6966 if (allocator_ != NULL) allocator_->Verify(); |
| 6943 #endif | 6967 #endif |
| 6944 } | 6968 } |
| 6945 | 6969 |
| 6946 } } // namespace v8::internal | 6970 } } // namespace v8::internal |
| OLD | NEW |