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

Side by Side Diff: src/asmjs/asm-wasm-builder.cc

Issue 2632123006: Reland: [Parse] ParseInfo owns the parsing Zone. (Closed)
Patch Set: Rebase Created 3 years, 10 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 | « no previous file | src/background-parsing-task.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/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
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;
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 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 1823 matching lines...) Expand 10 before | Expand all | Expand 10 after
2008 impl.builder_->WriteAsmJsOffsetTable(*asm_offsets_buffer); 2008 impl.builder_->WriteAsmJsOffsetTable(*asm_offsets_buffer);
2009 return {module_buffer, asm_offsets_buffer, success}; 2009 return {module_buffer, asm_offsets_buffer, success};
2010 } 2010 }
2011 2011
2012 const char* AsmWasmBuilder::foreign_init_name = "__foreign_init__"; 2012 const char* AsmWasmBuilder::foreign_init_name = "__foreign_init__";
2013 const char* AsmWasmBuilder::single_function_name = "__single_function__"; 2013 const char* AsmWasmBuilder::single_function_name = "__single_function__";
2014 2014
2015 } // namespace wasm 2015 } // namespace wasm
2016 } // namespace internal 2016 } // namespace internal
2017 } // namespace v8 2017 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/background-parsing-task.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698