| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/asmjs/asm-typer.h" | 5 #include "src/asmjs/asm-typer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 forward_definitions_(zone), | 182 forward_definitions_(zone), |
| 183 ffi_use_signatures_(zone), | 183 ffi_use_signatures_(zone), |
| 184 stdlib_types_(zone), | 184 stdlib_types_(zone), |
| 185 stdlib_math_types_(zone), | 185 stdlib_math_types_(zone), |
| 186 module_info_(VariableInfo::ForSpecialSymbol(zone_, kModule)), | 186 module_info_(VariableInfo::ForSpecialSymbol(zone_, kModule)), |
| 187 global_scope_(ZoneHashMap::kDefaultHashMapCapacity, | 187 global_scope_(ZoneHashMap::kDefaultHashMapCapacity, |
| 188 ZoneAllocationPolicy(zone)), | 188 ZoneAllocationPolicy(zone)), |
| 189 local_scope_(ZoneHashMap::kDefaultHashMapCapacity, | 189 local_scope_(ZoneHashMap::kDefaultHashMapCapacity, |
| 190 ZoneAllocationPolicy(zone)), | 190 ZoneAllocationPolicy(zone)), |
| 191 stack_limit_(isolate->stack_guard()->real_climit()), | 191 stack_limit_(isolate->stack_guard()->real_climit()), |
| 192 module_node_types_(zone_), | |
| 193 function_node_types_(zone_), | |
| 194 fround_type_(AsmType::FroundType(zone_)), | 192 fround_type_(AsmType::FroundType(zone_)), |
| 195 ffi_type_(AsmType::FFIType(zone_)), | 193 ffi_type_(AsmType::FFIType(zone_)), |
| 196 function_pointer_tables_(zone_) { | 194 function_pointer_tables_(zone_) { |
| 197 InitializeStdlib(); | 195 InitializeStdlib(); |
| 198 } | 196 } |
| 199 | 197 |
| 200 namespace { | 198 namespace { |
| 201 bool ValidAsmIdentifier(Handle<String> name) { | 199 bool ValidAsmIdentifier(Handle<String> name) { |
| 202 static const char* kInvalidAsmNames[] = {"eval", "arguments"}; | 200 static const char* kInvalidAsmNames[] = {"eval", "arguments"}; |
| 203 | 201 |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 | 390 |
| 393 if (entry == nullptr && !module_name_.is_null() && | 391 if (entry == nullptr && !module_name_.is_null() && |
| 394 module_name_->Equals(*variable->name())) { | 392 module_name_->Equals(*variable->name())) { |
| 395 return module_info_; | 393 return module_info_; |
| 396 } | 394 } |
| 397 | 395 |
| 398 return entry ? reinterpret_cast<VariableInfo*>(entry->value) : nullptr; | 396 return entry ? reinterpret_cast<VariableInfo*>(entry->value) : nullptr; |
| 399 } | 397 } |
| 400 | 398 |
| 401 void AsmTyper::AddForwardReference(VariableProxy* proxy, VariableInfo* info) { | 399 void AsmTyper::AddForwardReference(VariableProxy* proxy, VariableInfo* info) { |
| 402 info->SetFirstForwardUse(proxy->position() == kNoSourcePosition | 400 info->SetFirstForwardUse(proxy->position()); |
| 403 ? -1 | |
| 404 : script_->GetLineNumber(proxy->position())); | |
| 405 forward_definitions_.push_back(info); | 401 forward_definitions_.push_back(info); |
| 406 } | 402 } |
| 407 | 403 |
| 408 bool AsmTyper::AddGlobal(Variable* variable, VariableInfo* info) { | 404 bool AsmTyper::AddGlobal(Variable* variable, VariableInfo* info) { |
| 409 // We can't DCHECK(!in_function_) because function may actually install global | 405 // We can't DCHECK(!in_function_) because function may actually install global |
| 410 // names (forward defined functions and function tables.) | 406 // names (forward defined functions and function tables.) |
| 411 DCHECK(info->mutability() != VariableInfo::kInvalidMutability); | 407 DCHECK(info->mutability() != VariableInfo::kInvalidMutability); |
| 412 DCHECK(info->IsGlobal()); | 408 DCHECK(info->IsGlobal()); |
| 413 DCHECK(ValidAsmIdentifier(variable->name())); | 409 DCHECK(ValidAsmIdentifier(variable->name())); |
| 414 | 410 |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 } | 698 } |
| 703 } | 699 } |
| 704 | 700 |
| 705 // 6.2 ValidateExport | 701 // 6.2 ValidateExport |
| 706 if (module_return_ == nullptr) { | 702 if (module_return_ == nullptr) { |
| 707 FAIL(fun, "Missing asm.js module export."); | 703 FAIL(fun, "Missing asm.js module export."); |
| 708 } | 704 } |
| 709 | 705 |
| 710 for (auto* forward_def : forward_definitions_) { | 706 for (auto* forward_def : forward_definitions_) { |
| 711 if (forward_def->missing_definition()) { | 707 if (forward_def->missing_definition()) { |
| 712 FAIL_LINE(forward_def->source_location(), | 708 int position = forward_def->source_location(); |
| 713 "Missing definition for forward declared identifier."); | 709 int line = |
| 710 position == kNoSourcePosition ? -1 : script_->GetLineNumber(position); |
| 711 |
| 712 FAIL_LINE(line, "Missing definition for forward declared identifier."); |
| 714 } | 713 } |
| 715 } | 714 } |
| 716 | 715 |
| 717 RECURSE(ValidateExport(module_return_)); | 716 RECURSE(ValidateExport(module_return_)); |
| 718 | 717 |
| 719 if (!source_layout_.IsValid()) { | 718 if (!source_layout_.IsValid()) { |
| 720 FAIL(fun, "Invalid asm.js source code layout."); | 719 FAIL(fun, "Invalid asm.js source code layout."); |
| 721 } | 720 } |
| 722 | 721 |
| 723 return AsmType::Int(); // Any type that is not AsmType::None(); | 722 return AsmType::Int(); // Any type that is not AsmType::None(); |
| (...skipping 2154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2878 return true; | 2877 return true; |
| 2879 } | 2878 } |
| 2880 | 2879 |
| 2881 *error_message = typer.error_message(); | 2880 *error_message = typer.error_message(); |
| 2882 return false; | 2881 return false; |
| 2883 } | 2882 } |
| 2884 | 2883 |
| 2885 } // namespace wasm | 2884 } // namespace wasm |
| 2886 } // namespace internal | 2885 } // namespace internal |
| 2887 } // namespace v8 | 2886 } // namespace v8 |
| OLD | NEW |