| 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> |
| 11 | 11 |
| 12 #include "include/v8.h" | 12 #include "include/v8.h" |
| 13 #include "src/v8.h" | 13 #include "src/v8.h" |
| 14 | 14 |
| 15 #include "src/asmjs/asm-types.h" | 15 #include "src/asmjs/asm-types.h" |
| 16 #include "src/ast/ast.h" | 16 #include "src/ast/ast.h" |
| 17 #include "src/ast/scopes.h" | 17 #include "src/ast/scopes.h" |
| 18 #include "src/base/bits.h" | 18 #include "src/base/bits.h" |
| 19 #include "src/codegen.h" | 19 #include "src/codegen.h" |
| 20 #include "src/globals.h" | 20 #include "src/globals.h" |
| 21 #include "src/messages.h" | 21 #include "src/messages.h" |
| 22 #include "src/utils.h" | 22 #include "src/utils.h" |
| 23 #include "src/vector.h" |
| 23 | 24 |
| 24 #define FAIL_LOCATION(location, msg) \ | 25 #define FAIL_LOCATION_RAW(location, msg) \ |
| 25 do { \ | 26 do { \ |
| 26 Handle<String> message(isolate_->factory()->InternalizeOneByteString( \ | 27 Handle<String> message( \ |
| 27 STATIC_CHAR_VECTOR(msg))); \ | 28 isolate_->factory()->InternalizeOneByteString(msg)); \ |
| 28 error_message_ = MessageHandler::MakeMessageObject( \ | 29 error_message_ = MessageHandler::MakeMessageObject( \ |
| 29 isolate_, MessageTemplate::kAsmJsInvalid, (location), message, \ | 30 isolate_, MessageTemplate::kAsmJsInvalid, (location), message, \ |
| 30 Handle<JSArray>::null()); \ | 31 Handle<JSArray>::null()); \ |
| 31 error_message_->set_error_level(v8::Isolate::kMessageWarning); \ | 32 error_message_->set_error_level(v8::Isolate::kMessageWarning); \ |
| 32 message_location_ = *(location); \ | 33 message_location_ = *(location); \ |
| 33 return AsmType::None(); \ | 34 return AsmType::None(); \ |
| 34 } while (false) | 35 } while (false) |
| 35 | 36 |
| 36 #define FAIL(node, msg) \ | 37 #define FAIL_RAW(node, msg) \ |
| 37 do { \ | 38 do { \ |
| 38 MessageLocation location(script_, node->position(), node->position()); \ | 39 MessageLocation location(script_, node->position(), node->position()); \ |
| 39 FAIL_LOCATION(&location, msg); \ | 40 FAIL_LOCATION_RAW(&location, msg); \ |
| 40 } while (false) | 41 } while (false) |
| 41 | 42 |
| 43 #define FAIL_LOCATION(location, msg) \ |
| 44 FAIL_LOCATION_RAW(location, STATIC_CHAR_VECTOR(msg)) |
| 45 |
| 46 #define FAIL(node, msg) FAIL_RAW(node, STATIC_CHAR_VECTOR(msg)) |
| 47 |
| 42 #define RECURSE(call) \ | 48 #define RECURSE(call) \ |
| 43 do { \ | 49 do { \ |
| 44 if (GetCurrentStackPosition() < stack_limit_) { \ | 50 if (GetCurrentStackPosition() < stack_limit_) { \ |
| 45 stack_overflow_ = true; \ | 51 stack_overflow_ = true; \ |
| 46 FAIL(root_, "Stack overflow while parsing asm.js module."); \ | 52 FAIL(root_, "Stack overflow while parsing asm.js module."); \ |
| 47 } \ | 53 } \ |
| 48 \ | 54 \ |
| 49 AsmType* result = (call); \ | 55 AsmType* result = (call); \ |
| 50 if (stack_overflow_) { \ | 56 if (stack_overflow_) { \ |
| 51 return AsmType::None(); \ | 57 return AsmType::None(); \ |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 | 529 |
| 524 AsmTyper::StandardMember AsmTyper::VariableAsStandardMember(Variable* var) { | 530 AsmTyper::StandardMember AsmTyper::VariableAsStandardMember(Variable* var) { |
| 525 auto* var_info = Lookup(var); | 531 auto* var_info = Lookup(var); |
| 526 if (var_info == nullptr) { | 532 if (var_info == nullptr) { |
| 527 return kNone; | 533 return kNone; |
| 528 } | 534 } |
| 529 StandardMember member = var_info->standard_member(); | 535 StandardMember member = var_info->standard_member(); |
| 530 return member; | 536 return member; |
| 531 } | 537 } |
| 532 | 538 |
| 539 AsmType* AsmTyper::FailWithMessage(const char* text) { |
| 540 FAIL_RAW(root_, OneByteVector(text)); |
| 541 } |
| 542 |
| 533 bool AsmTyper::Validate() { | 543 bool AsmTyper::Validate() { |
| 534 return ValidateBeforeFunctionsPhase() && | 544 return ValidateBeforeFunctionsPhase() && |
| 535 !AsmType::None()->IsExactly(ValidateModuleFunctions(root_)) && | 545 !AsmType::None()->IsExactly(ValidateModuleFunctions(root_)) && |
| 536 ValidateAfterFunctionsPhase(); | 546 ValidateAfterFunctionsPhase(); |
| 537 } | 547 } |
| 538 | 548 |
| 539 bool AsmTyper::ValidateBeforeFunctionsPhase() { | 549 bool AsmTyper::ValidateBeforeFunctionsPhase() { |
| 540 if (!AsmType::None()->IsExactly(ValidateModuleBeforeFunctionsPhase(root_))) { | 550 if (!AsmType::None()->IsExactly(ValidateModuleBeforeFunctionsPhase(root_))) { |
| 541 return true; | 551 return true; |
| 542 } | 552 } |
| (...skipping 2380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2923 "Heap view creation parameter should be the module's heap parameter."); | 2933 "Heap view creation parameter should be the module's heap parameter."); |
| 2924 } | 2934 } |
| 2925 | 2935 |
| 2926 DCHECK(heap_view_info->type()->IsA(AsmType::Heap())); | 2936 DCHECK(heap_view_info->type()->IsA(AsmType::Heap())); |
| 2927 return heap_view_info->type(); | 2937 return heap_view_info->type(); |
| 2928 } | 2938 } |
| 2929 | 2939 |
| 2930 } // namespace wasm | 2940 } // namespace wasm |
| 2931 } // namespace internal | 2941 } // namespace internal |
| 2932 } // namespace v8 | 2942 } // namespace v8 |
| OLD | NEW |