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

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

Issue 2242583003: [Parser] Remove Variable::is_possibly_eval. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@toon_cl
Patch Set: Address comment Created 4 years, 4 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 | « src/globals.h ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »
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/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/compiler.h" 9 #include "src/compiler.h"
10 #include "src/interpreter/bytecode-flags.h" 10 #include "src/interpreter/bytecode-flags.h"
(...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 loop_builder.EndLoop(); 1163 loop_builder.EndLoop();
1164 } 1164 }
1165 1165
1166 void BytecodeGenerator::VisitForInAssignment(Expression* expr, 1166 void BytecodeGenerator::VisitForInAssignment(Expression* expr,
1167 FeedbackVectorSlot slot) { 1167 FeedbackVectorSlot slot) {
1168 DCHECK(expr->IsValidReferenceExpression()); 1168 DCHECK(expr->IsValidReferenceExpression());
1169 1169
1170 // Evaluate assignment starting with the value to be stored in the 1170 // Evaluate assignment starting with the value to be stored in the
1171 // accumulator. 1171 // accumulator.
1172 Property* property = expr->AsProperty(); 1172 Property* property = expr->AsProperty();
1173 LhsKind assign_type = 1173 LhsKind assign_type = Property::GetAssignType(property);
1174 Property::GetAssignType(property, HandleDereferenceMode::kDisallowed);
1175 switch (assign_type) { 1174 switch (assign_type) {
1176 case VARIABLE: { 1175 case VARIABLE: {
1177 Variable* variable = expr->AsVariableProxy()->var(); 1176 Variable* variable = expr->AsVariableProxy()->var();
1178 VisitVariableAssignment(variable, Token::ASSIGN, slot); 1177 VisitVariableAssignment(variable, Token::ASSIGN, slot);
1179 break; 1178 break;
1180 } 1179 }
1181 case NAMED_PROPERTY: { 1180 case NAMED_PROPERTY: {
1182 RegisterAllocationScope register_scope(this); 1181 RegisterAllocationScope register_scope(this);
1183 Register value = register_allocator()->NewRegister(); 1182 Register value = register_allocator()->NewRegister();
1184 builder()->StoreAccumulatorInRegister(value); 1183 builder()->StoreAccumulatorInRegister(value);
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after
2133 } 2132 }
2134 } 2133 }
2135 2134
2136 void BytecodeGenerator::VisitAssignment(Assignment* expr) { 2135 void BytecodeGenerator::VisitAssignment(Assignment* expr) {
2137 DCHECK(expr->target()->IsValidReferenceExpressionOrThis()); 2136 DCHECK(expr->target()->IsValidReferenceExpressionOrThis());
2138 Register object, key, home_object, value; 2137 Register object, key, home_object, value;
2139 Handle<String> name; 2138 Handle<String> name;
2140 2139
2141 // Left-hand side can only be a property, a global or a variable slot. 2140 // Left-hand side can only be a property, a global or a variable slot.
2142 Property* property = expr->target()->AsProperty(); 2141 Property* property = expr->target()->AsProperty();
2143 LhsKind assign_type = 2142 LhsKind assign_type = Property::GetAssignType(property);
2144 Property::GetAssignType(property, HandleDereferenceMode::kDisallowed);
2145 2143
2146 // Evaluate LHS expression. 2144 // Evaluate LHS expression.
2147 switch (assign_type) { 2145 switch (assign_type) {
2148 case VARIABLE: 2146 case VARIABLE:
2149 // Nothing to do to evaluate variable assignment LHS. 2147 // Nothing to do to evaluate variable assignment LHS.
2150 break; 2148 break;
2151 case NAMED_PROPERTY: { 2149 case NAMED_PROPERTY: {
2152 object = VisitForRegisterValue(property->obj()); 2150 object = VisitForRegisterValue(property->obj());
2153 name = property->key()->AsLiteral()->AsPropertyName(); 2151 name = property->key()->AsLiteral()->AsPropertyName();
2154 break; 2152 break;
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
2364 builder()->SetExpressionPosition(expr); 2362 builder()->SetExpressionPosition(expr);
2365 builder()->Throw(); 2363 builder()->Throw();
2366 // Throw statements are modeled as expressions instead of statements. These 2364 // Throw statements are modeled as expressions instead of statements. These
2367 // are converted from assignment statements in Rewriter::ReWrite pass. An 2365 // are converted from assignment statements in Rewriter::ReWrite pass. An
2368 // assignment statement expects a value in the accumulator. This is a hack to 2366 // assignment statement expects a value in the accumulator. This is a hack to
2369 // avoid DCHECK fails assert accumulator has been set. 2367 // avoid DCHECK fails assert accumulator has been set.
2370 execution_result()->SetResultInAccumulator(); 2368 execution_result()->SetResultInAccumulator();
2371 } 2369 }
2372 2370
2373 void BytecodeGenerator::VisitPropertyLoad(Register obj, Property* expr) { 2371 void BytecodeGenerator::VisitPropertyLoad(Register obj, Property* expr) {
2374 LhsKind property_kind = 2372 LhsKind property_kind = Property::GetAssignType(expr);
2375 Property::GetAssignType(expr, HandleDereferenceMode::kDisallowed);
2376 FeedbackVectorSlot slot = expr->PropertyFeedbackSlot(); 2373 FeedbackVectorSlot slot = expr->PropertyFeedbackSlot();
2377 builder()->SetExpressionPosition(expr); 2374 builder()->SetExpressionPosition(expr);
2378 switch (property_kind) { 2375 switch (property_kind) {
2379 case VARIABLE: 2376 case VARIABLE:
2380 UNREACHABLE(); 2377 UNREACHABLE();
2381 case NAMED_PROPERTY: { 2378 case NAMED_PROPERTY: {
2382 builder()->LoadNamedProperty(obj, 2379 builder()->LoadNamedProperty(obj,
2383 expr->key()->AsLiteral()->AsPropertyName(), 2380 expr->key()->AsLiteral()->AsPropertyName(),
2384 feedback_index(slot)); 2381 feedback_index(slot));
2385 break; 2382 break;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2443 VisitForRegisterValue(super_property->home_object(), home_object); 2440 VisitForRegisterValue(super_property->home_object(), home_object);
2444 VisitForRegisterValue(property->key(), key); 2441 VisitForRegisterValue(property->key(), key);
2445 BuildKeyedSuperPropertyLoad(receiver, home_object, key); 2442 BuildKeyedSuperPropertyLoad(receiver, home_object, key);
2446 2443
2447 if (opt_receiver_out.is_valid()) { 2444 if (opt_receiver_out.is_valid()) {
2448 builder()->MoveRegister(receiver, opt_receiver_out); 2445 builder()->MoveRegister(receiver, opt_receiver_out);
2449 } 2446 }
2450 } 2447 }
2451 2448
2452 void BytecodeGenerator::VisitProperty(Property* expr) { 2449 void BytecodeGenerator::VisitProperty(Property* expr) {
2453 LhsKind property_kind = 2450 LhsKind property_kind = Property::GetAssignType(expr);
2454 Property::GetAssignType(expr, HandleDereferenceMode::kDisallowed);
2455 if (property_kind != NAMED_SUPER_PROPERTY && 2451 if (property_kind != NAMED_SUPER_PROPERTY &&
2456 property_kind != KEYED_SUPER_PROPERTY) { 2452 property_kind != KEYED_SUPER_PROPERTY) {
2457 Register obj = VisitForRegisterValue(expr->obj()); 2453 Register obj = VisitForRegisterValue(expr->obj());
2458 VisitPropertyLoad(obj, expr); 2454 VisitPropertyLoad(obj, expr);
2459 } else { 2455 } else {
2460 VisitPropertyLoad(Register::invalid_value(), expr); 2456 VisitPropertyLoad(Register::invalid_value(), expr);
2461 } 2457 }
2462 } 2458 }
2463 2459
2464 Register BytecodeGenerator::VisitArguments(ZoneList<Expression*>* args) { 2460 Register BytecodeGenerator::VisitArguments(ZoneList<Expression*>* args) {
(...skipping 23 matching lines...) Expand all
2488 Register ith_arg = register_allocator()->NextConsecutiveRegister(); 2484 Register ith_arg = register_allocator()->NextConsecutiveRegister();
2489 VisitForAccumulatorValue(args->at(i)); 2485 VisitForAccumulatorValue(args->at(i));
2490 builder()->StoreAccumulatorInRegister(ith_arg); 2486 builder()->StoreAccumulatorInRegister(ith_arg);
2491 DCHECK(ith_arg.index() - i == first_arg.index()); 2487 DCHECK(ith_arg.index() - i == first_arg.index());
2492 } 2488 }
2493 return first_arg; 2489 return first_arg;
2494 } 2490 }
2495 2491
2496 void BytecodeGenerator::VisitCall(Call* expr) { 2492 void BytecodeGenerator::VisitCall(Call* expr) {
2497 Expression* callee_expr = expr->expression(); 2493 Expression* callee_expr = expr->expression();
2498 Call::CallType call_type = 2494 Call::CallType call_type = expr->GetCallType();
2499 expr->GetCallType(isolate(), HandleDereferenceMode::kDisallowed);
2500 2495
2501 if (call_type == Call::SUPER_CALL) { 2496 if (call_type == Call::SUPER_CALL) {
2502 return VisitCallSuper(expr); 2497 return VisitCallSuper(expr);
2503 } 2498 }
2504 2499
2505 // Prepare the callee and the receiver to the function call. This depends on 2500 // Prepare the callee and the receiver to the function call. This depends on
2506 // the semantics of the underlying call type. 2501 // the semantics of the underlying call type.
2507 2502
2508 // The receiver and arguments need to be allocated consecutively for 2503 // The receiver and arguments need to be allocated consecutively for
2509 // Call(). We allocate the callee and receiver consecutively for calls to 2504 // Call(). We allocate the callee and receiver consecutively for calls to
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
2807 builder()->LoadTrue(); 2802 builder()->LoadTrue();
2808 } 2803 }
2809 execution_result()->SetResultInAccumulator(); 2804 execution_result()->SetResultInAccumulator();
2810 } 2805 }
2811 2806
2812 void BytecodeGenerator::VisitCountOperation(CountOperation* expr) { 2807 void BytecodeGenerator::VisitCountOperation(CountOperation* expr) {
2813 DCHECK(expr->expression()->IsValidReferenceExpressionOrThis()); 2808 DCHECK(expr->expression()->IsValidReferenceExpressionOrThis());
2814 2809
2815 // Left-hand side can only be a property, a global or a variable slot. 2810 // Left-hand side can only be a property, a global or a variable slot.
2816 Property* property = expr->expression()->AsProperty(); 2811 Property* property = expr->expression()->AsProperty();
2817 LhsKind assign_type = 2812 LhsKind assign_type = Property::GetAssignType(property);
2818 Property::GetAssignType(property, HandleDereferenceMode::kDisallowed);
2819 2813
2820 bool is_postfix = expr->is_postfix() && !execution_result()->IsEffect(); 2814 bool is_postfix = expr->is_postfix() && !execution_result()->IsEffect();
2821 2815
2822 // Evaluate LHS expression and get old value. 2816 // Evaluate LHS expression and get old value.
2823 Register object, home_object, key, old_value, value; 2817 Register object, home_object, key, old_value, value;
2824 Handle<String> name; 2818 Handle<String> name;
2825 switch (assign_type) { 2819 switch (assign_type) {
2826 case VARIABLE: { 2820 case VARIABLE: {
2827 VariableProxy* proxy = expr->expression()->AsVariableProxy(); 2821 VariableProxy* proxy = expr->expression()->AsVariableProxy();
2828 VisitVariableLoadForAccumulatorValue(proxy->var(), 2822 VisitVariableLoadForAccumulatorValue(proxy->var(),
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
3277 return execution_context()->scope()->language_mode(); 3271 return execution_context()->scope()->language_mode();
3278 } 3272 }
3279 3273
3280 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { 3274 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const {
3281 return TypeFeedbackVector::GetIndex(slot); 3275 return TypeFeedbackVector::GetIndex(slot);
3282 } 3276 }
3283 3277
3284 } // namespace interpreter 3278 } // namespace interpreter
3285 } // namespace internal 3279 } // namespace internal
3286 } // namespace v8 3280 } // namespace v8
OLDNEW
« no previous file with comments | « src/globals.h ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698