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 2155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2166 | 2166 |
2167 void HGraphBuilder::VisitForControl(Expression* expr, | 2167 void HGraphBuilder::VisitForControl(Expression* expr, |
2168 HBasicBlock* true_block, | 2168 HBasicBlock* true_block, |
2169 HBasicBlock* false_block) { | 2169 HBasicBlock* false_block) { |
2170 TestContext for_test(this, true_block, false_block); | 2170 TestContext for_test(this, true_block, false_block); |
2171 Visit(expr); | 2171 Visit(expr); |
2172 } | 2172 } |
2173 | 2173 |
2174 | 2174 |
2175 void HGraphBuilder::VisitArgument(Expression* expr) { | 2175 void HGraphBuilder::VisitArgument(Expression* expr) { |
2176 VisitForValue(expr); | 2176 VISIT_FOR_VALUE(expr); |
| 2177 Push(AddInstruction(new HPushArgument(Pop()))); |
2177 } | 2178 } |
2178 | 2179 |
2179 | 2180 |
2180 void HGraphBuilder::VisitArgumentList(ZoneList<Expression*>* arguments) { | 2181 void HGraphBuilder::VisitArgumentList(ZoneList<Expression*>* arguments) { |
2181 for (int i = 0; i < arguments->length(); i++) { | 2182 for (int i = 0; i < arguments->length(); i++) { |
2182 VisitArgument(arguments->at(i)); | 2183 VisitArgument(arguments->at(i)); |
2183 if (HasStackOverflow() || !current_subgraph_->HasExit()) return; | 2184 if (HasStackOverflow() || !current_subgraph_->HasExit()) return; |
2184 } | 2185 } |
2185 } | 2186 } |
2186 | 2187 |
2187 | 2188 |
| 2189 void HGraphBuilder::VisitExpressions(ZoneList<Expression*>* exprs) { |
| 2190 for (int i = 0; i < exprs->length(); ++i) { |
| 2191 VISIT_FOR_VALUE(exprs->at(i)); |
| 2192 } |
| 2193 } |
| 2194 |
| 2195 |
2188 HGraph* HGraphBuilder::CreateGraph(CompilationInfo* info) { | 2196 HGraph* HGraphBuilder::CreateGraph(CompilationInfo* info) { |
2189 ASSERT(current_subgraph_ == NULL); | 2197 ASSERT(current_subgraph_ == NULL); |
2190 graph_ = new HGraph(info); | 2198 graph_ = new HGraph(info); |
2191 | 2199 |
2192 { | 2200 { |
2193 HPhase phase("Block building"); | 2201 HPhase phase("Block building"); |
2194 graph_->Initialize(CreateBasicBlock(graph_->start_environment())); | 2202 graph_->Initialize(CreateBasicBlock(graph_->start_environment())); |
2195 current_subgraph_ = graph_; | 2203 current_subgraph_ = graph_; |
2196 | 2204 |
2197 Scope* scope = info->scope(); | 2205 Scope* scope = info->scope(); |
(...skipping 2133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4331 | 4339 |
4332 void HGraphBuilder::VisitCall(Call* expr) { | 4340 void HGraphBuilder::VisitCall(Call* expr) { |
4333 Expression* callee = expr->expression(); | 4341 Expression* callee = expr->expression(); |
4334 int argument_count = expr->arguments()->length() + 1; // Plus receiver. | 4342 int argument_count = expr->arguments()->length() + 1; // Plus receiver. |
4335 HCall* call = NULL; | 4343 HCall* call = NULL; |
4336 | 4344 |
4337 Property* prop = callee->AsProperty(); | 4345 Property* prop = callee->AsProperty(); |
4338 if (prop != NULL) { | 4346 if (prop != NULL) { |
4339 if (!prop->key()->IsPropertyName()) { | 4347 if (!prop->key()->IsPropertyName()) { |
4340 // Keyed function call. | 4348 // Keyed function call. |
4341 VisitArgument(prop->obj()); | 4349 VISIT_FOR_VALUE(prop->obj()); |
4342 CHECK_BAILOUT; | |
4343 | 4350 |
4344 VISIT_FOR_VALUE(prop->key()); | 4351 VISIT_FOR_VALUE(prop->key()); |
4345 // Push receiver and key like the non-optimized code generator expects it. | 4352 // Push receiver and key like the non-optimized code generator expects it. |
4346 HValue* key = Pop(); | 4353 HValue* key = Pop(); |
4347 HValue* receiver = Pop(); | 4354 HValue* receiver = Pop(); |
4348 Push(key); | 4355 Push(key); |
4349 Push(receiver); | 4356 Push(receiver); |
4350 | 4357 |
4351 VisitArgumentList(expr->arguments()); | 4358 VisitExpressions(expr->arguments()); |
4352 CHECK_BAILOUT; | 4359 CHECK_BAILOUT; |
4353 | 4360 |
4354 HContext* context = new HContext; | 4361 HContext* context = new HContext; |
4355 AddInstruction(context); | 4362 AddInstruction(context); |
4356 call = new HCallKeyed(context, key, argument_count); | 4363 call = new HCallKeyed(context, key, argument_count); |
4357 call->set_position(expr->position()); | 4364 call->set_position(expr->position()); |
4358 PreProcessCall(call); | 4365 PreProcessCall(call); |
4359 Drop(1); // Key. | 4366 Drop(1); // Key. |
4360 ast_context()->ReturnInstruction(call, expr->id()); | 4367 ast_context()->ReturnInstruction(call, expr->id()); |
4361 return; | 4368 return; |
4362 } | 4369 } |
4363 | 4370 |
4364 // Named function call. | 4371 // Named function call. |
4365 expr->RecordTypeFeedback(oracle()); | 4372 expr->RecordTypeFeedback(oracle()); |
4366 | 4373 |
4367 if (TryCallApply(expr)) return; | 4374 if (TryCallApply(expr)) return; |
4368 CHECK_BAILOUT; | 4375 CHECK_BAILOUT; |
4369 | 4376 |
4370 VisitArgument(prop->obj()); | 4377 VISIT_FOR_VALUE(prop->obj()); |
4371 CHECK_BAILOUT; | 4378 VisitExpressions(expr->arguments()); |
4372 VisitArgumentList(expr->arguments()); | |
4373 CHECK_BAILOUT; | 4379 CHECK_BAILOUT; |
4374 | 4380 |
4375 Handle<String> name = prop->key()->AsLiteral()->AsPropertyName(); | 4381 Handle<String> name = prop->key()->AsLiteral()->AsPropertyName(); |
4376 | 4382 |
4377 expr->RecordTypeFeedback(oracle()); | 4383 expr->RecordTypeFeedback(oracle()); |
4378 ZoneMapList* types = expr->GetReceiverTypes(); | 4384 ZoneMapList* types = expr->GetReceiverTypes(); |
4379 | 4385 |
4380 HValue* receiver = | 4386 HValue* receiver = |
4381 environment()->ExpressionStackAt(expr->arguments()->length()); | 4387 environment()->ExpressionStackAt(expr->arguments()->length()); |
4382 if (expr->IsMonomorphic()) { | 4388 if (expr->IsMonomorphic()) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4429 AddInstruction(context); | 4435 AddInstruction(context); |
4430 call = new HCallNamed(context, name, argument_count); | 4436 call = new HCallNamed(context, name, argument_count); |
4431 } | 4437 } |
4432 | 4438 |
4433 } else { | 4439 } else { |
4434 Variable* var = expr->expression()->AsVariableProxy()->AsVariable(); | 4440 Variable* var = expr->expression()->AsVariableProxy()->AsVariable(); |
4435 bool global_call = (var != NULL) && var->is_global() && !var->is_this(); | 4441 bool global_call = (var != NULL) && var->is_global() && !var->is_this(); |
4436 | 4442 |
4437 if (!global_call) { | 4443 if (!global_call) { |
4438 ++argument_count; | 4444 ++argument_count; |
4439 VisitArgument(expr->expression()); | 4445 VISIT_FOR_VALUE(expr->expression()); |
4440 CHECK_BAILOUT; | |
4441 } | 4446 } |
4442 | 4447 |
4443 if (global_call) { | 4448 if (global_call) { |
4444 // If there is a global property cell for the name at compile time and | 4449 // If there is a global property cell for the name at compile time and |
4445 // access check is not enabled we assume that the function will not change | 4450 // access check is not enabled we assume that the function will not change |
4446 // and generate optimized code for calling the function. | 4451 // and generate optimized code for calling the function. |
4447 CompilationInfo* info = graph()->info(); | 4452 CompilationInfo* info = graph()->info(); |
4448 bool known_global_function = info->has_global_object() && | 4453 bool known_global_function = info->has_global_object() && |
4449 !info->global_object()->IsAccessCheckNeeded() && | 4454 !info->global_object()->IsAccessCheckNeeded() && |
4450 expr->ComputeGlobalTarget(Handle<GlobalObject>(info->global_object()), | 4455 expr->ComputeGlobalTarget(Handle<GlobalObject>(info->global_object()), |
4451 var->name()); | 4456 var->name()); |
4452 if (known_global_function) { | 4457 if (known_global_function) { |
4453 // Push the global object instead of the global receiver because | 4458 // Push the global object instead of the global receiver because |
4454 // code generated by the full code generator expects it. | 4459 // code generated by the full code generator expects it. |
4455 HContext* context = new HContext; | 4460 HContext* context = new HContext; |
4456 HGlobalObject* global_object = new HGlobalObject(context); | 4461 HGlobalObject* global_object = new HGlobalObject(context); |
4457 AddInstruction(context); | 4462 AddInstruction(context); |
4458 PushAndAdd(global_object); | 4463 PushAndAdd(global_object); |
4459 VisitArgumentList(expr->arguments()); | 4464 VisitExpressions(expr->arguments()); |
4460 CHECK_BAILOUT; | 4465 CHECK_BAILOUT; |
4461 | 4466 |
4462 VISIT_FOR_VALUE(expr->expression()); | 4467 VISIT_FOR_VALUE(expr->expression()); |
4463 HValue* function = Pop(); | 4468 HValue* function = Pop(); |
4464 AddInstruction(new HCheckFunction(function, expr->target())); | 4469 AddInstruction(new HCheckFunction(function, expr->target())); |
4465 | 4470 |
4466 // Replace the global object with the global receiver. | 4471 // Replace the global object with the global receiver. |
4467 HGlobalReceiver* global_receiver = new HGlobalReceiver(global_object); | 4472 HGlobalReceiver* global_receiver = new HGlobalReceiver(global_object); |
4468 // Index of the receiver from the top of the expression stack. | 4473 // Index of the receiver from the top of the expression stack. |
4469 const int receiver_index = argument_count - 1; | 4474 const int receiver_index = argument_count - 1; |
(...skipping 17 matching lines...) Expand all Loading... |
4487 } | 4492 } |
4488 // Check for bailout, as trying to inline might fail due to bailout | 4493 // Check for bailout, as trying to inline might fail due to bailout |
4489 // during hydrogen processing. | 4494 // during hydrogen processing. |
4490 CHECK_BAILOUT; | 4495 CHECK_BAILOUT; |
4491 | 4496 |
4492 call = new HCallKnownGlobal(expr->target(), argument_count); | 4497 call = new HCallKnownGlobal(expr->target(), argument_count); |
4493 } else { | 4498 } else { |
4494 HContext* context = new HContext; | 4499 HContext* context = new HContext; |
4495 AddInstruction(context); | 4500 AddInstruction(context); |
4496 PushAndAdd(new HGlobalObject(context)); | 4501 PushAndAdd(new HGlobalObject(context)); |
4497 VisitArgumentList(expr->arguments()); | 4502 VisitExpressions(expr->arguments()); |
4498 CHECK_BAILOUT; | 4503 CHECK_BAILOUT; |
4499 | 4504 |
4500 call = new HCallGlobal(context, var->name(), argument_count); | 4505 call = new HCallGlobal(context, var->name(), argument_count); |
4501 } | 4506 } |
4502 | 4507 |
4503 } else { | 4508 } else { |
4504 HContext* context = new HContext; | 4509 HContext* context = new HContext; |
4505 HGlobalObject* global_object = new HGlobalObject(context); | 4510 HGlobalObject* global_object = new HGlobalObject(context); |
4506 AddInstruction(context); | 4511 AddInstruction(context); |
4507 AddInstruction(global_object); | 4512 AddInstruction(global_object); |
4508 PushAndAdd(new HGlobalReceiver(global_object)); | 4513 PushAndAdd(new HGlobalReceiver(global_object)); |
4509 VisitArgumentList(expr->arguments()); | 4514 VisitExpressions(expr->arguments()); |
4510 CHECK_BAILOUT; | 4515 CHECK_BAILOUT; |
4511 | 4516 |
4512 call = new HCallFunction(context, argument_count); | 4517 call = new HCallFunction(context, argument_count); |
4513 } | 4518 } |
4514 } | 4519 } |
4515 | 4520 |
4516 call->set_position(expr->position()); | 4521 call->set_position(expr->position()); |
4517 PreProcessCall(call); | 4522 PreProcessCall(call); |
4518 ast_context()->ReturnInstruction(call, expr->id()); | 4523 ast_context()->ReturnInstruction(call, expr->id()); |
4519 } | 4524 } |
4520 | 4525 |
4521 | 4526 |
4522 void HGraphBuilder::VisitCallNew(CallNew* expr) { | 4527 void HGraphBuilder::VisitCallNew(CallNew* expr) { |
4523 // The constructor function is also used as the receiver argument to the | 4528 // The constructor function is also used as the receiver argument to the |
4524 // JS construct call builtin. | 4529 // JS construct call builtin. |
4525 VisitArgument(expr->expression()); | 4530 VISIT_FOR_VALUE(expr->expression()); |
4526 CHECK_BAILOUT; | 4531 VisitExpressions(expr->arguments()); |
4527 VisitArgumentList(expr->arguments()); | |
4528 CHECK_BAILOUT; | 4532 CHECK_BAILOUT; |
4529 | 4533 |
4530 HContext* context = new HContext; | 4534 HContext* context = new HContext; |
4531 AddInstruction(context); | 4535 AddInstruction(context); |
4532 | 4536 |
4533 // The constructor is both an operand to the instruction and an argument | 4537 // The constructor is both an operand to the instruction and an argument |
4534 // to the construct call. | 4538 // to the construct call. |
4535 int arg_count = expr->arguments()->length() + 1; // Plus constructor. | 4539 int arg_count = expr->arguments()->length() + 1; // Plus constructor. |
4536 HValue* constructor = environment()->ExpressionStackAt(arg_count - 1); | 4540 HValue* constructor = environment()->ExpressionStackAt(arg_count - 1); |
4537 HCall* call = new HCallNew(context, constructor, arg_count); | 4541 HCall* call = new HCallNew(context, constructor, arg_count); |
(...skipping 12 matching lines...) Expand all Loading... |
4550 | 4554 |
4551 const HGraphBuilder::InlineFunctionGenerator | 4555 const HGraphBuilder::InlineFunctionGenerator |
4552 HGraphBuilder::kInlineFunctionGenerators[] = { | 4556 HGraphBuilder::kInlineFunctionGenerators[] = { |
4553 INLINE_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_ADDRESS) | 4557 INLINE_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_ADDRESS) |
4554 INLINE_RUNTIME_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_ADDRESS) | 4558 INLINE_RUNTIME_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_ADDRESS) |
4555 }; | 4559 }; |
4556 #undef INLINE_FUNCTION_GENERATOR_ADDRESS | 4560 #undef INLINE_FUNCTION_GENERATOR_ADDRESS |
4557 | 4561 |
4558 | 4562 |
4559 void HGraphBuilder::VisitCallRuntime(CallRuntime* expr) { | 4563 void HGraphBuilder::VisitCallRuntime(CallRuntime* expr) { |
4560 Handle<String> name = expr->name(); | 4564 if (expr->is_jsruntime()) { |
4561 if (name->IsEqualTo(CStrVector("_Log"))) { | 4565 BAILOUT("call to a JavaScript runtime function"); |
4562 ast_context()->ReturnValue(graph()->GetConstantUndefined()); | |
4563 return; | |
4564 } | 4566 } |
4565 | 4567 |
4566 Runtime::Function* function = expr->function(); | 4568 Runtime::Function* function = expr->function(); |
4567 if (expr->is_jsruntime()) { | |
4568 BAILOUT("call to a JavaScript runtime function"); | |
4569 } | |
4570 ASSERT(function != NULL); | 4569 ASSERT(function != NULL); |
4571 | |
4572 VisitArgumentList(expr->arguments()); | |
4573 CHECK_BAILOUT; | |
4574 | |
4575 int argument_count = expr->arguments()->length(); | |
4576 if (function->intrinsic_type == Runtime::INLINE) { | 4570 if (function->intrinsic_type == Runtime::INLINE) { |
4577 ASSERT(name->length() > 0); | 4571 ASSERT(expr->name()->length() > 0); |
4578 ASSERT(name->Get(0) == '_'); | 4572 ASSERT(expr->name()->Get(0) == '_'); |
4579 // Call to an inline function. | 4573 // Call to an inline function. |
4580 int lookup_index = static_cast<int>(function->function_id) - | 4574 int lookup_index = static_cast<int>(function->function_id) - |
4581 static_cast<int>(Runtime::kFirstInlineFunction); | 4575 static_cast<int>(Runtime::kFirstInlineFunction); |
4582 ASSERT(lookup_index >= 0); | 4576 ASSERT(lookup_index >= 0); |
4583 ASSERT(static_cast<size_t>(lookup_index) < | 4577 ASSERT(static_cast<size_t>(lookup_index) < |
4584 ARRAY_SIZE(kInlineFunctionGenerators)); | 4578 ARRAY_SIZE(kInlineFunctionGenerators)); |
4585 InlineFunctionGenerator generator = kInlineFunctionGenerators[lookup_index]; | 4579 InlineFunctionGenerator generator = kInlineFunctionGenerators[lookup_index]; |
4586 | 4580 |
4587 // Call the inline code generator using the pointer-to-member. | 4581 // Call the inline code generator using the pointer-to-member. |
4588 (this->*generator)(argument_count, expr->id()); | 4582 (this->*generator)(expr); |
4589 } else { | 4583 } else { |
4590 ASSERT(function->intrinsic_type == Runtime::RUNTIME); | 4584 ASSERT(function->intrinsic_type == Runtime::RUNTIME); |
4591 HCall* call = new HCallRuntime(name, expr->function(), argument_count); | 4585 VisitArgumentList(expr->arguments()); |
| 4586 CHECK_BAILOUT; |
| 4587 |
| 4588 Handle<String> name = expr->name(); |
| 4589 int argument_count = expr->arguments()->length(); |
| 4590 HCall* call = new HCallRuntime(name, function, argument_count); |
4592 call->set_position(RelocInfo::kNoPosition); | 4591 call->set_position(RelocInfo::kNoPosition); |
4593 PreProcessCall(call); | 4592 Drop(argument_count); |
4594 ast_context()->ReturnInstruction(call, expr->id()); | 4593 ast_context()->ReturnInstruction(call, expr->id()); |
4595 } | 4594 } |
4596 } | 4595 } |
4597 | 4596 |
4598 | 4597 |
4599 void HGraphBuilder::VisitUnaryOperation(UnaryOperation* expr) { | 4598 void HGraphBuilder::VisitUnaryOperation(UnaryOperation* expr) { |
4600 Token::Value op = expr->op(); | 4599 Token::Value op = expr->op(); |
4601 if (op == Token::VOID) { | 4600 if (op == Token::VOID) { |
4602 VISIT_FOR_EFFECT(expr->expression()); | 4601 VISIT_FOR_EFFECT(expr->expression()); |
4603 ast_context()->ReturnValue(graph()->GetConstantUndefined()); | 4602 ast_context()->ReturnValue(graph()->GetConstantUndefined()); |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5128 (slot != NULL && slot->type() == Slot::LOOKUP) || | 5127 (slot != NULL && slot->type() == Slot::LOOKUP) || |
5129 decl->mode() == Variable::CONST || | 5128 decl->mode() == Variable::CONST || |
5130 decl->fun() != NULL) { | 5129 decl->fun() != NULL) { |
5131 BAILOUT("unsupported declaration"); | 5130 BAILOUT("unsupported declaration"); |
5132 } | 5131 } |
5133 } | 5132 } |
5134 | 5133 |
5135 | 5134 |
5136 // Generators for inline runtime functions. | 5135 // Generators for inline runtime functions. |
5137 // Support for types. | 5136 // Support for types. |
5138 void HGraphBuilder::GenerateIsSmi(int argument_count, int ast_id) { | 5137 void HGraphBuilder::GenerateIsSmi(CallRuntime* call) { |
5139 ASSERT(argument_count == 1); | 5138 ASSERT(call->arguments()->length() == 1); |
| 5139 VISIT_FOR_VALUE(call->arguments()->at(0)); |
5140 HValue* value = Pop(); | 5140 HValue* value = Pop(); |
5141 HIsSmi* result = new HIsSmi(value); | 5141 HIsSmi* result = new HIsSmi(value); |
5142 ast_context()->ReturnInstruction(result, ast_id); | 5142 ast_context()->ReturnInstruction(result, call->id()); |
5143 } | 5143 } |
5144 | 5144 |
5145 | 5145 |
5146 void HGraphBuilder::GenerateIsSpecObject(int argument_count, int ast_id) { | 5146 void HGraphBuilder::GenerateIsSpecObject(CallRuntime* call) { |
5147 ASSERT(argument_count == 1); | 5147 ASSERT(call->arguments()->length() == 1); |
| 5148 VISIT_FOR_VALUE(call->arguments()->at(0)); |
5148 HValue* value = Pop(); | 5149 HValue* value = Pop(); |
5149 HHasInstanceType* result = | 5150 HHasInstanceType* result = |
5150 new HHasInstanceType(value, FIRST_JS_OBJECT_TYPE, LAST_TYPE); | 5151 new HHasInstanceType(value, FIRST_JS_OBJECT_TYPE, LAST_TYPE); |
5151 ast_context()->ReturnInstruction(result, ast_id); | 5152 ast_context()->ReturnInstruction(result, call->id()); |
5152 } | 5153 } |
5153 | 5154 |
5154 | 5155 |
5155 void HGraphBuilder::GenerateIsFunction(int argument_count, int ast_id) { | 5156 void HGraphBuilder::GenerateIsFunction(CallRuntime* call) { |
5156 ASSERT(argument_count == 1); | 5157 ASSERT(call->arguments()->length() == 1); |
| 5158 VISIT_FOR_VALUE(call->arguments()->at(0)); |
5157 HValue* value = Pop(); | 5159 HValue* value = Pop(); |
5158 HHasInstanceType* result = new HHasInstanceType(value, JS_FUNCTION_TYPE); | 5160 HHasInstanceType* result = new HHasInstanceType(value, JS_FUNCTION_TYPE); |
5159 ast_context()->ReturnInstruction(result, ast_id); | 5161 ast_context()->ReturnInstruction(result, call->id()); |
5160 } | 5162 } |
5161 | 5163 |
5162 | 5164 |
5163 void HGraphBuilder::GenerateHasCachedArrayIndex(int argument_count, | 5165 void HGraphBuilder::GenerateHasCachedArrayIndex(CallRuntime* call) { |
5164 int ast_id) { | 5166 ASSERT(call->arguments()->length() == 1); |
5165 ASSERT(argument_count == 1); | 5167 VISIT_FOR_VALUE(call->arguments()->at(0)); |
5166 HValue* value = Pop(); | 5168 HValue* value = Pop(); |
5167 HHasCachedArrayIndex* result = new HHasCachedArrayIndex(value); | 5169 HHasCachedArrayIndex* result = new HHasCachedArrayIndex(value); |
5168 ast_context()->ReturnInstruction(result, ast_id); | 5170 ast_context()->ReturnInstruction(result, call->id()); |
5169 } | 5171 } |
5170 | 5172 |
5171 | 5173 |
5172 void HGraphBuilder::GenerateIsArray(int argument_count, int ast_id) { | 5174 void HGraphBuilder::GenerateIsArray(CallRuntime* call) { |
5173 ASSERT(argument_count == 1); | 5175 ASSERT(call->arguments()->length() == 1); |
| 5176 VISIT_FOR_VALUE(call->arguments()->at(0)); |
5174 HValue* value = Pop(); | 5177 HValue* value = Pop(); |
5175 HHasInstanceType* result = new HHasInstanceType(value, JS_ARRAY_TYPE); | 5178 HHasInstanceType* result = new HHasInstanceType(value, JS_ARRAY_TYPE); |
5176 ast_context()->ReturnInstruction(result, ast_id); | 5179 ast_context()->ReturnInstruction(result, call->id()); |
5177 } | 5180 } |
5178 | 5181 |
5179 | 5182 |
5180 void HGraphBuilder::GenerateIsRegExp(int argument_count, int ast_id) { | 5183 void HGraphBuilder::GenerateIsRegExp(CallRuntime* call) { |
5181 ASSERT(argument_count == 1); | 5184 ASSERT(call->arguments()->length() == 1); |
| 5185 VISIT_FOR_VALUE(call->arguments()->at(0)); |
5182 HValue* value = Pop(); | 5186 HValue* value = Pop(); |
5183 HHasInstanceType* result = new HHasInstanceType(value, JS_REGEXP_TYPE); | 5187 HHasInstanceType* result = new HHasInstanceType(value, JS_REGEXP_TYPE); |
5184 ast_context()->ReturnInstruction(result, ast_id); | 5188 ast_context()->ReturnInstruction(result, call->id()); |
5185 } | 5189 } |
5186 | 5190 |
5187 | 5191 |
5188 void HGraphBuilder::GenerateIsObject(int argument_count, int ast_id) { | 5192 void HGraphBuilder::GenerateIsObject(CallRuntime* call) { |
5189 ASSERT(argument_count == 1); | 5193 ASSERT(call->arguments()->length() == 1); |
5190 | 5194 VISIT_FOR_VALUE(call->arguments()->at(0)); |
5191 HValue* value = Pop(); | 5195 HValue* value = Pop(); |
5192 HIsObject* test = new HIsObject(value); | 5196 HIsObject* test = new HIsObject(value); |
5193 ast_context()->ReturnInstruction(test, ast_id); | 5197 ast_context()->ReturnInstruction(test, call->id()); |
5194 } | 5198 } |
5195 | 5199 |
5196 | 5200 |
5197 void HGraphBuilder::GenerateIsNonNegativeSmi(int argument_count, | 5201 void HGraphBuilder::GenerateIsNonNegativeSmi(CallRuntime* call) { |
5198 int ast_id) { | |
5199 BAILOUT("inlined runtime function: IsNonNegativeSmi"); | 5202 BAILOUT("inlined runtime function: IsNonNegativeSmi"); |
5200 } | 5203 } |
5201 | 5204 |
5202 | 5205 |
5203 void HGraphBuilder::GenerateIsUndetectableObject(int argument_count, | 5206 void HGraphBuilder::GenerateIsUndetectableObject(CallRuntime* call) { |
5204 int ast_id) { | |
5205 BAILOUT("inlined runtime function: IsUndetectableObject"); | 5207 BAILOUT("inlined runtime function: IsUndetectableObject"); |
5206 } | 5208 } |
5207 | 5209 |
5208 | 5210 |
5209 void HGraphBuilder::GenerateIsStringWrapperSafeForDefaultValueOf( | 5211 void HGraphBuilder::GenerateIsStringWrapperSafeForDefaultValueOf( |
5210 int argument_count, | 5212 CallRuntime* call) { |
5211 int ast_id) { | |
5212 BAILOUT("inlined runtime function: IsStringWrapperSafeForDefaultValueOf"); | 5213 BAILOUT("inlined runtime function: IsStringWrapperSafeForDefaultValueOf"); |
5213 } | 5214 } |
5214 | 5215 |
5215 | 5216 |
5216 // Support for construct call checks. | 5217 // Support for construct call checks. |
5217 void HGraphBuilder::GenerateIsConstructCall(int argument_count, int ast_id) { | 5218 void HGraphBuilder::GenerateIsConstructCall(CallRuntime* call) { |
5218 ASSERT(argument_count == 0); | 5219 ASSERT(call->arguments()->length() == 0); |
5219 ast_context()->ReturnInstruction(new HIsConstructCall, ast_id); | 5220 ast_context()->ReturnInstruction(new HIsConstructCall, call->id()); |
5220 } | 5221 } |
5221 | 5222 |
5222 | 5223 |
5223 // Support for arguments.length and arguments[?]. | 5224 // Support for arguments.length and arguments[?]. |
5224 void HGraphBuilder::GenerateArgumentsLength(int argument_count, int ast_id) { | 5225 void HGraphBuilder::GenerateArgumentsLength(CallRuntime* call) { |
5225 ASSERT(argument_count == 0); | 5226 ASSERT(call->arguments()->length() == 0); |
5226 HInstruction* elements = AddInstruction(new HArgumentsElements); | 5227 HInstruction* elements = AddInstruction(new HArgumentsElements); |
5227 HArgumentsLength* result = new HArgumentsLength(elements); | 5228 HArgumentsLength* result = new HArgumentsLength(elements); |
5228 ast_context()->ReturnInstruction(result, ast_id); | 5229 ast_context()->ReturnInstruction(result, call->id()); |
5229 } | 5230 } |
5230 | 5231 |
5231 | 5232 |
5232 void HGraphBuilder::GenerateArguments(int argument_count, int ast_id) { | 5233 void HGraphBuilder::GenerateArguments(CallRuntime* call) { |
5233 ASSERT(argument_count == 1); | 5234 ASSERT(call->arguments()->length() == 1); |
| 5235 VISIT_FOR_VALUE(call->arguments()->at(0)); |
5234 HValue* index = Pop(); | 5236 HValue* index = Pop(); |
5235 HInstruction* elements = AddInstruction(new HArgumentsElements); | 5237 HInstruction* elements = AddInstruction(new HArgumentsElements); |
5236 HInstruction* length = AddInstruction(new HArgumentsLength(elements)); | 5238 HInstruction* length = AddInstruction(new HArgumentsLength(elements)); |
5237 HAccessArgumentsAt* result = new HAccessArgumentsAt(elements, length, index); | 5239 HAccessArgumentsAt* result = new HAccessArgumentsAt(elements, length, index); |
5238 ast_context()->ReturnInstruction(result, ast_id); | 5240 ast_context()->ReturnInstruction(result, call->id()); |
5239 } | 5241 } |
5240 | 5242 |
5241 | 5243 |
5242 // Support for accessing the class and value fields of an object. | 5244 // Support for accessing the class and value fields of an object. |
5243 void HGraphBuilder::GenerateClassOf(int argument_count, int ast_id) { | 5245 void HGraphBuilder::GenerateClassOf(CallRuntime* call) { |
5244 // The special form detected by IsClassOfTest is detected before we get here | 5246 // The special form detected by IsClassOfTest is detected before we get here |
5245 // and does not cause a bailout. | 5247 // and does not cause a bailout. |
5246 BAILOUT("inlined runtime function: ClassOf"); | 5248 BAILOUT("inlined runtime function: ClassOf"); |
5247 } | 5249 } |
5248 | 5250 |
5249 | 5251 |
5250 void HGraphBuilder::GenerateValueOf(int argument_count, int ast_id) { | 5252 void HGraphBuilder::GenerateValueOf(CallRuntime* call) { |
5251 ASSERT(argument_count == 1); | 5253 ASSERT(call->arguments()->length() == 1); |
| 5254 VISIT_FOR_VALUE(call->arguments()->at(0)); |
5252 HValue* value = Pop(); | 5255 HValue* value = Pop(); |
5253 HValueOf* result = new HValueOf(value); | 5256 HValueOf* result = new HValueOf(value); |
5254 ast_context()->ReturnInstruction(result, ast_id); | 5257 ast_context()->ReturnInstruction(result, call->id()); |
5255 } | 5258 } |
5256 | 5259 |
5257 | 5260 |
5258 void HGraphBuilder::GenerateSetValueOf(int argument_count, int ast_id) { | 5261 void HGraphBuilder::GenerateSetValueOf(CallRuntime* call) { |
5259 BAILOUT("inlined runtime function: SetValueOf"); | 5262 BAILOUT("inlined runtime function: SetValueOf"); |
5260 } | 5263 } |
5261 | 5264 |
5262 | 5265 |
5263 // Fast support for charCodeAt(n). | 5266 // Fast support for charCodeAt(n). |
5264 void HGraphBuilder::GenerateStringCharCodeAt(int argument_count, int ast_id) { | 5267 void HGraphBuilder::GenerateStringCharCodeAt(CallRuntime* call) { |
5265 ASSERT(argument_count == 2); | 5268 ASSERT(call->arguments()->length() == 2); |
| 5269 VISIT_FOR_VALUE(call->arguments()->at(0)); |
| 5270 VISIT_FOR_VALUE(call->arguments()->at(1)); |
5266 HValue* index = Pop(); | 5271 HValue* index = Pop(); |
5267 HValue* string = Pop(); | 5272 HValue* string = Pop(); |
5268 HStringCharCodeAt* result = BuildStringCharCodeAt(string, index); | 5273 HStringCharCodeAt* result = BuildStringCharCodeAt(string, index); |
5269 ast_context()->ReturnInstruction(result, ast_id); | 5274 ast_context()->ReturnInstruction(result, call->id()); |
5270 } | 5275 } |
5271 | 5276 |
5272 | 5277 |
5273 // Fast support for string.charAt(n) and string[n]. | 5278 // Fast support for string.charAt(n) and string[n]. |
5274 void HGraphBuilder::GenerateStringCharFromCode(int argument_count, | 5279 void HGraphBuilder::GenerateStringCharFromCode(CallRuntime* call) { |
5275 int ast_id) { | |
5276 BAILOUT("inlined runtime function: StringCharFromCode"); | 5280 BAILOUT("inlined runtime function: StringCharFromCode"); |
5277 } | 5281 } |
5278 | 5282 |
5279 | 5283 |
5280 // Fast support for string.charAt(n) and string[n]. | 5284 // Fast support for string.charAt(n) and string[n]. |
5281 void HGraphBuilder::GenerateStringCharAt(int argument_count, int ast_id) { | 5285 void HGraphBuilder::GenerateStringCharAt(CallRuntime* call) { |
5282 ASSERT_EQ(2, argument_count); | 5286 ASSERT_EQ(2, call->arguments()->length()); |
5283 HContext* context = new HContext; | 5287 VisitArgumentList(call->arguments()); |
5284 AddInstruction(context); | 5288 CHECK_BAILOUT; |
5285 HCallStub* result = | 5289 HContext* context = new HContext; |
5286 new HCallStub(context, CodeStub::StringCharAt, argument_count); | 5290 AddInstruction(context); |
5287 PreProcessCall(result); | 5291 HCallStub* result = new HCallStub(context, CodeStub::StringCharAt, 2); |
5288 ast_context()->ReturnInstruction(result, ast_id); | 5292 Drop(2); |
| 5293 ast_context()->ReturnInstruction(result, call->id()); |
5289 } | 5294 } |
5290 | 5295 |
5291 | 5296 |
5292 // Fast support for object equality testing. | 5297 // Fast support for object equality testing. |
5293 void HGraphBuilder::GenerateObjectEquals(int argument_count, int ast_id) { | 5298 void HGraphBuilder::GenerateObjectEquals(CallRuntime* call) { |
5294 ASSERT(argument_count == 2); | 5299 ASSERT(call->arguments()->length() == 2); |
| 5300 VISIT_FOR_VALUE(call->arguments()->at(0)); |
| 5301 VISIT_FOR_VALUE(call->arguments()->at(1)); |
5295 HValue* right = Pop(); | 5302 HValue* right = Pop(); |
5296 HValue* left = Pop(); | 5303 HValue* left = Pop(); |
5297 HCompareJSObjectEq* result = new HCompareJSObjectEq(left, right); | 5304 HCompareJSObjectEq* result = new HCompareJSObjectEq(left, right); |
5298 ast_context()->ReturnInstruction(result, ast_id); | 5305 ast_context()->ReturnInstruction(result, call->id()); |
5299 } | 5306 } |
5300 | 5307 |
5301 | 5308 |
5302 void HGraphBuilder::GenerateLog(int argument_count, int ast_id) { | 5309 void HGraphBuilder::GenerateLog(CallRuntime* call) { |
5303 UNREACHABLE(); // We caught this in VisitCallRuntime. | 5310 // %_Log is ignored in optimized code. |
| 5311 ast_context()->ReturnValue(graph()->GetConstantUndefined()); |
5304 } | 5312 } |
5305 | 5313 |
5306 | 5314 |
5307 // Fast support for Math.random(). | 5315 // Fast support for Math.random(). |
5308 void HGraphBuilder::GenerateRandomHeapNumber(int argument_count, int ast_id) { | 5316 void HGraphBuilder::GenerateRandomHeapNumber(CallRuntime* call) { |
5309 BAILOUT("inlined runtime function: RandomHeapNumber"); | 5317 BAILOUT("inlined runtime function: RandomHeapNumber"); |
5310 } | 5318 } |
5311 | 5319 |
5312 | 5320 |
5313 // Fast support for StringAdd. | 5321 // Fast support for StringAdd. |
5314 void HGraphBuilder::GenerateStringAdd(int argument_count, int ast_id) { | 5322 void HGraphBuilder::GenerateStringAdd(CallRuntime* call) { |
5315 ASSERT_EQ(2, argument_count); | 5323 ASSERT_EQ(2, call->arguments()->length()); |
5316 HContext* context = new HContext; | 5324 VisitArgumentList(call->arguments()); |
5317 AddInstruction(context); | 5325 CHECK_BAILOUT; |
5318 HCallStub* result = | 5326 HContext* context = new HContext; |
5319 new HCallStub(context, CodeStub::StringAdd, argument_count); | 5327 AddInstruction(context); |
5320 PreProcessCall(result); | 5328 HCallStub* result = new HCallStub(context, CodeStub::StringAdd, 2); |
5321 ast_context()->ReturnInstruction(result, ast_id); | 5329 Drop(2); |
| 5330 ast_context()->ReturnInstruction(result, call->id()); |
5322 } | 5331 } |
5323 | 5332 |
5324 | 5333 |
5325 // Fast support for SubString. | 5334 // Fast support for SubString. |
5326 void HGraphBuilder::GenerateSubString(int argument_count, int ast_id) { | 5335 void HGraphBuilder::GenerateSubString(CallRuntime* call) { |
5327 ASSERT_EQ(3, argument_count); | 5336 ASSERT_EQ(3, call->arguments()->length()); |
5328 HContext* context = new HContext; | 5337 VisitArgumentList(call->arguments()); |
5329 AddInstruction(context); | 5338 CHECK_BAILOUT; |
5330 HCallStub* result = | 5339 HContext* context = new HContext; |
5331 new HCallStub(context, CodeStub::SubString, argument_count); | 5340 AddInstruction(context); |
5332 PreProcessCall(result); | 5341 HCallStub* result = new HCallStub(context, CodeStub::SubString, 3); |
5333 ast_context()->ReturnInstruction(result, ast_id); | 5342 Drop(3); |
| 5343 ast_context()->ReturnInstruction(result, call->id()); |
5334 } | 5344 } |
5335 | 5345 |
5336 | 5346 |
5337 // Fast support for StringCompare. | 5347 // Fast support for StringCompare. |
5338 void HGraphBuilder::GenerateStringCompare(int argument_count, int ast_id) { | 5348 void HGraphBuilder::GenerateStringCompare(CallRuntime* call) { |
5339 ASSERT_EQ(2, argument_count); | 5349 ASSERT_EQ(2, call->arguments()->length()); |
5340 HContext* context = new HContext; | 5350 VisitArgumentList(call->arguments()); |
5341 AddInstruction(context); | 5351 CHECK_BAILOUT; |
5342 HCallStub* result = | 5352 HContext* context = new HContext; |
5343 new HCallStub(context, CodeStub::StringCompare, argument_count); | 5353 AddInstruction(context); |
5344 PreProcessCall(result); | 5354 HCallStub* result = new HCallStub(context, CodeStub::StringCompare, 2); |
5345 ast_context()->ReturnInstruction(result, ast_id); | 5355 Drop(2); |
| 5356 ast_context()->ReturnInstruction(result, call->id()); |
5346 } | 5357 } |
5347 | 5358 |
5348 | 5359 |
5349 // Support for direct calls from JavaScript to native RegExp code. | 5360 // Support for direct calls from JavaScript to native RegExp code. |
5350 void HGraphBuilder::GenerateRegExpExec(int argument_count, int ast_id) { | 5361 void HGraphBuilder::GenerateRegExpExec(CallRuntime* call) { |
5351 ASSERT_EQ(4, argument_count); | 5362 ASSERT_EQ(4, call->arguments()->length()); |
5352 HContext* context = new HContext; | 5363 VisitArgumentList(call->arguments()); |
5353 AddInstruction(context); | 5364 CHECK_BAILOUT; |
5354 HCallStub* result = | 5365 HContext* context = new HContext; |
5355 new HCallStub(context, CodeStub::RegExpExec, argument_count); | 5366 AddInstruction(context); |
5356 PreProcessCall(result); | 5367 HCallStub* result = new HCallStub(context, CodeStub::RegExpExec, 4); |
5357 ast_context()->ReturnInstruction(result, ast_id); | 5368 Drop(4); |
| 5369 ast_context()->ReturnInstruction(result, call->id()); |
5358 } | 5370 } |
5359 | 5371 |
5360 | 5372 |
5361 // Construct a RegExp exec result with two in-object properties. | 5373 // Construct a RegExp exec result with two in-object properties. |
5362 void HGraphBuilder::GenerateRegExpConstructResult(int argument_count, | 5374 void HGraphBuilder::GenerateRegExpConstructResult(CallRuntime* call) { |
5363 int ast_id) { | 5375 ASSERT_EQ(3, call->arguments()->length()); |
5364 ASSERT_EQ(3, argument_count); | 5376 VisitArgumentList(call->arguments()); |
5365 HContext* context = new HContext; | 5377 CHECK_BAILOUT; |
5366 AddInstruction(context); | 5378 HContext* context = new HContext; |
5367 HCallStub* result = | 5379 AddInstruction(context); |
5368 new HCallStub(context, CodeStub::RegExpConstructResult, argument_count); | 5380 HCallStub* result = new HCallStub(context, CodeStub::RegExpConstructResult, 3)
; |
5369 PreProcessCall(result); | 5381 Drop(3); |
5370 ast_context()->ReturnInstruction(result, ast_id); | 5382 ast_context()->ReturnInstruction(result, call->id()); |
5371 } | 5383 } |
5372 | 5384 |
5373 | 5385 |
5374 // Support for fast native caches. | 5386 // Support for fast native caches. |
5375 void HGraphBuilder::GenerateGetFromCache(int argument_count, int ast_id) { | 5387 void HGraphBuilder::GenerateGetFromCache(CallRuntime* call) { |
5376 BAILOUT("inlined runtime function: GetFromCache"); | 5388 BAILOUT("inlined runtime function: GetFromCache"); |
5377 } | 5389 } |
5378 | 5390 |
5379 | 5391 |
5380 // Fast support for number to string. | 5392 // Fast support for number to string. |
5381 void HGraphBuilder::GenerateNumberToString(int argument_count, int ast_id) { | 5393 void HGraphBuilder::GenerateNumberToString(CallRuntime* call) { |
5382 ASSERT_EQ(1, argument_count); | 5394 ASSERT_EQ(1, call->arguments()->length()); |
5383 HContext* context = new HContext; | 5395 VisitArgumentList(call->arguments()); |
5384 AddInstruction(context); | 5396 CHECK_BAILOUT; |
5385 HCallStub* result = | 5397 HContext* context = new HContext; |
5386 new HCallStub(context, CodeStub::NumberToString, argument_count); | 5398 AddInstruction(context); |
5387 PreProcessCall(result); | 5399 HCallStub* result = new HCallStub(context, CodeStub::NumberToString, 1); |
5388 ast_context()->ReturnInstruction(result, ast_id); | 5400 Drop(1); |
| 5401 ast_context()->ReturnInstruction(result, call->id()); |
5389 } | 5402 } |
5390 | 5403 |
5391 | 5404 |
5392 // Fast swapping of elements. Takes three expressions, the object and two | 5405 // Fast swapping of elements. Takes three expressions, the object and two |
5393 // indices. This should only be used if the indices are known to be | 5406 // indices. This should only be used if the indices are known to be |
5394 // non-negative and within bounds of the elements array at the call site. | 5407 // non-negative and within bounds of the elements array at the call site. |
5395 void HGraphBuilder::GenerateSwapElements(int argument_count, int ast_id) { | 5408 void HGraphBuilder::GenerateSwapElements(CallRuntime* call) { |
5396 BAILOUT("inlined runtime function: SwapElements"); | 5409 BAILOUT("inlined runtime function: SwapElements"); |
5397 } | 5410 } |
5398 | 5411 |
5399 | 5412 |
5400 // Fast call for custom callbacks. | 5413 // Fast call for custom callbacks. |
5401 void HGraphBuilder::GenerateCallFunction(int argument_count, int ast_id) { | 5414 void HGraphBuilder::GenerateCallFunction(CallRuntime* call) { |
5402 BAILOUT("inlined runtime function: CallFunction"); | 5415 BAILOUT("inlined runtime function: CallFunction"); |
5403 } | 5416 } |
5404 | 5417 |
5405 | 5418 |
5406 // Fast call to math functions. | 5419 // Fast call to math functions. |
5407 void HGraphBuilder::GenerateMathPow(int argument_count, int ast_id) { | 5420 void HGraphBuilder::GenerateMathPow(CallRuntime* call) { |
5408 ASSERT_EQ(2, argument_count); | 5421 ASSERT_EQ(2, call->arguments()->length()); |
| 5422 VISIT_FOR_VALUE(call->arguments()->at(0)); |
| 5423 VISIT_FOR_VALUE(call->arguments()->at(1)); |
5409 HValue* right = Pop(); | 5424 HValue* right = Pop(); |
5410 HValue* left = Pop(); | 5425 HValue* left = Pop(); |
5411 HPower* result = new HPower(left, right); | 5426 HPower* result = new HPower(left, right); |
5412 ast_context()->ReturnInstruction(result, ast_id); | 5427 ast_context()->ReturnInstruction(result, call->id()); |
5413 } | 5428 } |
5414 | 5429 |
5415 | 5430 |
5416 void HGraphBuilder::GenerateMathSin(int argument_count, int ast_id) { | 5431 void HGraphBuilder::GenerateMathSin(CallRuntime* call) { |
5417 ASSERT_EQ(1, argument_count); | 5432 ASSERT_EQ(1, call->arguments()->length()); |
5418 HContext* context = new HContext; | 5433 VisitArgumentList(call->arguments()); |
5419 AddInstruction(context); | 5434 CHECK_BAILOUT; |
5420 HCallStub* result = | 5435 HContext* context = new HContext; |
5421 new HCallStub(context, CodeStub::TranscendentalCache, argument_count); | 5436 AddInstruction(context); |
| 5437 HCallStub* result = new HCallStub(context, CodeStub::TranscendentalCache, 1); |
5422 result->set_transcendental_type(TranscendentalCache::SIN); | 5438 result->set_transcendental_type(TranscendentalCache::SIN); |
5423 PreProcessCall(result); | 5439 Drop(1); |
5424 ast_context()->ReturnInstruction(result, ast_id); | 5440 ast_context()->ReturnInstruction(result, call->id()); |
5425 } | 5441 } |
5426 | 5442 |
5427 | 5443 |
5428 void HGraphBuilder::GenerateMathCos(int argument_count, int ast_id) { | 5444 void HGraphBuilder::GenerateMathCos(CallRuntime* call) { |
5429 ASSERT_EQ(1, argument_count); | 5445 ASSERT_EQ(1, call->arguments()->length()); |
5430 HContext* context = new HContext; | 5446 VisitArgumentList(call->arguments()); |
5431 AddInstruction(context); | 5447 CHECK_BAILOUT; |
5432 HCallStub* result = | 5448 HContext* context = new HContext; |
5433 new HCallStub(context, CodeStub::TranscendentalCache, argument_count); | 5449 AddInstruction(context); |
| 5450 HCallStub* result = new HCallStub(context, CodeStub::TranscendentalCache, 1); |
5434 result->set_transcendental_type(TranscendentalCache::COS); | 5451 result->set_transcendental_type(TranscendentalCache::COS); |
5435 PreProcessCall(result); | 5452 Drop(1); |
5436 ast_context()->ReturnInstruction(result, ast_id); | 5453 ast_context()->ReturnInstruction(result, call->id()); |
5437 } | 5454 } |
5438 | 5455 |
5439 | 5456 |
5440 void HGraphBuilder::GenerateMathLog(int argument_count, int ast_id) { | 5457 void HGraphBuilder::GenerateMathLog(CallRuntime* call) { |
5441 ASSERT_EQ(1, argument_count); | 5458 ASSERT_EQ(1, call->arguments()->length()); |
5442 HContext* context = new HContext; | 5459 VisitArgumentList(call->arguments()); |
5443 AddInstruction(context); | 5460 CHECK_BAILOUT; |
5444 HCallStub* result = | 5461 HContext* context = new HContext; |
5445 new HCallStub(context, CodeStub::TranscendentalCache, argument_count); | 5462 AddInstruction(context); |
| 5463 HCallStub* result = new HCallStub(context, CodeStub::TranscendentalCache, 1); |
5446 result->set_transcendental_type(TranscendentalCache::LOG); | 5464 result->set_transcendental_type(TranscendentalCache::LOG); |
5447 PreProcessCall(result); | 5465 Drop(1); |
5448 ast_context()->ReturnInstruction(result, ast_id); | 5466 ast_context()->ReturnInstruction(result, call->id()); |
5449 } | 5467 } |
5450 | 5468 |
5451 | 5469 |
5452 void HGraphBuilder::GenerateMathSqrt(int argument_count, int ast_id) { | 5470 void HGraphBuilder::GenerateMathSqrt(CallRuntime* call) { |
5453 BAILOUT("inlined runtime function: MathSqrt"); | 5471 BAILOUT("inlined runtime function: MathSqrt"); |
5454 } | 5472 } |
5455 | 5473 |
5456 | 5474 |
5457 // Check whether two RegExps are equivalent | 5475 // Check whether two RegExps are equivalent |
5458 void HGraphBuilder::GenerateIsRegExpEquivalent(int argument_count, | 5476 void HGraphBuilder::GenerateIsRegExpEquivalent(CallRuntime* call) { |
5459 int ast_id) { | |
5460 BAILOUT("inlined runtime function: IsRegExpEquivalent"); | 5477 BAILOUT("inlined runtime function: IsRegExpEquivalent"); |
5461 } | 5478 } |
5462 | 5479 |
5463 | 5480 |
5464 void HGraphBuilder::GenerateGetCachedArrayIndex(int argument_count, | 5481 void HGraphBuilder::GenerateGetCachedArrayIndex(CallRuntime* call) { |
5465 int ast_id) { | 5482 ASSERT(call->arguments()->length() == 1); |
5466 ASSERT(argument_count == 1); | 5483 VISIT_FOR_VALUE(call->arguments()->at(0)); |
5467 HValue* value = Pop(); | 5484 HValue* value = Pop(); |
5468 HGetCachedArrayIndex* result = new HGetCachedArrayIndex(value); | 5485 HGetCachedArrayIndex* result = new HGetCachedArrayIndex(value); |
5469 ast_context()->ReturnInstruction(result, ast_id); | 5486 ast_context()->ReturnInstruction(result, call->id()); |
5470 } | 5487 } |
5471 | 5488 |
5472 | 5489 |
5473 void HGraphBuilder::GenerateFastAsciiArrayJoin(int argument_count, | 5490 void HGraphBuilder::GenerateFastAsciiArrayJoin(CallRuntime* call) { |
5474 int ast_id) { | |
5475 BAILOUT("inlined runtime function: FastAsciiArrayJoin"); | 5491 BAILOUT("inlined runtime function: FastAsciiArrayJoin"); |
5476 } | 5492 } |
5477 | 5493 |
5478 | 5494 |
5479 #undef BAILOUT | 5495 #undef BAILOUT |
5480 #undef CHECK_BAILOUT | 5496 #undef CHECK_BAILOUT |
5481 #undef VISIT_FOR_EFFECT | 5497 #undef VISIT_FOR_EFFECT |
5482 #undef VISIT_FOR_VALUE | 5498 #undef VISIT_FOR_VALUE |
5483 #undef ADD_TO_SUBGRAPH | 5499 #undef ADD_TO_SUBGRAPH |
5484 | 5500 |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5982 } | 5998 } |
5983 } | 5999 } |
5984 | 6000 |
5985 #ifdef DEBUG | 6001 #ifdef DEBUG |
5986 if (graph_ != NULL) graph_->Verify(); | 6002 if (graph_ != NULL) graph_->Verify(); |
5987 if (allocator_ != NULL) allocator_->Verify(); | 6003 if (allocator_ != NULL) allocator_->Verify(); |
5988 #endif | 6004 #endif |
5989 } | 6005 } |
5990 | 6006 |
5991 } } // namespace v8::internal | 6007 } } // namespace v8::internal |
OLD | NEW |