OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 4515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4526 ASSERT(var == NULL || prop == NULL); | 4526 ASSERT(var == NULL || prop == NULL); |
4527 bool inc = expr->op() == Token::INC; | 4527 bool inc = expr->op() == Token::INC; |
4528 | 4528 |
4529 if (var != NULL) { | 4529 if (var != NULL) { |
4530 if (!var->is_global() && !var->IsStackAllocated()) { | 4530 if (!var->is_global() && !var->IsStackAllocated()) { |
4531 BAILOUT("non-stack/non-global variable in count operation"); | 4531 BAILOUT("non-stack/non-global variable in count operation"); |
4532 } | 4532 } |
4533 | 4533 |
4534 VISIT_FOR_VALUE(target); | 4534 VISIT_FOR_VALUE(target); |
4535 | 4535 |
4536 HValue* value = Pop(); | 4536 // Match the full code generator stack by simulating an extra stack |
4537 HInstruction* instr = BuildIncrement(value, inc); | 4537 // element for postfix operations in a non-effect context. |
4538 AddInstruction(instr); | 4538 bool has_extra = expr->is_postfix() && !ast_context()->IsEffect(); |
4539 | 4539 HValue* before = has_extra ? Top() : Pop(); |
4540 if (expr->is_prefix()) { | 4540 HInstruction* after = BuildIncrement(before, inc); |
4541 Push(instr); | 4541 AddInstruction(after); |
4542 } else { | 4542 Push(after); |
4543 Push(value); | |
4544 } | |
4545 | 4543 |
4546 if (var->is_global()) { | 4544 if (var->is_global()) { |
4547 HandleGlobalVariableAssignment(var, | 4545 HandleGlobalVariableAssignment(var, |
4548 instr, | 4546 after, |
4549 expr->position(), | 4547 expr->position(), |
4550 expr->AssignmentId()); | 4548 expr->AssignmentId()); |
4551 } else { | 4549 } else { |
4552 ASSERT(var->IsStackAllocated()); | 4550 ASSERT(var->IsStackAllocated()); |
4553 Bind(var, instr); | 4551 Bind(var, after); |
4554 } | 4552 } |
4555 ast_context()->ReturnValue(Pop()); | 4553 Drop(has_extra ? 2 : 1); |
| 4554 ast_context()->ReturnValue(expr->is_postfix() ? before : after); |
4556 | 4555 |
4557 } else if (prop != NULL) { | 4556 } else if (prop != NULL) { |
4558 prop->RecordTypeFeedback(oracle()); | 4557 prop->RecordTypeFeedback(oracle()); |
4559 | 4558 |
4560 if (prop->key()->IsPropertyName()) { | 4559 if (prop->key()->IsPropertyName()) { |
4561 // Named property. | 4560 // Named property. |
4562 | 4561 |
4563 // Match the full code generator stack by simulating an extra stack | 4562 // Match the full code generator stack by simulating an extra stack |
4564 // element for postfix operations in a value context. | 4563 // element for postfix operations in a non-effect context. |
4565 bool has_extra = expr->is_postfix() && !ast_context()->IsEffect(); | 4564 bool has_extra = expr->is_postfix() && !ast_context()->IsEffect(); |
4566 if (has_extra) Push(graph_->GetConstantUndefined()); | 4565 if (has_extra) Push(graph_->GetConstantUndefined()); |
4567 | 4566 |
4568 VISIT_FOR_VALUE(prop->obj()); | 4567 VISIT_FOR_VALUE(prop->obj()); |
4569 HValue* obj = Top(); | 4568 HValue* obj = Top(); |
4570 | 4569 |
4571 HInstruction* load = NULL; | 4570 HInstruction* load = NULL; |
4572 if (prop->IsMonomorphic()) { | 4571 if (prop->IsMonomorphic()) { |
4573 Handle<String> name = prop->key()->AsLiteral()->AsPropertyName(); | 4572 Handle<String> name = prop->key()->AsLiteral()->AsPropertyName(); |
4574 Handle<Map> map = prop->GetReceiverTypes()->first(); | 4573 Handle<Map> map = prop->GetReceiverTypes()->first(); |
(...skipping 20 matching lines...) Expand all Loading... |
4595 if (has_extra) environment()->SetExpressionStackAt(1, before); | 4594 if (has_extra) environment()->SetExpressionStackAt(1, before); |
4596 if (store->HasSideEffects()) AddSimulate(expr->AssignmentId()); | 4595 if (store->HasSideEffects()) AddSimulate(expr->AssignmentId()); |
4597 Drop(has_extra ? 2 : 1); | 4596 Drop(has_extra ? 2 : 1); |
4598 | 4597 |
4599 ast_context()->ReturnValue(expr->is_postfix() ? before : after); | 4598 ast_context()->ReturnValue(expr->is_postfix() ? before : after); |
4600 | 4599 |
4601 } else { | 4600 } else { |
4602 // Keyed property. | 4601 // Keyed property. |
4603 | 4602 |
4604 // Match the full code generator stack by simulate an extra stack element | 4603 // Match the full code generator stack by simulate an extra stack element |
4605 // for postfix operations in a value context. | 4604 // for postfix operations in a non-effect context. |
4606 bool has_extra = expr->is_postfix() && !ast_context()->IsEffect(); | 4605 bool has_extra = expr->is_postfix() && !ast_context()->IsEffect(); |
4607 if (has_extra) Push(graph_->GetConstantUndefined()); | 4606 if (has_extra) Push(graph_->GetConstantUndefined()); |
4608 | 4607 |
4609 VISIT_FOR_VALUE(prop->obj()); | 4608 VISIT_FOR_VALUE(prop->obj()); |
4610 VISIT_FOR_VALUE(prop->key()); | 4609 VISIT_FOR_VALUE(prop->key()); |
4611 HValue* obj = environment()->ExpressionStackAt(1); | 4610 HValue* obj = environment()->ExpressionStackAt(1); |
4612 HValue* key = environment()->ExpressionStackAt(0); | 4611 HValue* key = environment()->ExpressionStackAt(0); |
4613 | 4612 |
4614 bool is_fast_elements = prop->IsMonomorphic() && | 4613 bool is_fast_elements = prop->IsMonomorphic() && |
4615 prop->GetMonomorphicReceiverType()->has_fast_elements(); | 4614 prop->GetMonomorphicReceiverType()->has_fast_elements(); |
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5668 } | 5667 } |
5669 | 5668 |
5670 #ifdef DEBUG | 5669 #ifdef DEBUG |
5671 if (graph_ != NULL) graph_->Verify(); | 5670 if (graph_ != NULL) graph_->Verify(); |
5672 if (chunk_ != NULL) chunk_->Verify(); | 5671 if (chunk_ != NULL) chunk_->Verify(); |
5673 if (allocator_ != NULL) allocator_->Verify(); | 5672 if (allocator_ != NULL) allocator_->Verify(); |
5674 #endif | 5673 #endif |
5675 } | 5674 } |
5676 | 5675 |
5677 } } // namespace v8::internal | 5676 } } // namespace v8::internal |
OLD | NEW |