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/api-natives.h" | 5 #include "src/api-natives.h" |
6 #include "src/api.h" | 6 #include "src/api.h" |
7 #include "src/assert-scope.h" | 7 #include "src/assert-scope.h" |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/execution.h" | 10 #include "src/execution.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 134 |
135 if (!i::Compiler::ParseAndAnalyze(info)) { | 135 if (!i::Compiler::ParseAndAnalyze(info)) { |
136 return nullptr; | 136 return nullptr; |
137 } | 137 } |
138 | 138 |
139 if (info->scope()->declarations()->length() == 0) { | 139 if (info->scope()->declarations()->length() == 0) { |
140 thrower->Error("Asm.js validation failed: no declarations in scope"); | 140 thrower->Error("Asm.js validation failed: no declarations in scope"); |
141 return nullptr; | 141 return nullptr; |
142 } | 142 } |
143 | 143 |
| 144 if (!info->scope()->declarations()->at(0)->IsFunctionDeclaration()) { |
| 145 thrower->Error("Asm.js validation failed: non-function declaration"); |
| 146 return nullptr; |
| 147 } |
| 148 |
144 info->set_literal( | 149 info->set_literal( |
145 info->scope()->declarations()->at(0)->AsFunctionDeclaration()->fun()); | 150 info->scope()->declarations()->at(0)->AsFunctionDeclaration()->fun()); |
146 | 151 |
147 v8::internal::AsmTyper typer(info->isolate(), info->zone(), *(info->script()), | 152 v8::internal::AsmTyper typer(info->isolate(), info->zone(), *(info->script()), |
148 info->literal()); | 153 info->literal()); |
149 if (i::FLAG_enable_simd_asmjs) { | 154 if (i::FLAG_enable_simd_asmjs) { |
150 typer.set_allow_simd(true); | 155 typer.set_allow_simd(true); |
151 } | 156 } |
152 if (!typer.Validate()) { | 157 if (!typer.Validate()) { |
153 thrower->Error("Asm.js validation failed: %s", typer.error_message()); | 158 thrower->Error("Asm.js validation failed: %s", typer.error_message()); |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 int unused_property_fields = in_object_properties - pre_allocated; | 492 int unused_property_fields = in_object_properties - pre_allocated; |
488 Handle<Map> map = Map::CopyInitialMap( | 493 Handle<Map> map = Map::CopyInitialMap( |
489 prev_map, instance_size, in_object_properties, unused_property_fields); | 494 prev_map, instance_size, in_object_properties, unused_property_fields); |
490 | 495 |
491 context->set_wasm_function_map(*map); | 496 context->set_wasm_function_map(*map); |
492 } | 497 } |
493 } | 498 } |
494 | 499 |
495 } // namespace internal | 500 } // namespace internal |
496 } // namespace v8 | 501 } // namespace v8 |
OLD | NEW |