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

Side by Side Diff: src/full-codegen/x87/full-codegen-x87.cc

Issue 1735853002: X87: [fullcodegen] Implement control flow across do-expressions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if V8_TARGET_ARCH_X87 5 #if V8_TARGET_ARCH_X87
6 6
7 #include "src/ast/scopes.h" 7 #include "src/ast/scopes.h"
8 #include "src/code-factory.h" 8 #include "src/code-factory.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); 919 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS);
920 } 920 }
921 921
922 922
923 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { 923 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) {
924 Comment cmnt(masm_, "[ ForInStatement"); 924 Comment cmnt(masm_, "[ ForInStatement");
925 SetStatementPosition(stmt, SKIP_BREAK); 925 SetStatementPosition(stmt, SKIP_BREAK);
926 926
927 FeedbackVectorSlot slot = stmt->ForInFeedbackSlot(); 927 FeedbackVectorSlot slot = stmt->ForInFeedbackSlot();
928 928
929 Label loop, exit;
930 ForIn loop_statement(this, stmt);
931 increment_loop_depth();
932
933 // Get the object to enumerate over. 929 // Get the object to enumerate over.
934 SetExpressionAsStatementPosition(stmt->enumerable()); 930 SetExpressionAsStatementPosition(stmt->enumerable());
935 VisitForAccumulatorValue(stmt->enumerable()); 931 VisitForAccumulatorValue(stmt->enumerable());
936 OperandStackDepthIncrement(ForIn::kElementCount); 932 OperandStackDepthIncrement(5);
933
934 Label loop, exit;
935 Iteration loop_statement(this, stmt);
936 increment_loop_depth();
937 937
938 // If the object is null or undefined, skip over the loop, otherwise convert 938 // If the object is null or undefined, skip over the loop, otherwise convert
939 // it to a JS receiver. See ECMA-262 version 5, section 12.6.4. 939 // it to a JS receiver. See ECMA-262 version 5, section 12.6.4.
940 Label convert, done_convert; 940 Label convert, done_convert;
941 __ JumpIfSmi(eax, &convert, Label::kNear); 941 __ JumpIfSmi(eax, &convert, Label::kNear);
942 __ CmpObjectType(eax, FIRST_JS_RECEIVER_TYPE, ecx); 942 __ CmpObjectType(eax, FIRST_JS_RECEIVER_TYPE, ecx);
943 __ j(above_equal, &done_convert, Label::kNear); 943 __ j(above_equal, &done_convert, Label::kNear);
944 __ cmp(eax, isolate()->factory()->undefined_value()); 944 __ cmp(eax, isolate()->factory()->undefined_value());
945 __ j(equal, &exit); 945 __ j(equal, &exit);
946 __ cmp(eax, isolate()->factory()->null_value()); 946 __ cmp(eax, isolate()->factory()->null_value());
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 // Generate code for going to the next element by incrementing the 1074 // Generate code for going to the next element by incrementing the
1075 // index (smi) stored on top of the stack. 1075 // index (smi) stored on top of the stack.
1076 __ bind(loop_statement.continue_label()); 1076 __ bind(loop_statement.continue_label());
1077 __ add(Operand(esp, 0 * kPointerSize), Immediate(Smi::FromInt(1))); 1077 __ add(Operand(esp, 0 * kPointerSize), Immediate(Smi::FromInt(1)));
1078 1078
1079 EmitBackEdgeBookkeeping(stmt, &loop); 1079 EmitBackEdgeBookkeeping(stmt, &loop);
1080 __ jmp(&loop); 1080 __ jmp(&loop);
1081 1081
1082 // Remove the pointers stored on the stack. 1082 // Remove the pointers stored on the stack.
1083 __ bind(loop_statement.break_label()); 1083 __ bind(loop_statement.break_label());
1084 __ add(esp, Immediate(5 * kPointerSize)); 1084 DropOperands(5);
1085 OperandStackDepthDecrement(ForIn::kElementCount);
1086 1085
1087 // Exit and decrement the loop depth. 1086 // Exit and decrement the loop depth.
1088 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); 1087 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS);
1089 __ bind(&exit); 1088 __ bind(&exit);
1090 decrement_loop_depth(); 1089 decrement_loop_depth();
1091 } 1090 }
1092 1091
1093 1092
1094 void FullCodeGenerator::EmitSetHomeObject(Expression* initializer, int offset, 1093 void FullCodeGenerator::EmitSetHomeObject(Expression* initializer, int offset,
1095 FeedbackVectorSlot slot) { 1094 FeedbackVectorSlot slot) {
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
1765 SetExpressionPosition(expr); 1764 SetExpressionPosition(expr);
1766 1765
1767 // Evaluate yielded value first; the initial iterator definition depends on 1766 // Evaluate yielded value first; the initial iterator definition depends on
1768 // this. It stays on the stack while we update the iterator. 1767 // this. It stays on the stack while we update the iterator.
1769 VisitForStackValue(expr->expression()); 1768 VisitForStackValue(expr->expression());
1770 1769
1771 switch (expr->yield_kind()) { 1770 switch (expr->yield_kind()) {
1772 case Yield::kSuspend: 1771 case Yield::kSuspend:
1773 // Pop value from top-of-stack slot; box result into result register. 1772 // Pop value from top-of-stack slot; box result into result register.
1774 EmitCreateIteratorResult(false); 1773 EmitCreateIteratorResult(false);
1775 __ push(result_register()); 1774 PushOperand(result_register());
1776 // Fall through. 1775 // Fall through.
1777 case Yield::kInitial: { 1776 case Yield::kInitial: {
1778 Label suspend, continuation, post_runtime, resume; 1777 Label suspend, continuation, post_runtime, resume;
1779 1778
1780 __ jmp(&suspend); 1779 __ jmp(&suspend);
1781 __ bind(&continuation); 1780 __ bind(&continuation);
1782 // When we arrive here, the stack top is the resume mode and 1781 // When we arrive here, the stack top is the resume mode and
1783 // result_register() holds the input value (the argument given to the 1782 // result_register() holds the input value (the argument given to the
1784 // respective resume operation). 1783 // respective resume operation).
1785 __ RecordGeneratorContinuation(); 1784 __ RecordGeneratorContinuation();
1786 __ pop(ebx); 1785 __ pop(ebx);
1787 __ cmp(ebx, Immediate(Smi::FromInt(JSGeneratorObject::RETURN))); 1786 __ cmp(ebx, Immediate(Smi::FromInt(JSGeneratorObject::RETURN)));
1788 __ j(not_equal, &resume); 1787 __ j(not_equal, &resume);
1789 __ push(result_register()); 1788 __ push(result_register());
1790 EmitCreateIteratorResult(true); 1789 EmitCreateIteratorResult(true);
1791 EmitUnwindAndReturn(); 1790 EmitUnwindAndReturn();
1792 1791
1793 __ bind(&suspend); 1792 __ bind(&suspend);
1793 OperandStackDepthIncrement(1); // Not popped on this path.
1794 VisitForAccumulatorValue(expr->generator_object()); 1794 VisitForAccumulatorValue(expr->generator_object());
1795 DCHECK(continuation.pos() > 0 && Smi::IsValid(continuation.pos())); 1795 DCHECK(continuation.pos() > 0 && Smi::IsValid(continuation.pos()));
1796 __ mov(FieldOperand(eax, JSGeneratorObject::kContinuationOffset), 1796 __ mov(FieldOperand(eax, JSGeneratorObject::kContinuationOffset),
1797 Immediate(Smi::FromInt(continuation.pos()))); 1797 Immediate(Smi::FromInt(continuation.pos())));
1798 __ mov(FieldOperand(eax, JSGeneratorObject::kContextOffset), esi); 1798 __ mov(FieldOperand(eax, JSGeneratorObject::kContextOffset), esi);
1799 __ mov(ecx, esi); 1799 __ mov(ecx, esi);
1800 __ RecordWriteField(eax, JSGeneratorObject::kContextOffset, ecx, edx, 1800 __ RecordWriteField(eax, JSGeneratorObject::kContextOffset, ecx, edx,
1801 kDontSaveFPRegs); 1801 kDontSaveFPRegs);
1802 __ lea(ebx, Operand(ebp, StandardFrameConstants::kExpressionsOffset)); 1802 __ lea(ebx, Operand(ebp, StandardFrameConstants::kExpressionsOffset));
1803 __ cmp(esp, ebx); 1803 __ cmp(esp, ebx);
1804 __ j(equal, &post_runtime); 1804 __ j(equal, &post_runtime);
1805 __ push(eax); // generator object 1805 __ push(eax); // generator object
1806 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); 1806 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1);
1807 __ mov(context_register(), 1807 __ mov(context_register(),
1808 Operand(ebp, StandardFrameConstants::kContextOffset)); 1808 Operand(ebp, StandardFrameConstants::kContextOffset));
1809 __ bind(&post_runtime); 1809 __ bind(&post_runtime);
1810 PopOperand(result_register()); 1810 PopOperand(result_register());
1811 EmitReturnSequence(); 1811 EmitReturnSequence();
1812 1812
1813 __ bind(&resume); 1813 __ bind(&resume);
1814 context()->Plug(result_register()); 1814 context()->Plug(result_register());
1815 break; 1815 break;
1816 } 1816 }
1817 1817
1818 case Yield::kFinal: { 1818 case Yield::kFinal: {
1819 // Pop value from top-of-stack slot, box result into result register. 1819 // Pop value from top-of-stack slot, box result into result register.
1820 OperandStackDepthDecrement(1);
1821 EmitCreateIteratorResult(true); 1820 EmitCreateIteratorResult(true);
1822 EmitUnwindAndReturn(); 1821 EmitUnwindAndReturn();
1823 break; 1822 break;
1824 } 1823 }
1825 1824
1826 case Yield::kDelegating: 1825 case Yield::kDelegating:
1827 UNREACHABLE(); 1826 UNREACHABLE();
1828 } 1827 }
1829 } 1828 }
1830 1829
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1951 __ mov(ebx, ContextOperand(ebx, Context::ITERATOR_RESULT_MAP_INDEX)); 1950 __ mov(ebx, ContextOperand(ebx, Context::ITERATOR_RESULT_MAP_INDEX));
1952 __ mov(FieldOperand(eax, HeapObject::kMapOffset), ebx); 1951 __ mov(FieldOperand(eax, HeapObject::kMapOffset), ebx);
1953 __ mov(FieldOperand(eax, JSObject::kPropertiesOffset), 1952 __ mov(FieldOperand(eax, JSObject::kPropertiesOffset),
1954 isolate()->factory()->empty_fixed_array()); 1953 isolate()->factory()->empty_fixed_array());
1955 __ mov(FieldOperand(eax, JSObject::kElementsOffset), 1954 __ mov(FieldOperand(eax, JSObject::kElementsOffset),
1956 isolate()->factory()->empty_fixed_array()); 1955 isolate()->factory()->empty_fixed_array());
1957 __ pop(FieldOperand(eax, JSIteratorResult::kValueOffset)); 1956 __ pop(FieldOperand(eax, JSIteratorResult::kValueOffset));
1958 __ mov(FieldOperand(eax, JSIteratorResult::kDoneOffset), 1957 __ mov(FieldOperand(eax, JSIteratorResult::kDoneOffset),
1959 isolate()->factory()->ToBoolean(done)); 1958 isolate()->factory()->ToBoolean(done));
1960 STATIC_ASSERT(JSIteratorResult::kSize == 5 * kPointerSize); 1959 STATIC_ASSERT(JSIteratorResult::kSize == 5 * kPointerSize);
1960 OperandStackDepthDecrement(1);
1961 } 1961 }
1962 1962
1963 1963
1964 void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr, 1964 void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr,
1965 Token::Value op, 1965 Token::Value op,
1966 Expression* left, 1966 Expression* left,
1967 Expression* right) { 1967 Expression* right) {
1968 // Do combined smi check of the operands. Left operand is on the 1968 // Do combined smi check of the operands. Left operand is on the
1969 // stack. Right operand is in eax. 1969 // stack. Right operand is in eax.
1970 Label smi_case, done, stub_call; 1970 Label smi_case, done, stub_call;
(...skipping 2117 matching lines...) Expand 10 before | Expand all | Expand 10 after
4088 Assembler::target_address_at(call_target_address, 4088 Assembler::target_address_at(call_target_address,
4089 unoptimized_code)); 4089 unoptimized_code));
4090 return OSR_AFTER_STACK_CHECK; 4090 return OSR_AFTER_STACK_CHECK;
4091 } 4091 }
4092 4092
4093 4093
4094 } // namespace internal 4094 } // namespace internal
4095 } // namespace v8 4095 } // namespace v8
4096 4096
4097 #endif // V8_TARGET_ARCH_X87 4097 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698