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 3830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3841 | 3841 |
3842 | 3842 |
3843 bool HGraphBuilder::TryArgumentsAccess(Property* expr) { | 3843 bool HGraphBuilder::TryArgumentsAccess(Property* expr) { |
3844 VariableProxy* proxy = expr->obj()->AsVariableProxy(); | 3844 VariableProxy* proxy = expr->obj()->AsVariableProxy(); |
3845 if (proxy == NULL) return false; | 3845 if (proxy == NULL) return false; |
3846 if (!proxy->var()->IsStackAllocated()) return false; | 3846 if (!proxy->var()->IsStackAllocated()) return false; |
3847 if (!environment()->Lookup(proxy->var())->CheckFlag(HValue::kIsArguments)) { | 3847 if (!environment()->Lookup(proxy->var())->CheckFlag(HValue::kIsArguments)) { |
3848 return false; | 3848 return false; |
3849 } | 3849 } |
3850 | 3850 |
| 3851 // Our implementation of arguments (based on this stack frame or an |
| 3852 // adapter below it) does not work for inlined functions. |
| 3853 if (function_state()->outer() != NULL) { |
| 3854 Bailout("arguments access in inlined function"); |
| 3855 return true; |
| 3856 } |
| 3857 |
3851 HInstruction* result = NULL; | 3858 HInstruction* result = NULL; |
3852 if (expr->key()->IsPropertyName()) { | 3859 if (expr->key()->IsPropertyName()) { |
3853 Handle<String> name = expr->key()->AsLiteral()->AsPropertyName(); | 3860 Handle<String> name = expr->key()->AsLiteral()->AsPropertyName(); |
3854 if (!name->IsEqualTo(CStrVector("length"))) return false; | 3861 if (!name->IsEqualTo(CStrVector("length"))) return false; |
3855 HInstruction* elements = AddInstruction(new(zone()) HArgumentsElements); | 3862 HInstruction* elements = AddInstruction(new(zone()) HArgumentsElements); |
3856 result = new(zone()) HArgumentsLength(elements); | 3863 result = new(zone()) HArgumentsLength(elements); |
3857 } else { | 3864 } else { |
3858 Push(graph()->GetArgumentsObject()); | 3865 Push(graph()->GetArgumentsObject()); |
3859 VisitForValue(expr->key()); | 3866 VisitForValue(expr->key()); |
3860 if (HasStackOverflow() || current_block() == NULL) return true; | 3867 if (HasStackOverflow() || current_block() == NULL) return true; |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4389 if (args->length() != 2) return false; | 4396 if (args->length() != 2) return false; |
4390 | 4397 |
4391 VariableProxy* arg_two = args->at(1)->AsVariableProxy(); | 4398 VariableProxy* arg_two = args->at(1)->AsVariableProxy(); |
4392 if (arg_two == NULL || !arg_two->var()->IsStackAllocated()) return false; | 4399 if (arg_two == NULL || !arg_two->var()->IsStackAllocated()) return false; |
4393 HValue* arg_two_value = environment()->Lookup(arg_two->var()); | 4400 HValue* arg_two_value = environment()->Lookup(arg_two->var()); |
4394 if (!arg_two_value->CheckFlag(HValue::kIsArguments)) return false; | 4401 if (!arg_two_value->CheckFlag(HValue::kIsArguments)) return false; |
4395 | 4402 |
4396 if (!expr->IsMonomorphic() || | 4403 if (!expr->IsMonomorphic() || |
4397 expr->check_type() != RECEIVER_MAP_CHECK) return false; | 4404 expr->check_type() != RECEIVER_MAP_CHECK) return false; |
4398 | 4405 |
| 4406 // Our implementation of arguments (based on this stack frame or an |
| 4407 // adapter below it) does not work for inlined functions. |
| 4408 if (function_state()->outer() != NULL) { |
| 4409 Bailout("Function.prototype.apply optimization in inlined function"); |
| 4410 return true; |
| 4411 } |
| 4412 |
4399 // Found pattern f.apply(receiver, arguments). | 4413 // Found pattern f.apply(receiver, arguments). |
4400 VisitForValue(prop->obj()); | 4414 VisitForValue(prop->obj()); |
4401 if (HasStackOverflow() || current_block() == NULL) return true; | 4415 if (HasStackOverflow() || current_block() == NULL) return true; |
4402 HValue* function = Pop(); | 4416 HValue* function = Pop(); |
4403 VisitForValue(args->at(0)); | 4417 VisitForValue(args->at(0)); |
4404 if (HasStackOverflow() || current_block() == NULL) return true; | 4418 if (HasStackOverflow() || current_block() == NULL) return true; |
4405 HValue* receiver = Pop(); | 4419 HValue* receiver = Pop(); |
4406 HInstruction* elements = AddInstruction(new(zone()) HArgumentsElements); | 4420 HInstruction* elements = AddInstruction(new(zone()) HArgumentsElements); |
4407 HInstruction* length = AddInstruction(new(zone()) HArgumentsLength(elements)); | 4421 HInstruction* length = AddInstruction(new(zone()) HArgumentsLength(elements)); |
4408 AddCheckConstantFunction(expr, | 4422 AddCheckConstantFunction(expr, |
(...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5415 // false from %_IsConstructCall(). | 5429 // false from %_IsConstructCall(). |
5416 ast_context()->ReturnValue(graph()->GetConstantFalse()); | 5430 ast_context()->ReturnValue(graph()->GetConstantFalse()); |
5417 } else { | 5431 } else { |
5418 ast_context()->ReturnInstruction(new(zone()) HIsConstructCall, call->id()); | 5432 ast_context()->ReturnInstruction(new(zone()) HIsConstructCall, call->id()); |
5419 } | 5433 } |
5420 } | 5434 } |
5421 | 5435 |
5422 | 5436 |
5423 // Support for arguments.length and arguments[?]. | 5437 // Support for arguments.length and arguments[?]. |
5424 void HGraphBuilder::GenerateArgumentsLength(CallRuntime* call) { | 5438 void HGraphBuilder::GenerateArgumentsLength(CallRuntime* call) { |
| 5439 // Our implementation of arguments (based on this stack frame or an |
| 5440 // adapter below it) does not work for inlined functions. This runtime |
| 5441 // function is blacklisted by AstNode::IsInlineable. |
| 5442 ASSERT(function_state()->outer() == NULL); |
5425 ASSERT(call->arguments()->length() == 0); | 5443 ASSERT(call->arguments()->length() == 0); |
5426 HInstruction* elements = AddInstruction(new(zone()) HArgumentsElements); | 5444 HInstruction* elements = AddInstruction(new(zone()) HArgumentsElements); |
5427 HArgumentsLength* result = new(zone()) HArgumentsLength(elements); | 5445 HArgumentsLength* result = new(zone()) HArgumentsLength(elements); |
5428 ast_context()->ReturnInstruction(result, call->id()); | 5446 ast_context()->ReturnInstruction(result, call->id()); |
5429 } | 5447 } |
5430 | 5448 |
5431 | 5449 |
5432 void HGraphBuilder::GenerateArguments(CallRuntime* call) { | 5450 void HGraphBuilder::GenerateArguments(CallRuntime* call) { |
| 5451 // Our implementation of arguments (based on this stack frame or an |
| 5452 // adapter below it) does not work for inlined functions. This runtime |
| 5453 // function is blacklisted by AstNode::IsInlineable. |
| 5454 ASSERT(function_state()->outer() == NULL); |
5433 ASSERT(call->arguments()->length() == 1); | 5455 ASSERT(call->arguments()->length() == 1); |
5434 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | 5456 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
5435 HValue* index = Pop(); | 5457 HValue* index = Pop(); |
5436 HInstruction* elements = AddInstruction(new(zone()) HArgumentsElements); | 5458 HInstruction* elements = AddInstruction(new(zone()) HArgumentsElements); |
5437 HInstruction* length = AddInstruction(new(zone()) HArgumentsLength(elements)); | 5459 HInstruction* length = AddInstruction(new(zone()) HArgumentsLength(elements)); |
5438 HAccessArgumentsAt* result = | 5460 HAccessArgumentsAt* result = |
5439 new(zone()) HAccessArgumentsAt(elements, length, index); | 5461 new(zone()) HAccessArgumentsAt(elements, length, index); |
5440 ast_context()->ReturnInstruction(result, call->id()); | 5462 ast_context()->ReturnInstruction(result, call->id()); |
5441 } | 5463 } |
5442 | 5464 |
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6230 } | 6252 } |
6231 } | 6253 } |
6232 | 6254 |
6233 #ifdef DEBUG | 6255 #ifdef DEBUG |
6234 if (graph_ != NULL) graph_->Verify(); | 6256 if (graph_ != NULL) graph_->Verify(); |
6235 if (allocator_ != NULL) allocator_->Verify(); | 6257 if (allocator_ != NULL) allocator_->Verify(); |
6236 #endif | 6258 #endif |
6237 } | 6259 } |
6238 | 6260 |
6239 } } // namespace v8::internal | 6261 } } // namespace v8::internal |
OLD | NEW |