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

Side by Side Diff: src/hydrogen.cc

Issue 7616010: Merge r8072 and r8884 to 3.3. (Closed) Base URL: http://v8.googlecode.com/svn/branches/3.3/
Patch Set: Created 9 years, 4 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
« no previous file with comments | « src/hydrogen.h ('k') | src/objects.h » ('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 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 3908 matching lines...) Expand 10 before | Expand all | Expand 10 after
3919 3919
3920 3920
3921 bool HGraphBuilder::TryArgumentsAccess(Property* expr) { 3921 bool HGraphBuilder::TryArgumentsAccess(Property* expr) {
3922 VariableProxy* proxy = expr->obj()->AsVariableProxy(); 3922 VariableProxy* proxy = expr->obj()->AsVariableProxy();
3923 if (proxy == NULL) return false; 3923 if (proxy == NULL) return false;
3924 if (!proxy->var()->IsStackAllocated()) return false; 3924 if (!proxy->var()->IsStackAllocated()) return false;
3925 if (!environment()->Lookup(proxy->var())->CheckFlag(HValue::kIsArguments)) { 3925 if (!environment()->Lookup(proxy->var())->CheckFlag(HValue::kIsArguments)) {
3926 return false; 3926 return false;
3927 } 3927 }
3928 3928
3929 // Our implementation of arguments (based on this stack frame or an
3930 // adapter below it) does not work for inlined functions.
3931 if (function_state()->outer() != NULL) {
3932 Bailout("arguments access in inlined function");
3933 return true;
3934 }
3935
3929 HInstruction* result = NULL; 3936 HInstruction* result = NULL;
3930 if (expr->key()->IsPropertyName()) { 3937 if (expr->key()->IsPropertyName()) {
3931 Handle<String> name = expr->key()->AsLiteral()->AsPropertyName(); 3938 Handle<String> name = expr->key()->AsLiteral()->AsPropertyName();
3932 if (!name->IsEqualTo(CStrVector("length"))) return false; 3939 if (!name->IsEqualTo(CStrVector("length"))) return false;
3933 HInstruction* elements = AddInstruction(new(zone()) HArgumentsElements); 3940 HInstruction* elements = AddInstruction(new(zone()) HArgumentsElements);
3934 result = new(zone()) HArgumentsLength(elements); 3941 result = new(zone()) HArgumentsLength(elements);
3935 } else { 3942 } else {
3936 Push(graph()->GetArgumentsObject()); 3943 Push(graph()->GetArgumentsObject());
3937 VisitForValue(expr->key()); 3944 VisitForValue(expr->key());
3938 if (HasStackOverflow() || current_block() == NULL) return true; 3945 if (HasStackOverflow() || current_block() == NULL) return true;
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
4452 } 4459 }
4453 return false; 4460 return false;
4454 } 4461 }
4455 4462
4456 4463
4457 bool HGraphBuilder::TryCallApply(Call* expr) { 4464 bool HGraphBuilder::TryCallApply(Call* expr) {
4458 Expression* callee = expr->expression(); 4465 Expression* callee = expr->expression();
4459 Property* prop = callee->AsProperty(); 4466 Property* prop = callee->AsProperty();
4460 ASSERT(prop != NULL); 4467 ASSERT(prop != NULL);
4461 4468
4469 if (!expr->IsMonomorphic() || expr->check_type() != RECEIVER_MAP_CHECK) {
4470 return false;
4471 }
4472 Handle<Map> function_map = expr->GetReceiverTypes()->first();
4473 if (function_map->instance_type() != JS_FUNCTION_TYPE ||
4474 !expr->target()->shared()->HasBuiltinFunctionId() ||
4475 expr->target()->shared()->builtin_function_id() != kFunctionApply) {
4476 return false;
4477 }
4478
4462 if (info()->scope()->arguments() == NULL) return false; 4479 if (info()->scope()->arguments() == NULL) return false;
4463 4480
4464 Handle<String> name = prop->key()->AsLiteral()->AsPropertyName();
4465 if (!name->IsEqualTo(CStrVector("apply"))) return false;
4466
4467 ZoneList<Expression*>* args = expr->arguments(); 4481 ZoneList<Expression*>* args = expr->arguments();
4468 if (args->length() != 2) return false; 4482 if (args->length() != 2) return false;
4469 4483
4470 VariableProxy* arg_two = args->at(1)->AsVariableProxy(); 4484 VariableProxy* arg_two = args->at(1)->AsVariableProxy();
4471 if (arg_two == NULL || !arg_two->var()->IsStackAllocated()) return false; 4485 if (arg_two == NULL || !arg_two->var()->IsStackAllocated()) return false;
4472 HValue* arg_two_value = environment()->Lookup(arg_two->var()); 4486 HValue* arg_two_value = environment()->Lookup(arg_two->var());
4473 if (!arg_two_value->CheckFlag(HValue::kIsArguments)) return false; 4487 if (!arg_two_value->CheckFlag(HValue::kIsArguments)) return false;
4474 4488
4475 if (!expr->IsMonomorphic() || 4489 // Our implementation of arguments (based on this stack frame or an
4476 expr->check_type() != RECEIVER_MAP_CHECK) return false; 4490 // adapter below it) does not work for inlined functions.
4491 if (function_state()->outer() != NULL) {
4492 Bailout("Function.prototype.apply optimization in inlined function");
4493 return true;
4494 }
4477 4495
4478 // Found pattern f.apply(receiver, arguments). 4496 // Found pattern f.apply(receiver, arguments).
4479 VisitForValue(prop->obj()); 4497 VisitForValue(prop->obj());
4480 if (HasStackOverflow() || current_block() == NULL) return true; 4498 if (HasStackOverflow() || current_block() == NULL) return true;
4481 HValue* function = Pop(); 4499 HValue* function = Pop();
4482 VisitForValue(args->at(0)); 4500 VisitForValue(args->at(0));
4483 if (HasStackOverflow() || current_block() == NULL) return true; 4501 if (HasStackOverflow() || current_block() == NULL) return true;
4484 HValue* receiver = Pop(); 4502 HValue* receiver = Pop();
4485 HInstruction* elements = AddInstruction(new(zone()) HArgumentsElements); 4503 HInstruction* elements = AddInstruction(new(zone()) HArgumentsElements);
4486 HInstruction* length = AddInstruction(new(zone()) HArgumentsLength(elements)); 4504 HInstruction* length = AddInstruction(new(zone()) HArgumentsLength(elements));
4487 AddCheckConstantFunction(expr, 4505 AddCheckConstantFunction(expr, function, function_map, true);
4488 function,
4489 expr->GetReceiverTypes()->first(),
4490 true);
4491 HInstruction* result = 4506 HInstruction* result =
4492 new(zone()) HApplyArguments(function, receiver, length, elements); 4507 new(zone()) HApplyArguments(function, receiver, length, elements);
4493 result->set_position(expr->position()); 4508 result->set_position(expr->position());
4494 ast_context()->ReturnInstruction(result, expr->id()); 4509 ast_context()->ReturnInstruction(result, expr->id());
4495 return true; 4510 return true;
4496 } 4511 }
4497 4512
4498 4513
4499 void HGraphBuilder::VisitCall(Call* expr) { 4514 void HGraphBuilder::VisitCall(Call* expr) {
4500 ASSERT(!HasStackOverflow()); 4515 ASSERT(!HasStackOverflow());
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after
5495 // false from %_IsConstructCall(). 5510 // false from %_IsConstructCall().
5496 ast_context()->ReturnValue(graph()->GetConstantFalse()); 5511 ast_context()->ReturnValue(graph()->GetConstantFalse());
5497 } else { 5512 } else {
5498 ast_context()->ReturnInstruction(new(zone()) HIsConstructCall, call->id()); 5513 ast_context()->ReturnInstruction(new(zone()) HIsConstructCall, call->id());
5499 } 5514 }
5500 } 5515 }
5501 5516
5502 5517
5503 // Support for arguments.length and arguments[?]. 5518 // Support for arguments.length and arguments[?].
5504 void HGraphBuilder::GenerateArgumentsLength(CallRuntime* call) { 5519 void HGraphBuilder::GenerateArgumentsLength(CallRuntime* call) {
5520 // Our implementation of arguments (based on this stack frame or an
5521 // adapter below it) does not work for inlined functions. This runtime
5522 // function is blacklisted by AstNode::IsInlineable.
5523 ASSERT(function_state()->outer() == NULL);
5505 ASSERT(call->arguments()->length() == 0); 5524 ASSERT(call->arguments()->length() == 0);
5506 HInstruction* elements = AddInstruction(new(zone()) HArgumentsElements); 5525 HInstruction* elements = AddInstruction(new(zone()) HArgumentsElements);
5507 HArgumentsLength* result = new(zone()) HArgumentsLength(elements); 5526 HArgumentsLength* result = new(zone()) HArgumentsLength(elements);
5508 ast_context()->ReturnInstruction(result, call->id()); 5527 ast_context()->ReturnInstruction(result, call->id());
5509 } 5528 }
5510 5529
5511 5530
5512 void HGraphBuilder::GenerateArguments(CallRuntime* call) { 5531 void HGraphBuilder::GenerateArguments(CallRuntime* call) {
5532 // Our implementation of arguments (based on this stack frame or an
5533 // adapter below it) does not work for inlined functions. This runtime
5534 // function is blacklisted by AstNode::IsInlineable.
5535 ASSERT(function_state()->outer() == NULL);
5513 ASSERT(call->arguments()->length() == 1); 5536 ASSERT(call->arguments()->length() == 1);
5514 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); 5537 CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
5515 HValue* index = Pop(); 5538 HValue* index = Pop();
5516 HInstruction* elements = AddInstruction(new(zone()) HArgumentsElements); 5539 HInstruction* elements = AddInstruction(new(zone()) HArgumentsElements);
5517 HInstruction* length = AddInstruction(new(zone()) HArgumentsLength(elements)); 5540 HInstruction* length = AddInstruction(new(zone()) HArgumentsLength(elements));
5518 HAccessArgumentsAt* result = 5541 HAccessArgumentsAt* result =
5519 new(zone()) HAccessArgumentsAt(elements, length, index); 5542 new(zone()) HAccessArgumentsAt(elements, length, index);
5520 ast_context()->ReturnInstruction(result, call->id()); 5543 ast_context()->ReturnInstruction(result, call->id());
5521 } 5544 }
5522 5545
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
6310 } 6333 }
6311 } 6334 }
6312 6335
6313 #ifdef DEBUG 6336 #ifdef DEBUG
6314 if (graph_ != NULL) graph_->Verify(); 6337 if (graph_ != NULL) graph_->Verify();
6315 if (allocator_ != NULL) allocator_->Verify(); 6338 if (allocator_ != NULL) allocator_->Verify();
6316 #endif 6339 #endif
6317 } 6340 }
6318 6341
6319 } } // namespace v8::internal 6342 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698