OLD | NEW |
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 1937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1948 .LoadLiteral( | 1948 .LoadLiteral( |
1949 Smi::FromInt(execution_context()->scope()->start_position())) | 1949 Smi::FromInt(execution_context()->scope()->start_position())) |
1950 .StoreAccumulatorInRegister(position); | 1950 .StoreAccumulatorInRegister(position); |
1951 | 1951 |
1952 // Call ResolvePossiblyDirectEval and modify the callee. | 1952 // Call ResolvePossiblyDirectEval and modify the callee. |
1953 builder() | 1953 builder() |
1954 ->CallRuntime(Runtime::kResolvePossiblyDirectEval, callee_for_eval, 5) | 1954 ->CallRuntime(Runtime::kResolvePossiblyDirectEval, callee_for_eval, 5) |
1955 .StoreAccumulatorInRegister(callee); | 1955 .StoreAccumulatorInRegister(callee); |
1956 } | 1956 } |
1957 | 1957 |
1958 // TODO(rmcilroy): Use CallIC to allow call type feedback. | 1958 builder()->SetExpressionPosition(expr); |
1959 builder()->Call(callee, receiver, 1 + args->length(), | 1959 builder()->Call(callee, receiver, 1 + args->length(), |
1960 feedback_index(expr->CallFeedbackICSlot())); | 1960 feedback_index(expr->CallFeedbackICSlot())); |
1961 execution_result()->SetResultInAccumulator(); | 1961 execution_result()->SetResultInAccumulator(); |
1962 } | 1962 } |
1963 | 1963 |
1964 | 1964 |
1965 void BytecodeGenerator::VisitCallNew(CallNew* expr) { | 1965 void BytecodeGenerator::VisitCallNew(CallNew* expr) { |
1966 Register constructor = register_allocator()->NewRegister(); | 1966 Register constructor = register_allocator()->NewRegister(); |
1967 VisitForAccumulatorValue(expr->expression()); | 1967 VisitForAccumulatorValue(expr->expression()); |
1968 builder()->StoreAccumulatorInRegister(constructor); | 1968 builder()->StoreAccumulatorInRegister(constructor); |
1969 | 1969 |
1970 ZoneList<Expression*>* args = expr->arguments(); | 1970 ZoneList<Expression*>* args = expr->arguments(); |
1971 Register first_arg = VisitArguments(args); | 1971 Register first_arg = VisitArguments(args); |
| 1972 builder()->SetExpressionPosition(expr); |
1972 builder()->New(constructor, first_arg, args->length()); | 1973 builder()->New(constructor, first_arg, args->length()); |
1973 execution_result()->SetResultInAccumulator(); | 1974 execution_result()->SetResultInAccumulator(); |
1974 } | 1975 } |
1975 | 1976 |
1976 | 1977 |
1977 void BytecodeGenerator::VisitCallRuntime(CallRuntime* expr) { | 1978 void BytecodeGenerator::VisitCallRuntime(CallRuntime* expr) { |
1978 ZoneList<Expression*>* args = expr->arguments(); | 1979 ZoneList<Expression*>* args = expr->arguments(); |
1979 if (expr->is_jsruntime()) { | 1980 if (expr->is_jsruntime()) { |
1980 // Allocate a register for the receiver and load it with undefined. | 1981 // Allocate a register for the receiver and load it with undefined. |
1981 register_allocator()->PrepareForConsecutiveAllocations(1 + args->length()); | 1982 register_allocator()->PrepareForConsecutiveAllocations(1 + args->length()); |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2540 } | 2541 } |
2541 | 2542 |
2542 | 2543 |
2543 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 2544 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
2544 return info()->feedback_vector()->GetIndex(slot); | 2545 return info()->feedback_vector()->GetIndex(slot); |
2545 } | 2546 } |
2546 | 2547 |
2547 } // namespace interpreter | 2548 } // namespace interpreter |
2548 } // namespace internal | 2549 } // namespace internal |
2549 } // namespace v8 | 2550 } // namespace v8 |
OLD | NEW |