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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/wasm/asm-wasm-builder.h" | 7 #include "src/wasm/asm-wasm-builder.h" |
8 #include "src/wasm/wasm-macro-gen.h" | 8 #include "src/wasm/wasm-macro-gen.h" |
9 #include "src/wasm/wasm-opcodes.h" | 9 #include "src/wasm/wasm-opcodes.h" |
10 | 10 |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 void VisitTryCatchStatement(TryCatchStatement* stmt) { UNREACHABLE(); } | 329 void VisitTryCatchStatement(TryCatchStatement* stmt) { UNREACHABLE(); } |
330 | 330 |
331 void VisitTryFinallyStatement(TryFinallyStatement* stmt) { UNREACHABLE(); } | 331 void VisitTryFinallyStatement(TryFinallyStatement* stmt) { UNREACHABLE(); } |
332 | 332 |
333 void VisitDebuggerStatement(DebuggerStatement* stmt) { UNREACHABLE(); } | 333 void VisitDebuggerStatement(DebuggerStatement* stmt) { UNREACHABLE(); } |
334 | 334 |
335 void VisitFunctionLiteral(FunctionLiteral* expr) { | 335 void VisitFunctionLiteral(FunctionLiteral* expr) { |
336 Scope* scope = expr->scope(); | 336 Scope* scope = expr->scope(); |
337 if (in_function_) { | 337 if (in_function_) { |
338 if (expr->bounds().lower->IsFunction()) { | 338 if (expr->bounds().lower->IsFunction()) { |
339 Type::FunctionType* func_type = expr->bounds().lower->AsFunction(); | 339 FunctionType* func_type = expr->bounds().lower->AsFunction(); |
340 LocalType return_type = TypeFrom(func_type->Result()); | 340 LocalType return_type = TypeFrom(func_type->Result()); |
341 current_function_builder_->ReturnType(return_type); | 341 current_function_builder_->ReturnType(return_type); |
342 for (int i = 0; i < expr->parameter_count(); i++) { | 342 for (int i = 0; i < expr->parameter_count(); i++) { |
343 LocalType type = TypeFrom(func_type->Parameter(i)); | 343 LocalType type = TypeFrom(func_type->Parameter(i)); |
344 DCHECK(type != kAstStmt); | 344 DCHECK(type != kAstStmt); |
345 LookupOrInsertLocal(scope->parameter(i), type); | 345 LookupOrInsertLocal(scope->parameter(i), type); |
346 } | 346 } |
347 } else { | 347 } else { |
348 UNREACHABLE(); | 348 UNREACHABLE(); |
349 } | 349 } |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 current_function_builder_ = builder_->FunctionAt(init_function_index_); | 458 current_function_builder_ = builder_->FunctionAt(init_function_index_); |
459 in_function_ = true; | 459 in_function_ = true; |
460 } | 460 } |
461 | 461 |
462 void UnLoadInitFunction() { | 462 void UnLoadInitFunction() { |
463 in_function_ = false; | 463 in_function_ = false; |
464 current_function_builder_ = nullptr; | 464 current_function_builder_ = nullptr; |
465 } | 465 } |
466 | 466 |
467 void AddFunctionTable(VariableProxy* table, ArrayLiteral* funcs) { | 467 void AddFunctionTable(VariableProxy* table, ArrayLiteral* funcs) { |
468 Type::FunctionType* func_type = | 468 FunctionType* func_type = |
469 funcs->bounds().lower->AsArray()->Element()->AsFunction(); | 469 funcs->bounds().lower->AsArray()->Element()->AsFunction(); |
470 LocalType return_type = TypeFrom(func_type->Result()); | 470 LocalType return_type = TypeFrom(func_type->Result()); |
471 FunctionSig::Builder sig(zone(), return_type == kAstStmt ? 0 : 1, | 471 FunctionSig::Builder sig(zone(), return_type == kAstStmt ? 0 : 1, |
472 func_type->Arity()); | 472 func_type->Arity()); |
473 if (return_type != kAstStmt) { | 473 if (return_type != kAstStmt) { |
474 sig.AddReturn(static_cast<LocalType>(return_type)); | 474 sig.AddReturn(static_cast<LocalType>(return_type)); |
475 } | 475 } |
476 for (int i = 0; i < func_type->Arity(); i++) { | 476 for (int i = 0; i < func_type->Arity(); i++) { |
477 sig.AddParam(TypeFrom(func_type->Parameter(i))); | 477 sig.AddParam(TypeFrom(func_type->Parameter(i))); |
478 } | 478 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 } | 544 } |
545 } | 545 } |
546 | 546 |
547 void VisitYield(Yield* expr) { UNREACHABLE(); } | 547 void VisitYield(Yield* expr) { UNREACHABLE(); } |
548 | 548 |
549 void VisitThrow(Throw* expr) { UNREACHABLE(); } | 549 void VisitThrow(Throw* expr) { UNREACHABLE(); } |
550 | 550 |
551 void VisitProperty(Property* expr) { | 551 void VisitProperty(Property* expr) { |
552 Expression* obj = expr->obj(); | 552 Expression* obj = expr->obj(); |
553 DCHECK(obj->bounds().lower == obj->bounds().upper); | 553 DCHECK(obj->bounds().lower == obj->bounds().upper); |
554 TypeImpl<ZoneTypeConfig>* type = obj->bounds().lower; | 554 Type* type = obj->bounds().lower; |
555 MachineType mtype; | 555 MachineType mtype; |
556 int size; | 556 int size; |
557 if (type->Is(cache_.kUint8Array)) { | 557 if (type->Is(cache_.kUint8Array)) { |
558 mtype = MachineType::Uint8(); | 558 mtype = MachineType::Uint8(); |
559 size = 1; | 559 size = 1; |
560 } else if (type->Is(cache_.kInt8Array)) { | 560 } else if (type->Is(cache_.kInt8Array)) { |
561 mtype = MachineType::Int8(); | 561 mtype = MachineType::Int8(); |
562 size = 1; | 562 size = 1; |
563 } else if (type->Is(cache_.kUint16Array)) { | 563 } else if (type->Is(cache_.kUint16Array)) { |
564 mtype = MachineType::Uint16(); | 564 mtype = MachineType::Uint16(); |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 left_index = kInt32; | 944 left_index = kInt32; |
945 right_index = kInt32; | 945 right_index = kInt32; |
946 } | 946 } |
947 DCHECK((left_index == right_index) || | 947 DCHECK((left_index == right_index) || |
948 (ignore_sign && (left_index <= 1) && (right_index <= 1))); | 948 (ignore_sign && (left_index <= 1) && (right_index <= 1))); |
949 return left_index; | 949 return left_index; |
950 } | 950 } |
951 | 951 |
952 TypeIndex TypeIndexOf(Expression* expr) { | 952 TypeIndex TypeIndexOf(Expression* expr) { |
953 DCHECK(expr->bounds().lower == expr->bounds().upper); | 953 DCHECK(expr->bounds().lower == expr->bounds().upper); |
954 TypeImpl<ZoneTypeConfig>* type = expr->bounds().lower; | 954 Type* type = expr->bounds().lower; |
955 if (type->Is(cache_.kAsmFixnum)) { | 955 if (type->Is(cache_.kAsmFixnum)) { |
956 return kFixnum; | 956 return kFixnum; |
957 } else if (type->Is(cache_.kAsmSigned)) { | 957 } else if (type->Is(cache_.kAsmSigned)) { |
958 return kInt32; | 958 return kInt32; |
959 } else if (type->Is(cache_.kAsmUnsigned)) { | 959 } else if (type->Is(cache_.kAsmUnsigned)) { |
960 return kUint32; | 960 return kUint32; |
961 } else if (type->Is(cache_.kAsmInt)) { | 961 } else if (type->Is(cache_.kAsmInt)) { |
962 return kInt32; | 962 return kInt32; |
963 } else if (type->Is(cache_.kAsmFloat)) { | 963 } else if (type->Is(cache_.kAsmFloat)) { |
964 return kFloat32; | 964 return kFloat32; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 entry->value = container; | 1056 entry->value = container; |
1057 } | 1057 } |
1058 return (reinterpret_cast<IndexContainer*>(entry->value))->index; | 1058 return (reinterpret_cast<IndexContainer*>(entry->value))->index; |
1059 } | 1059 } |
1060 | 1060 |
1061 LocalType TypeOf(Expression* expr) { | 1061 LocalType TypeOf(Expression* expr) { |
1062 DCHECK(expr->bounds().lower == expr->bounds().upper); | 1062 DCHECK(expr->bounds().lower == expr->bounds().upper); |
1063 return TypeFrom(expr->bounds().lower); | 1063 return TypeFrom(expr->bounds().lower); |
1064 } | 1064 } |
1065 | 1065 |
1066 LocalType TypeFrom(TypeImpl<ZoneTypeConfig>* type) { | 1066 LocalType TypeFrom(Type* type) { |
1067 if (type->Is(cache_.kAsmInt)) { | 1067 if (type->Is(cache_.kAsmInt)) { |
1068 return kAstI32; | 1068 return kAstI32; |
1069 } else if (type->Is(cache_.kAsmFloat)) { | 1069 } else if (type->Is(cache_.kAsmFloat)) { |
1070 return kAstF32; | 1070 return kAstF32; |
1071 } else if (type->Is(cache_.kAsmDouble)) { | 1071 } else if (type->Is(cache_.kAsmDouble)) { |
1072 return kAstF64; | 1072 return kAstF64; |
1073 } else { | 1073 } else { |
1074 return kAstStmt; | 1074 return kAstStmt; |
1075 } | 1075 } |
1076 } | 1076 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1109 // that zone in constructor may be thrown away once wasm module is written. | 1109 // that zone in constructor may be thrown away once wasm module is written. |
1110 WasmModuleIndex* AsmWasmBuilder::Run() { | 1110 WasmModuleIndex* AsmWasmBuilder::Run() { |
1111 AsmWasmBuilderImpl impl(isolate_, zone_, literal_); | 1111 AsmWasmBuilderImpl impl(isolate_, zone_, literal_); |
1112 impl.Compile(); | 1112 impl.Compile(); |
1113 WasmModuleWriter* writer = impl.builder_->Build(zone_); | 1113 WasmModuleWriter* writer = impl.builder_->Build(zone_); |
1114 return writer->WriteTo(zone_); | 1114 return writer->WriteTo(zone_); |
1115 } | 1115 } |
1116 } // namespace wasm | 1116 } // namespace wasm |
1117 } // namespace internal | 1117 } // namespace internal |
1118 } // namespace v8 | 1118 } // namespace v8 |
OLD | NEW |