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

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

Issue 2552873003: [wasm][asm.js] Pass Script with Handle. (Closed)
Patch Set: re-enable tests Created 4 years 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 | « src/asmjs/asm-wasm-builder.h ('k') | test/cctest/asmjs/test-asm-typer.cc » ('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 29 matching lines...) Expand all
40 40
41 struct ForeignVariable { 41 struct ForeignVariable {
42 Handle<Name> name; 42 Handle<Name> name;
43 Variable* var; 43 Variable* var;
44 LocalType type; 44 LocalType type;
45 }; 45 };
46 46
47 class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> { 47 class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
48 public: 48 public:
49 AsmWasmBuilderImpl(Isolate* isolate, Zone* zone, 49 AsmWasmBuilderImpl(Isolate* isolate, Zone* zone,
50 AstValueFactory* ast_value_factory, Script* script, 50 AstValueFactory* ast_value_factory, Handle<Script> script,
51 FunctionLiteral* literal, AsmTyper* typer) 51 FunctionLiteral* literal, AsmTyper* typer)
52 : local_variables_(ZoneHashMap::kDefaultHashMapCapacity, 52 : local_variables_(ZoneHashMap::kDefaultHashMapCapacity,
53 ZoneAllocationPolicy(zone)), 53 ZoneAllocationPolicy(zone)),
54 functions_(ZoneHashMap::kDefaultHashMapCapacity, 54 functions_(ZoneHashMap::kDefaultHashMapCapacity,
55 ZoneAllocationPolicy(zone)), 55 ZoneAllocationPolicy(zone)),
56 global_variables_(ZoneHashMap::kDefaultHashMapCapacity, 56 global_variables_(ZoneHashMap::kDefaultHashMapCapacity,
57 ZoneAllocationPolicy(zone)), 57 ZoneAllocationPolicy(zone)),
58 scope_(kModuleScope), 58 scope_(kModuleScope),
59 builder_(new (zone) WasmModuleBuilder(zone)), 59 builder_(new (zone) WasmModuleBuilder(zone)),
60 current_function_builder_(nullptr), 60 current_function_builder_(nullptr),
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 DCHECK_EQ(kModuleScope, scope_); 132 DCHECK_EQ(kModuleScope, scope_);
133 DCHECK_NULL(current_function_builder_); 133 DCHECK_NULL(current_function_builder_);
134 FunctionLiteral* old_func = decl->fun(); 134 FunctionLiteral* old_func = decl->fun();
135 Zone zone(isolate_->allocator(), ZONE_NAME); 135 Zone zone(isolate_->allocator(), ZONE_NAME);
136 DeclarationScope* new_func_scope = nullptr; 136 DeclarationScope* new_func_scope = nullptr;
137 if (decl->fun()->body() == nullptr) { 137 if (decl->fun()->body() == nullptr) {
138 // TODO(bradnelson): Refactor parser so we don't need a 138 // TODO(bradnelson): Refactor parser so we don't need a
139 // SharedFunctionInfo to parse a single function, 139 // SharedFunctionInfo to parse a single function,
140 // or squirrel away the SharedFunctionInfo to use later. 140 // or squirrel away the SharedFunctionInfo to use later.
141 Handle<SharedFunctionInfo> shared = 141 Handle<SharedFunctionInfo> shared =
142 isolate_->factory()->NewSharedFunctionInfoForLiteral( 142 isolate_->factory()->NewSharedFunctionInfoForLiteral(decl->fun(),
143 decl->fun(), handle(script_, isolate_)); 143 script_);
144 shared->set_is_toplevel(false); 144 shared->set_is_toplevel(false);
145 ParseInfo info(&zone, handle(script_, isolate_)); 145 ParseInfo info(&zone, script_);
146 info.set_shared_info(shared); 146 info.set_shared_info(shared);
147 info.set_toplevel(false); 147 info.set_toplevel(false);
148 info.set_language_mode(decl->fun()->scope()->language_mode()); 148 info.set_language_mode(decl->fun()->scope()->language_mode());
149 info.set_allow_lazy_parsing(false); 149 info.set_allow_lazy_parsing(false);
150 info.set_function_literal_id(shared->function_literal_id()); 150 info.set_function_literal_id(shared->function_literal_id());
151 info.set_ast_value_factory(ast_value_factory_); 151 info.set_ast_value_factory(ast_value_factory_);
152 info.set_ast_value_factory_owned(false); 152 info.set_ast_value_factory_owned(false);
153 // Create fresh function scope to use to parse the function in. 153 // Create fresh function scope to use to parse the function in.
154 new_func_scope = new (info.zone()) DeclarationScope( 154 new_func_scope = new (info.zone()) DeclarationScope(
155 info.zone(), decl->fun()->scope()->outer_scope(), FUNCTION_SCOPE); 155 info.zone(), decl->fun()->scope()->outer_scope(), FUNCTION_SCOPE);
(...skipping 1758 matching lines...) Expand 10 before | Expand all | Expand 10 after
1914 ZoneHashMap local_variables_; 1914 ZoneHashMap local_variables_;
1915 ZoneHashMap functions_; 1915 ZoneHashMap functions_;
1916 ZoneHashMap global_variables_; 1916 ZoneHashMap global_variables_;
1917 AsmScope scope_; 1917 AsmScope scope_;
1918 WasmModuleBuilder* builder_; 1918 WasmModuleBuilder* builder_;
1919 WasmFunctionBuilder* current_function_builder_; 1919 WasmFunctionBuilder* current_function_builder_;
1920 FunctionLiteral* literal_; 1920 FunctionLiteral* literal_;
1921 Isolate* isolate_; 1921 Isolate* isolate_;
1922 Zone* zone_; 1922 Zone* zone_;
1923 AstValueFactory* ast_value_factory_; 1923 AstValueFactory* ast_value_factory_;
1924 Script* script_; 1924 Handle<Script> script_;
1925 AsmTyper* typer_; 1925 AsmTyper* typer_;
1926 bool typer_failed_; 1926 bool typer_failed_;
1927 ZoneVector<std::pair<BreakableStatement*, bool>> breakable_blocks_; 1927 ZoneVector<std::pair<BreakableStatement*, bool>> breakable_blocks_;
1928 ZoneVector<ForeignVariable> foreign_variables_; 1928 ZoneVector<ForeignVariable> foreign_variables_;
1929 WasmFunctionBuilder* init_function_; 1929 WasmFunctionBuilder* init_function_;
1930 WasmFunctionBuilder* foreign_init_function_; 1930 WasmFunctionBuilder* foreign_init_function_;
1931 uint32_t next_table_index_; 1931 uint32_t next_table_index_;
1932 ZoneHashMap function_tables_; 1932 ZoneHashMap function_tables_;
1933 ImportedFunctionTable imported_function_table_; 1933 ImportedFunctionTable imported_function_table_;
1934 1934
1935 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); 1935 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
1936 1936
1937 private: 1937 private:
1938 DISALLOW_COPY_AND_ASSIGN(AsmWasmBuilderImpl); 1938 DISALLOW_COPY_AND_ASSIGN(AsmWasmBuilderImpl);
1939 }; 1939 };
1940 1940
1941 AsmWasmBuilder::AsmWasmBuilder(Isolate* isolate, Zone* zone, 1941 AsmWasmBuilder::AsmWasmBuilder(Isolate* isolate, Zone* zone,
1942 AstValueFactory* ast_value_factory, 1942 AstValueFactory* ast_value_factory,
1943 Script* script, FunctionLiteral* literal) 1943 Handle<Script> script, FunctionLiteral* literal)
1944 : isolate_(isolate), 1944 : isolate_(isolate),
1945 zone_(zone), 1945 zone_(zone),
1946 ast_value_factory_(ast_value_factory), 1946 ast_value_factory_(ast_value_factory),
1947 script_(script), 1947 script_(script),
1948 literal_(literal), 1948 literal_(literal),
1949 typer_(isolate, zone, script, literal) {} 1949 typer_(isolate, zone, script, literal) {}
1950 1950
1951 // TODO(aseemgarg): probably should take zone (to write wasm to) as input so 1951 // TODO(aseemgarg): probably should take zone (to write wasm to) as input so
1952 // that zone in constructor may be thrown away once wasm module is written. 1952 // that zone in constructor may be thrown away once wasm module is written.
1953 AsmWasmBuilder::Result AsmWasmBuilder::Run(Handle<FixedArray>* foreign_args) { 1953 AsmWasmBuilder::Result AsmWasmBuilder::Run(Handle<FixedArray>* foreign_args) {
1954 AsmWasmBuilderImpl impl(isolate_, zone_, ast_value_factory_, script_, 1954 AsmWasmBuilderImpl impl(isolate_, zone_, ast_value_factory_, script_,
1955 literal_, &typer_); 1955 literal_, &typer_);
1956 bool success = impl.Build(); 1956 bool success = impl.Build();
1957 *foreign_args = impl.GetForeignArgs(); 1957 *foreign_args = impl.GetForeignArgs();
1958 ZoneBuffer* module_buffer = new (zone_) ZoneBuffer(zone_); 1958 ZoneBuffer* module_buffer = new (zone_) ZoneBuffer(zone_);
1959 impl.builder_->WriteTo(*module_buffer); 1959 impl.builder_->WriteTo(*module_buffer);
1960 ZoneBuffer* asm_offsets_buffer = new (zone_) ZoneBuffer(zone_); 1960 ZoneBuffer* asm_offsets_buffer = new (zone_) ZoneBuffer(zone_);
1961 impl.builder_->WriteAsmJsOffsetTable(*asm_offsets_buffer); 1961 impl.builder_->WriteAsmJsOffsetTable(*asm_offsets_buffer);
1962 return {module_buffer, asm_offsets_buffer, success}; 1962 return {module_buffer, asm_offsets_buffer, success};
1963 } 1963 }
1964 1964
1965 const char* AsmWasmBuilder::foreign_init_name = "__foreign_init__"; 1965 const char* AsmWasmBuilder::foreign_init_name = "__foreign_init__";
1966 const char* AsmWasmBuilder::single_function_name = "__single_function__"; 1966 const char* AsmWasmBuilder::single_function_name = "__single_function__";
1967 1967
1968 } // namespace wasm 1968 } // namespace wasm
1969 } // namespace internal 1969 } // namespace internal
1970 } // namespace v8 1970 } // namespace v8
OLDNEW
« no previous file with comments | « src/asmjs/asm-wasm-builder.h ('k') | test/cctest/asmjs/test-asm-typer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698