Chromium Code Reviews| 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/compile-time-value.h" | 7 #include "src/ast/compile-time-value.h" |
| 8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/compilation-info.h" | 10 #include "src/compilation-info.h" |
| (...skipping 1987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1998 ModuleDescriptor* descriptor = scope()->GetModuleScope()->module(); | 1998 ModuleDescriptor* descriptor = scope()->GetModuleScope()->module(); |
| 1999 if (variable->IsExport()) { | 1999 if (variable->IsExport()) { |
| 2000 auto it = descriptor->regular_exports().find(variable->raw_name()); | 2000 auto it = descriptor->regular_exports().find(variable->raw_name()); |
| 2001 DCHECK(it != descriptor->regular_exports().end()); | 2001 DCHECK(it != descriptor->regular_exports().end()); |
| 2002 Register export_name = register_allocator()->NewRegister(); | 2002 Register export_name = register_allocator()->NewRegister(); |
| 2003 builder() | 2003 builder() |
| 2004 ->LoadLiteral(it->second->export_name->string()) | 2004 ->LoadLiteral(it->second->export_name->string()) |
| 2005 .StoreAccumulatorInRegister(export_name) | 2005 .StoreAccumulatorInRegister(export_name) |
| 2006 .CallRuntime(Runtime::kLoadModuleExport, export_name, 1); | 2006 .CallRuntime(Runtime::kLoadModuleExport, export_name, 1); |
| 2007 } else { | 2007 } else { |
| 2008 UNIMPLEMENTED(); | 2008 auto it = descriptor->regular_imports().find(variable->raw_name()); |
|
rmcilroy
2016/09/22 10:18:13
Could you add some tests to test-bytecode-generato
| |
| 2009 DCHECK(it != descriptor->regular_imports().end()); | |
| 2010 register_allocator()->PrepareForConsecutiveAllocations(2); | |
| 2011 Register import_name = register_allocator()->NextConsecutiveRegister(); | |
| 2012 Register module_request = | |
| 2013 register_allocator()->NextConsecutiveRegister(); | |
| 2014 builder() | |
| 2015 ->LoadLiteral(it->second->import_name->string()) | |
| 2016 .StoreAccumulatorInRegister(import_name) | |
| 2017 .LoadLiteral(Smi::FromInt(it->second->module_request)) | |
| 2018 .StoreAccumulatorInRegister(module_request) | |
| 2019 .CallRuntime(Runtime::kLoadModuleImport, import_name, 2); | |
| 2009 } | 2020 } |
| 2010 break; | 2021 break; |
| 2011 } | 2022 } |
| 2012 } | 2023 } |
| 2013 execution_result()->SetResultInAccumulator(); | 2024 execution_result()->SetResultInAccumulator(); |
| 2014 } | 2025 } |
| 2015 | 2026 |
| 2016 void BytecodeGenerator::VisitVariableLoadForAccumulatorValue( | 2027 void BytecodeGenerator::VisitVariableLoadForAccumulatorValue( |
| 2017 Variable* variable, FeedbackVectorSlot slot, TypeofMode typeof_mode) { | 2028 Variable* variable, FeedbackVectorSlot slot, TypeofMode typeof_mode) { |
| 2018 AccumulatorResultScope accumulator_result(this); | 2029 AccumulatorResultScope accumulator_result(this); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2198 builder()->CallRuntime(Runtime::kThrowConstAssignError, Register(), 0); | 2209 builder()->CallRuntime(Runtime::kThrowConstAssignError, Register(), 0); |
| 2199 break; | 2210 break; |
| 2200 } | 2211 } |
| 2201 | 2212 |
| 2202 // If we don't throw above, we know that we're dealing with an | 2213 // If we don't throw above, we know that we're dealing with an |
| 2203 // export because imports are const and we do not generate initializing | 2214 // export because imports are const and we do not generate initializing |
| 2204 // assignments for them. | 2215 // assignments for them. |
| 2205 DCHECK(variable->IsExport()); | 2216 DCHECK(variable->IsExport()); |
| 2206 | 2217 |
| 2207 ModuleDescriptor* mod = scope()->GetModuleScope()->module(); | 2218 ModuleDescriptor* mod = scope()->GetModuleScope()->module(); |
| 2219 // There may be several export names for this local name, but it doesn't | |
| 2220 // matter which one we pick, as they all map to the same cell. | |
| 2208 auto it = mod->regular_exports().find(variable->raw_name()); | 2221 auto it = mod->regular_exports().find(variable->raw_name()); |
| 2209 DCHECK(it != mod->regular_exports().end()); | 2222 DCHECK(it != mod->regular_exports().end()); |
| 2210 | 2223 |
| 2211 register_allocator()->PrepareForConsecutiveAllocations(2); | 2224 register_allocator()->PrepareForConsecutiveAllocations(2); |
| 2212 Register export_name = register_allocator()->NextConsecutiveRegister(); | 2225 Register export_name = register_allocator()->NextConsecutiveRegister(); |
| 2213 Register value = register_allocator()->NextConsecutiveRegister(); | 2226 Register value = register_allocator()->NextConsecutiveRegister(); |
| 2214 builder() | 2227 builder() |
| 2215 ->StoreAccumulatorInRegister(value) | 2228 ->StoreAccumulatorInRegister(value) |
| 2216 .LoadLiteral(it->second->export_name->string()) | 2229 .LoadLiteral(it->second->export_name->string()) |
| 2217 .StoreAccumulatorInRegister(export_name) | 2230 .StoreAccumulatorInRegister(export_name) |
| (...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3450 return execution_context()->scope()->language_mode(); | 3463 return execution_context()->scope()->language_mode(); |
| 3451 } | 3464 } |
| 3452 | 3465 |
| 3453 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3466 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
| 3454 return TypeFeedbackVector::GetIndex(slot); | 3467 return TypeFeedbackVector::GetIndex(slot); |
| 3455 } | 3468 } |
| 3456 | 3469 |
| 3457 } // namespace interpreter | 3470 } // namespace interpreter |
| 3458 } // namespace internal | 3471 } // namespace internal |
| 3459 } // namespace v8 | 3472 } // namespace v8 |
| OLD | NEW |