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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 // Required to get M_E etc. in MSVC. | 7 // Required to get M_E etc. in MSVC. |
8 #if defined(_WIN32) | 8 #if defined(_WIN32) |
9 #define _USE_MATH_DEFINES | 9 #define _USE_MATH_DEFINES |
10 #endif | 10 #endif |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 init_function_->Emit(kExprEnd); // finish init function. | 135 init_function_->Emit(kExprEnd); // finish init function. |
136 return true; | 136 return true; |
137 } | 137 } |
138 | 138 |
139 void VisitVariableDeclaration(VariableDeclaration* decl) {} | 139 void VisitVariableDeclaration(VariableDeclaration* decl) {} |
140 | 140 |
141 void VisitFunctionDeclaration(FunctionDeclaration* decl) { | 141 void VisitFunctionDeclaration(FunctionDeclaration* decl) { |
142 DCHECK_EQ(kModuleScope, scope_); | 142 DCHECK_EQ(kModuleScope, scope_); |
143 DCHECK_NULL(current_function_builder_); | 143 DCHECK_NULL(current_function_builder_); |
144 FunctionLiteral* old_func = decl->fun(); | 144 FunctionLiteral* old_func = decl->fun(); |
145 Zone zone(isolate_->allocator(), ZONE_NAME); | |
146 DeclarationScope* new_func_scope = nullptr; | 145 DeclarationScope* new_func_scope = nullptr; |
146 std::unique_ptr<ParseInfo> info; | |
marja
2017/01/17 15:39:08
Hmm, now the Zone cannot outlive ParseInfo? That s
rmcilroy
2017/01/19 12:48:29
Acknowledged.
| |
147 if (decl->fun()->body() == nullptr) { | 147 if (decl->fun()->body() == nullptr) { |
148 // TODO(titzer/bradnelson): Reuse SharedFunctionInfos used here when | 148 // TODO(titzer/bradnelson): Reuse SharedFunctionInfos used here when |
149 // compiling the wasm module. | 149 // compiling the wasm module. |
150 Handle<SharedFunctionInfo> shared = | 150 Handle<SharedFunctionInfo> shared = |
151 Compiler::GetSharedFunctionInfo(decl->fun(), script_, info_); | 151 Compiler::GetSharedFunctionInfo(decl->fun(), script_, info_); |
152 shared->set_is_toplevel(false); | 152 shared->set_is_toplevel(false); |
153 ParseInfo info(&zone, script_); | 153 info.reset(new ParseInfo(script_)); |
154 info.set_shared_info(shared); | 154 info->set_shared_info(shared); |
155 info.set_toplevel(false); | 155 info->set_toplevel(false); |
156 info.set_language_mode(decl->fun()->scope()->language_mode()); | 156 info->set_language_mode(decl->fun()->scope()->language_mode()); |
157 info.set_allow_lazy_parsing(false); | 157 info->set_allow_lazy_parsing(false); |
158 info.set_function_literal_id(shared->function_literal_id()); | 158 info->set_function_literal_id(shared->function_literal_id()); |
159 info.set_ast_value_factory(ast_value_factory_); | 159 info->set_ast_value_factory(ast_value_factory_); |
160 info.set_ast_value_factory_owned(false); | 160 info->set_ast_value_factory_owned(false); |
161 // Create fresh function scope to use to parse the function in. | 161 // Create fresh function scope to use to parse the function in. |
162 new_func_scope = new (info.zone()) DeclarationScope( | 162 new_func_scope = new (info->zone()) DeclarationScope( |
163 info.zone(), decl->fun()->scope()->outer_scope(), FUNCTION_SCOPE); | 163 info->zone(), decl->fun()->scope()->outer_scope(), FUNCTION_SCOPE); |
164 info.set_asm_function_scope(new_func_scope); | 164 info->set_asm_function_scope(new_func_scope); |
165 if (!Compiler::ParseAndAnalyze(&info)) { | 165 if (!Compiler::ParseAndAnalyze(info.get())) { |
166 typer_failed_ = true; | 166 typer_failed_ = true; |
167 return; | 167 return; |
168 } | 168 } |
169 FunctionLiteral* func = info.literal(); | 169 FunctionLiteral* func = info->literal(); |
170 DCHECK_NOT_NULL(func); | 170 DCHECK_NOT_NULL(func); |
171 decl->set_fun(func); | 171 decl->set_fun(func); |
172 } | 172 } |
173 if (!typer_->ValidateInnerFunction(decl)) { | 173 if (!typer_->ValidateInnerFunction(decl)) { |
174 typer_failed_ = true; | 174 typer_failed_ = true; |
175 decl->set_fun(old_func); | 175 decl->set_fun(old_func); |
176 if (new_func_scope != nullptr) { | 176 if (new_func_scope != nullptr) { |
177 DCHECK_EQ(new_func_scope, decl->scope()->inner_scope()); | 177 DCHECK_EQ(new_func_scope, decl->scope()->inner_scope()); |
178 if (!decl->scope()->RemoveInnerScope(new_func_scope)) { | 178 if (!decl->scope()->RemoveInnerScope(new_func_scope)) { |
179 UNREACHABLE(); | 179 UNREACHABLE(); |
(...skipping 1821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2001 impl.builder_->WriteAsmJsOffsetTable(*asm_offsets_buffer); | 2001 impl.builder_->WriteAsmJsOffsetTable(*asm_offsets_buffer); |
2002 return {module_buffer, asm_offsets_buffer, success}; | 2002 return {module_buffer, asm_offsets_buffer, success}; |
2003 } | 2003 } |
2004 | 2004 |
2005 const char* AsmWasmBuilder::foreign_init_name = "__foreign_init__"; | 2005 const char* AsmWasmBuilder::foreign_init_name = "__foreign_init__"; |
2006 const char* AsmWasmBuilder::single_function_name = "__single_function__"; | 2006 const char* AsmWasmBuilder::single_function_name = "__single_function__"; |
2007 | 2007 |
2008 } // namespace wasm | 2008 } // namespace wasm |
2009 } // namespace internal | 2009 } // namespace internal |
2010 } // namespace v8 | 2010 } // namespace v8 |
OLD | NEW |