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); |
145 DeclarationScope* new_func_scope = nullptr; | 146 DeclarationScope* new_func_scope = nullptr; |
146 std::unique_ptr<ParseInfo> info; | |
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 info.reset(new ParseInfo(script_)); | 153 ParseInfo info(&zone, 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.get())) { | 165 if (!Compiler::ParseAndAnalyze(&info)) { |
166 decl->fun()->scope()->outer_scope()->RemoveInnerScope(new_func_scope); | 166 decl->fun()->scope()->outer_scope()->RemoveInnerScope(new_func_scope); |
167 if (isolate_->has_pending_exception()) { | 167 if (isolate_->has_pending_exception()) { |
168 isolate_->clear_pending_exception(); | 168 isolate_->clear_pending_exception(); |
169 } | 169 } |
170 typer_->TriggerParsingError(); | 170 typer_->TriggerParsingError(); |
171 typer_failed_ = true; | 171 typer_failed_ = true; |
172 return; | 172 return; |
173 } | 173 } |
174 FunctionLiteral* func = info->literal(); | 174 FunctionLiteral* func = info.literal(); |
175 DCHECK_NOT_NULL(func); | 175 DCHECK_NOT_NULL(func); |
176 decl->set_fun(func); | 176 decl->set_fun(func); |
177 } | 177 } |
178 if (!typer_->ValidateInnerFunction(decl)) { | 178 if (!typer_->ValidateInnerFunction(decl)) { |
179 typer_failed_ = true; | 179 typer_failed_ = true; |
180 decl->set_fun(old_func); | 180 decl->set_fun(old_func); |
181 if (new_func_scope != nullptr) { | 181 if (new_func_scope != nullptr) { |
182 DCHECK_EQ(new_func_scope, decl->scope()->inner_scope()); | 182 DCHECK_EQ(new_func_scope, decl->scope()->inner_scope()); |
183 if (!decl->scope()->RemoveInnerScope(new_func_scope)) { | 183 if (!decl->scope()->RemoveInnerScope(new_func_scope)) { |
184 UNREACHABLE(); | 184 UNREACHABLE(); |
(...skipping 1821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2006 impl.builder_->WriteAsmJsOffsetTable(*asm_offsets_buffer); | 2006 impl.builder_->WriteAsmJsOffsetTable(*asm_offsets_buffer); |
2007 return {module_buffer, asm_offsets_buffer, success}; | 2007 return {module_buffer, asm_offsets_buffer, success}; |
2008 } | 2008 } |
2009 | 2009 |
2010 const char* AsmWasmBuilder::foreign_init_name = "__foreign_init__"; | 2010 const char* AsmWasmBuilder::foreign_init_name = "__foreign_init__"; |
2011 const char* AsmWasmBuilder::single_function_name = "__single_function__"; | 2011 const char* AsmWasmBuilder::single_function_name = "__single_function__"; |
2012 | 2012 |
2013 } // namespace wasm | 2013 } // namespace wasm |
2014 } // namespace internal | 2014 } // namespace internal |
2015 } // namespace v8 | 2015 } // namespace v8 |
OLD | NEW |