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

Side by Side Diff: src/interpreter/bytecode-generator.cc

Issue 1855913002: [interpreter] add some expression positions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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 | src/interpreter/source-position-table.cc » ('j') | test/message/message.status » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 #include "src/interpreter/bytecode-generator.h" 5 #include "src/interpreter/bytecode-generator.h"
6 6
7 #include "src/ast/scopes.h" 7 #include "src/ast/scopes.h"
8 #include "src/compiler.h" 8 #include "src/compiler.h"
9 #include "src/interpreter/bytecode-register-allocator.h" 9 #include "src/interpreter/bytecode-register-allocator.h"
10 #include "src/interpreter/control-flow-builders.h" 10 #include "src/interpreter/control-flow-builders.h"
(...skipping 1729 matching lines...) Expand 10 before | Expand all | Expand 10 after
1740 1740
1741 if (!literal_in_accumulator) { 1741 if (!literal_in_accumulator) {
1742 // Restore literal array into accumulator. 1742 // Restore literal array into accumulator.
1743 builder()->LoadAccumulatorWithRegister(literal); 1743 builder()->LoadAccumulatorWithRegister(literal);
1744 } 1744 }
1745 execution_result()->SetResultInAccumulator(); 1745 execution_result()->SetResultInAccumulator();
1746 } 1746 }
1747 1747
1748 1748
1749 void BytecodeGenerator::VisitVariableProxy(VariableProxy* proxy) { 1749 void BytecodeGenerator::VisitVariableProxy(VariableProxy* proxy) {
1750 builder()->SetExpressionPosition(proxy);
1750 VisitVariableLoad(proxy->var(), proxy->VariableFeedbackSlot()); 1751 VisitVariableLoad(proxy->var(), proxy->VariableFeedbackSlot());
1751 } 1752 }
1752 1753
1753 void BytecodeGenerator::BuildHoleCheckForVariableLoad(VariableMode mode, 1754 void BytecodeGenerator::BuildHoleCheckForVariableLoad(VariableMode mode,
1754 Handle<String> name) { 1755 Handle<String> name) {
1755 if (mode == CONST_LEGACY) { 1756 if (mode == CONST_LEGACY) {
1756 BytecodeLabel end_label; 1757 BytecodeLabel end_label;
1757 builder()->JumpIfNotHole(&end_label).LoadUndefined().Bind(&end_label); 1758 builder()->JumpIfNotHole(&end_label).LoadUndefined().Bind(&end_label);
1758 } else if (mode == LET || mode == CONST) { 1759 } else if (mode == LET || mode == CONST) {
1759 BuildThrowIfHole(name); 1760 BuildThrowIfHole(name);
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
2184 break; 2185 break;
2185 } 2186 }
2186 } 2187 }
2187 VisitForAccumulatorValue(expr->value()); 2188 VisitForAccumulatorValue(expr->value());
2188 builder()->BinaryOperation(expr->binary_op(), old_value); 2189 builder()->BinaryOperation(expr->binary_op(), old_value);
2189 } else { 2190 } else {
2190 VisitForAccumulatorValue(expr->value()); 2191 VisitForAccumulatorValue(expr->value());
2191 } 2192 }
2192 2193
2193 // Store the value. 2194 // Store the value.
2195 builder()->SetExpressionPosition(expr);
2194 FeedbackVectorSlot slot = expr->AssignmentSlot(); 2196 FeedbackVectorSlot slot = expr->AssignmentSlot();
2195 switch (assign_type) { 2197 switch (assign_type) {
2196 case VARIABLE: { 2198 case VARIABLE: {
2197 // TODO(oth): The VisitVariableAssignment() call is hard to reason about. 2199 // TODO(oth): The VisitVariableAssignment() call is hard to reason about.
2198 // Is the value in the accumulator safe? Yes, but scary. 2200 // Is the value in the accumulator safe? Yes, but scary.
2199 Variable* variable = expr->target()->AsVariableProxy()->var(); 2201 Variable* variable = expr->target()->AsVariableProxy()->var();
2200 VisitVariableAssignment(variable, expr->op(), slot); 2202 VisitVariableAssignment(variable, expr->op(), slot);
2201 break; 2203 break;
2202 } 2204 }
2203 case NAMED_PROPERTY: 2205 case NAMED_PROPERTY:
(...skipping 17 matching lines...) Expand all
2221 } 2223 }
2222 execution_result()->SetResultInAccumulator(); 2224 execution_result()->SetResultInAccumulator();
2223 } 2225 }
2224 2226
2225 2227
2226 void BytecodeGenerator::VisitYield(Yield* expr) { UNIMPLEMENTED(); } 2228 void BytecodeGenerator::VisitYield(Yield* expr) { UNIMPLEMENTED(); }
2227 2229
2228 2230
2229 void BytecodeGenerator::VisitThrow(Throw* expr) { 2231 void BytecodeGenerator::VisitThrow(Throw* expr) {
2230 VisitForAccumulatorValue(expr->exception()); 2232 VisitForAccumulatorValue(expr->exception());
2233 builder()->SetExpressionPosition(expr);
2231 builder()->Throw(); 2234 builder()->Throw();
2232 // Throw statments are modeled as expression instead of statments. These are 2235 // Throw statments are modeled as expression instead of statments. These are
2233 // converted from assignment statements in Rewriter::ReWrite pass. An 2236 // converted from assignment statements in Rewriter::ReWrite pass. An
2234 // assignment statement expects a value in the accumulator. This is a hack to 2237 // assignment statement expects a value in the accumulator. This is a hack to
2235 // avoid DCHECK fails assert accumulator has been set. 2238 // avoid DCHECK fails assert accumulator has been set.
2236 execution_result()->SetResultInAccumulator(); 2239 execution_result()->SetResultInAccumulator();
2237 } 2240 }
2238 2241
2239 2242
2240 void BytecodeGenerator::VisitPropertyLoad(Register obj, Property* expr) { 2243 void BytecodeGenerator::VisitPropertyLoad(Register obj, Property* expr) {
2241 LhsKind property_kind = Property::GetAssignType(expr); 2244 LhsKind property_kind = Property::GetAssignType(expr);
2242 FeedbackVectorSlot slot = expr->PropertyFeedbackSlot(); 2245 FeedbackVectorSlot slot = expr->PropertyFeedbackSlot();
2246 builder()->SetExpressionPosition(expr);
2243 switch (property_kind) { 2247 switch (property_kind) {
2244 case VARIABLE: 2248 case VARIABLE:
2245 UNREACHABLE(); 2249 UNREACHABLE();
2246 case NAMED_PROPERTY: { 2250 case NAMED_PROPERTY: {
2247 builder()->LoadNamedProperty(obj, 2251 builder()->LoadNamedProperty(obj,
2248 expr->key()->AsLiteral()->AsPropertyName(), 2252 expr->key()->AsLiteral()->AsPropertyName(),
2249 feedback_index(slot)); 2253 feedback_index(slot));
2250 break; 2254 break;
2251 } 2255 }
2252 case KEYED_PROPERTY: { 2256 case KEYED_PROPERTY: {
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
2741 // Save result for postfix expressions. 2745 // Save result for postfix expressions.
2742 if (is_postfix) { 2746 if (is_postfix) {
2743 old_value = register_allocator()->outer()->NewRegister(); 2747 old_value = register_allocator()->outer()->NewRegister();
2744 builder()->StoreAccumulatorInRegister(old_value); 2748 builder()->StoreAccumulatorInRegister(old_value);
2745 } 2749 }
2746 2750
2747 // Perform +1/-1 operation. 2751 // Perform +1/-1 operation.
2748 builder()->CountOperation(expr->binary_op()); 2752 builder()->CountOperation(expr->binary_op());
2749 2753
2750 // Store the value. 2754 // Store the value.
2755 builder()->SetExpressionPosition(expr);
2751 FeedbackVectorSlot feedback_slot = expr->CountSlot(); 2756 FeedbackVectorSlot feedback_slot = expr->CountSlot();
2752 switch (assign_type) { 2757 switch (assign_type) {
2753 case VARIABLE: { 2758 case VARIABLE: {
2754 Variable* variable = expr->expression()->AsVariableProxy()->var(); 2759 Variable* variable = expr->expression()->AsVariableProxy()->var();
2755 VisitVariableAssignment(variable, expr->op(), feedback_slot); 2760 VisitVariableAssignment(variable, expr->op(), feedback_slot);
2756 break; 2761 break;
2757 } 2762 }
2758 case NAMED_PROPERTY: { 2763 case NAMED_PROPERTY: {
2759 builder()->StoreNamedProperty(object, name, feedback_index(feedback_slot), 2764 builder()->StoreNamedProperty(object, name, feedback_index(feedback_slot),
2760 language_mode()); 2765 language_mode());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2800 default: 2805 default:
2801 VisitArithmeticExpression(binop); 2806 VisitArithmeticExpression(binop);
2802 break; 2807 break;
2803 } 2808 }
2804 } 2809 }
2805 2810
2806 2811
2807 void BytecodeGenerator::VisitCompareOperation(CompareOperation* expr) { 2812 void BytecodeGenerator::VisitCompareOperation(CompareOperation* expr) {
2808 Register lhs = VisitForRegisterValue(expr->left()); 2813 Register lhs = VisitForRegisterValue(expr->left());
2809 VisitForAccumulatorValue(expr->right()); 2814 VisitForAccumulatorValue(expr->right());
2815 builder()->SetExpressionPosition(expr);
2810 builder()->CompareOperation(expr->op(), lhs); 2816 builder()->CompareOperation(expr->op(), lhs);
2811 execution_result()->SetResultInAccumulator(); 2817 execution_result()->SetResultInAccumulator();
2812 } 2818 }
2813 2819
2814 2820
2815 void BytecodeGenerator::VisitArithmeticExpression(BinaryOperation* expr) { 2821 void BytecodeGenerator::VisitArithmeticExpression(BinaryOperation* expr) {
2816 Register lhs = VisitForRegisterValue(expr->left()); 2822 Register lhs = VisitForRegisterValue(expr->left());
2817 VisitForAccumulatorValue(expr->right()); 2823 VisitForAccumulatorValue(expr->right());
2818 builder()->BinaryOperation(expr->op(), lhs); 2824 builder()->BinaryOperation(expr->op(), lhs);
2819 execution_result()->SetResultInAccumulator(); 2825 execution_result()->SetResultInAccumulator();
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
3149 } 3155 }
3150 3156
3151 3157
3152 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { 3158 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const {
3153 return info()->feedback_vector()->GetIndex(slot); 3159 return info()->feedback_vector()->GetIndex(slot);
3154 } 3160 }
3155 3161
3156 } // namespace interpreter 3162 } // namespace interpreter
3157 } // namespace internal 3163 } // namespace internal
3158 } // namespace v8 3164 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/interpreter/source-position-table.cc » ('j') | test/message/message.status » ('J')

Powered by Google App Engine
This is Rietveld 408576698