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

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

Issue 1724753002: [fullcodegen] Implement control flow across do-expressions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Disable verification. 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
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_X64 5 #if V8_TARGET_ARCH_X64
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 929 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); 940 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS);
941 } 941 }
942 942
943 943
944 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { 944 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) {
945 Comment cmnt(masm_, "[ ForInStatement"); 945 Comment cmnt(masm_, "[ ForInStatement");
946 SetStatementPosition(stmt, SKIP_BREAK); 946 SetStatementPosition(stmt, SKIP_BREAK);
947 947
948 FeedbackVectorSlot slot = stmt->ForInFeedbackSlot(); 948 FeedbackVectorSlot slot = stmt->ForInFeedbackSlot();
949 949
950 Label loop, exit;
951 ForIn loop_statement(this, stmt);
952 increment_loop_depth();
953
954 // Get the object to enumerate over. 950 // Get the object to enumerate over.
955 SetExpressionAsStatementPosition(stmt->enumerable()); 951 SetExpressionAsStatementPosition(stmt->enumerable());
956 VisitForAccumulatorValue(stmt->enumerable()); 952 VisitForAccumulatorValue(stmt->enumerable());
957 OperandStackDepthIncrement(ForIn::kElementCount); 953 OperandStackDepthIncrement(5);
954
955 Label loop, exit;
956 Iteration loop_statement(this, stmt);
957 increment_loop_depth();
958 958
959 // If the object is null or undefined, skip over the loop, otherwise convert 959 // If the object is null or undefined, skip over the loop, otherwise convert
960 // it to a JS receiver. See ECMA-262 version 5, section 12.6.4. 960 // it to a JS receiver. See ECMA-262 version 5, section 12.6.4.
961 Label convert, done_convert; 961 Label convert, done_convert;
962 __ JumpIfSmi(rax, &convert, Label::kNear); 962 __ JumpIfSmi(rax, &convert, Label::kNear);
963 __ CmpObjectType(rax, FIRST_JS_RECEIVER_TYPE, rcx); 963 __ CmpObjectType(rax, FIRST_JS_RECEIVER_TYPE, rcx);
964 __ j(above_equal, &done_convert, Label::kNear); 964 __ j(above_equal, &done_convert, Label::kNear);
965 __ CompareRoot(rax, Heap::kNullValueRootIndex); 965 __ CompareRoot(rax, Heap::kNullValueRootIndex);
966 __ j(equal, &exit); 966 __ j(equal, &exit);
967 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); 967 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex);
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 // Generate code for going to the next element by incrementing the 1108 // Generate code for going to the next element by incrementing the
1109 // index (smi) stored on top of the stack. 1109 // index (smi) stored on top of the stack.
1110 __ bind(loop_statement.continue_label()); 1110 __ bind(loop_statement.continue_label());
1111 __ SmiAddConstant(Operand(rsp, 0 * kPointerSize), Smi::FromInt(1)); 1111 __ SmiAddConstant(Operand(rsp, 0 * kPointerSize), Smi::FromInt(1));
1112 1112
1113 EmitBackEdgeBookkeeping(stmt, &loop); 1113 EmitBackEdgeBookkeeping(stmt, &loop);
1114 __ jmp(&loop); 1114 __ jmp(&loop);
1115 1115
1116 // Remove the pointers stored on the stack. 1116 // Remove the pointers stored on the stack.
1117 __ bind(loop_statement.break_label()); 1117 __ bind(loop_statement.break_label());
1118 __ addp(rsp, Immediate(5 * kPointerSize)); 1118 DropOperands(5);
1119 OperandStackDepthDecrement(ForIn::kElementCount);
1120 1119
1121 // Exit and decrement the loop depth. 1120 // Exit and decrement the loop depth.
1122 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); 1121 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS);
1123 __ bind(&exit); 1122 __ bind(&exit);
1124 decrement_loop_depth(); 1123 decrement_loop_depth();
1125 } 1124 }
1126 1125
1127 1126
1128 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, 1127 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info,
1129 bool pretenure) { 1128 bool pretenure) {
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
1821 SetExpressionPosition(expr); 1820 SetExpressionPosition(expr);
1822 1821
1823 // Evaluate yielded value first; the initial iterator definition depends on 1822 // Evaluate yielded value first; the initial iterator definition depends on
1824 // this. It stays on the stack while we update the iterator. 1823 // this. It stays on the stack while we update the iterator.
1825 VisitForStackValue(expr->expression()); 1824 VisitForStackValue(expr->expression());
1826 1825
1827 switch (expr->yield_kind()) { 1826 switch (expr->yield_kind()) {
1828 case Yield::kSuspend: 1827 case Yield::kSuspend:
1829 // Pop value from top-of-stack slot; box result into result register. 1828 // Pop value from top-of-stack slot; box result into result register.
1830 EmitCreateIteratorResult(false); 1829 EmitCreateIteratorResult(false);
1831 __ Push(result_register()); 1830 PushOperand(result_register());
1832 // Fall through. 1831 // Fall through.
1833 case Yield::kInitial: { 1832 case Yield::kInitial: {
1834 Label suspend, continuation, post_runtime, resume; 1833 Label suspend, continuation, post_runtime, resume;
1835 1834
1836 __ jmp(&suspend); 1835 __ jmp(&suspend);
1837 __ bind(&continuation); 1836 __ bind(&continuation);
1838 // When we arrive here, the stack top is the resume mode and 1837 // When we arrive here, the stack top is the resume mode and
1839 // result_register() holds the input value (the argument given to the 1838 // result_register() holds the input value (the argument given to the
1840 // respective resume operation). 1839 // respective resume operation).
1841 __ RecordGeneratorContinuation(); 1840 __ RecordGeneratorContinuation();
1842 __ Pop(rbx); 1841 __ Pop(rbx);
1843 __ SmiCompare(rbx, Smi::FromInt(JSGeneratorObject::RETURN)); 1842 __ SmiCompare(rbx, Smi::FromInt(JSGeneratorObject::RETURN));
1844 __ j(not_equal, &resume); 1843 __ j(not_equal, &resume);
1845 __ Push(result_register()); 1844 __ Push(result_register());
1846 EmitCreateIteratorResult(true); 1845 EmitCreateIteratorResult(true);
1847 EmitUnwindAndReturn(); 1846 EmitUnwindAndReturn();
1848 1847
1849 __ bind(&suspend); 1848 __ bind(&suspend);
1849 OperandStackDepthIncrement(1); // Not popped on this path.
1850 VisitForAccumulatorValue(expr->generator_object()); 1850 VisitForAccumulatorValue(expr->generator_object());
1851 DCHECK(continuation.pos() > 0 && Smi::IsValid(continuation.pos())); 1851 DCHECK(continuation.pos() > 0 && Smi::IsValid(continuation.pos()));
1852 __ Move(FieldOperand(rax, JSGeneratorObject::kContinuationOffset), 1852 __ Move(FieldOperand(rax, JSGeneratorObject::kContinuationOffset),
1853 Smi::FromInt(continuation.pos())); 1853 Smi::FromInt(continuation.pos()));
1854 __ movp(FieldOperand(rax, JSGeneratorObject::kContextOffset), rsi); 1854 __ movp(FieldOperand(rax, JSGeneratorObject::kContextOffset), rsi);
1855 __ movp(rcx, rsi); 1855 __ movp(rcx, rsi);
1856 __ RecordWriteField(rax, JSGeneratorObject::kContextOffset, rcx, rdx, 1856 __ RecordWriteField(rax, JSGeneratorObject::kContextOffset, rcx, rdx,
1857 kDontSaveFPRegs); 1857 kDontSaveFPRegs);
1858 __ leap(rbx, Operand(rbp, StandardFrameConstants::kExpressionsOffset)); 1858 __ leap(rbx, Operand(rbp, StandardFrameConstants::kExpressionsOffset));
1859 __ cmpp(rsp, rbx); 1859 __ cmpp(rsp, rbx);
1860 __ j(equal, &post_runtime); 1860 __ j(equal, &post_runtime);
1861 __ Push(rax); // generator object 1861 __ Push(rax); // generator object
1862 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); 1862 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1);
1863 __ movp(context_register(), 1863 __ movp(context_register(),
1864 Operand(rbp, StandardFrameConstants::kContextOffset)); 1864 Operand(rbp, StandardFrameConstants::kContextOffset));
1865 __ bind(&post_runtime); 1865 __ bind(&post_runtime);
1866 1866
1867 PopOperand(result_register()); 1867 PopOperand(result_register());
1868 EmitReturnSequence(); 1868 EmitReturnSequence();
1869 1869
1870 __ bind(&resume); 1870 __ bind(&resume);
1871 context()->Plug(result_register()); 1871 context()->Plug(result_register());
1872 break; 1872 break;
1873 } 1873 }
1874 1874
1875 case Yield::kFinal: { 1875 case Yield::kFinal: {
1876 // Pop value from top-of-stack slot, box result into result register. 1876 // Pop value from top-of-stack slot, box result into result register.
1877 OperandStackDepthDecrement(1);
1878 EmitCreateIteratorResult(true); 1877 EmitCreateIteratorResult(true);
1879 EmitUnwindAndReturn(); 1878 EmitUnwindAndReturn();
1880 break; 1879 break;
1881 } 1880 }
1882 1881
1883 case Yield::kDelegating: 1882 case Yield::kDelegating:
1884 UNREACHABLE(); 1883 UNREACHABLE();
1885 } 1884 }
1886 } 1885 }
1887 1886
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
2007 __ bind(&done_allocate); 2006 __ bind(&done_allocate);
2008 __ LoadNativeContextSlot(Context::ITERATOR_RESULT_MAP_INDEX, rbx); 2007 __ LoadNativeContextSlot(Context::ITERATOR_RESULT_MAP_INDEX, rbx);
2009 __ movp(FieldOperand(rax, HeapObject::kMapOffset), rbx); 2008 __ movp(FieldOperand(rax, HeapObject::kMapOffset), rbx);
2010 __ LoadRoot(rbx, Heap::kEmptyFixedArrayRootIndex); 2009 __ LoadRoot(rbx, Heap::kEmptyFixedArrayRootIndex);
2011 __ movp(FieldOperand(rax, JSObject::kPropertiesOffset), rbx); 2010 __ movp(FieldOperand(rax, JSObject::kPropertiesOffset), rbx);
2012 __ movp(FieldOperand(rax, JSObject::kElementsOffset), rbx); 2011 __ movp(FieldOperand(rax, JSObject::kElementsOffset), rbx);
2013 __ Pop(FieldOperand(rax, JSIteratorResult::kValueOffset)); 2012 __ Pop(FieldOperand(rax, JSIteratorResult::kValueOffset));
2014 __ LoadRoot(FieldOperand(rax, JSIteratorResult::kDoneOffset), 2013 __ LoadRoot(FieldOperand(rax, JSIteratorResult::kDoneOffset),
2015 done ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex); 2014 done ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex);
2016 STATIC_ASSERT(JSIteratorResult::kSize == 5 * kPointerSize); 2015 STATIC_ASSERT(JSIteratorResult::kSize == 5 * kPointerSize);
2016 OperandStackDepthDecrement(1);
2017 } 2017 }
2018 2018
2019 2019
2020 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { 2020 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) {
2021 SetExpressionPosition(prop); 2021 SetExpressionPosition(prop);
2022 Literal* key = prop->key()->AsLiteral(); 2022 Literal* key = prop->key()->AsLiteral();
2023 DCHECK(!key->value()->IsSmi()); 2023 DCHECK(!key->value()->IsSmi());
2024 DCHECK(!prop->IsSuperAccess()); 2024 DCHECK(!prop->IsSuperAccess());
2025 2025
2026 __ Move(LoadDescriptor::NameRegister(), key->value()); 2026 __ Move(LoadDescriptor::NameRegister(), key->value());
(...skipping 2093 matching lines...) Expand 10 before | Expand all | Expand 10 after
4120 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 4120 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
4121 Assembler::target_address_at(call_target_address, 4121 Assembler::target_address_at(call_target_address,
4122 unoptimized_code)); 4122 unoptimized_code));
4123 return OSR_AFTER_STACK_CHECK; 4123 return OSR_AFTER_STACK_CHECK;
4124 } 4124 }
4125 4125
4126 } // namespace internal 4126 } // namespace internal
4127 } // namespace v8 4127 } // namespace v8
4128 4128
4129 #endif // V8_TARGET_ARCH_X64 4129 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/full-codegen/mips64/full-codegen-mips64.cc ('k') | test/mjsunit/harmony/do-expressions-control.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698