| 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 // 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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 TypeOf(stmt->expression()) == kAstStmt ? ARITY_0 : ARITY_1; | 262 TypeOf(stmt->expression()) == kAstStmt ? ARITY_0 : ARITY_1; |
| 263 current_function_builder_->EmitWithU8(kExprReturn, arity); | 263 current_function_builder_->EmitWithU8(kExprReturn, arity); |
| 264 } else { | 264 } else { |
| 265 UNREACHABLE(); | 265 UNREACHABLE(); |
| 266 } | 266 } |
| 267 } | 267 } |
| 268 | 268 |
| 269 void VisitWithStatement(WithStatement* stmt) { UNREACHABLE(); } | 269 void VisitWithStatement(WithStatement* stmt) { UNREACHABLE(); } |
| 270 | 270 |
| 271 void HandleCase(CaseNode* node, | 271 void HandleCase(CaseNode* node, |
| 272 const ZoneMap<int, unsigned int>& case_to_block, | 272 ZoneMap<int, unsigned int>& case_to_block, |
| 273 VariableProxy* tag, int default_block, int if_depth) { | 273 VariableProxy* tag, int default_block, int if_depth) { |
| 274 int prev_if_depth = if_depth; | 274 int prev_if_depth = if_depth; |
| 275 if (node->left != nullptr) { | 275 if (node->left != nullptr) { |
| 276 VisitVariableProxy(tag); | 276 VisitVariableProxy(tag); |
| 277 current_function_builder_->EmitI32Const(node->begin); | 277 current_function_builder_->EmitI32Const(node->begin); |
| 278 current_function_builder_->Emit(kExprI32LtS); | 278 current_function_builder_->Emit(kExprI32LtS); |
| 279 current_function_builder_->Emit(kExprIf); | 279 current_function_builder_->Emit(kExprIf); |
| 280 if_depth++; | 280 if_depth++; |
| 281 breakable_blocks_.push_back(std::make_pair(nullptr, false)); | 281 breakable_blocks_.push_back(std::make_pair(nullptr, false)); |
| 282 HandleCase(node->left, case_to_block, tag, default_block, if_depth); | 282 HandleCase(node->left, case_to_block, tag, default_block, if_depth); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 293 current_function_builder_->Emit(kExprElse); | 293 current_function_builder_->Emit(kExprElse); |
| 294 } | 294 } |
| 295 if (node->begin == node->end) { | 295 if (node->begin == node->end) { |
| 296 VisitVariableProxy(tag); | 296 VisitVariableProxy(tag); |
| 297 current_function_builder_->EmitI32Const(node->begin); | 297 current_function_builder_->EmitI32Const(node->begin); |
| 298 current_function_builder_->Emit(kExprI32Eq); | 298 current_function_builder_->Emit(kExprI32Eq); |
| 299 current_function_builder_->Emit(kExprIf); | 299 current_function_builder_->Emit(kExprIf); |
| 300 DCHECK(case_to_block.find(node->begin) != case_to_block.end()); | 300 DCHECK(case_to_block.find(node->begin) != case_to_block.end()); |
| 301 current_function_builder_->EmitWithU8(kExprBr, ARITY_0); | 301 current_function_builder_->EmitWithU8(kExprBr, ARITY_0); |
| 302 current_function_builder_->EmitVarInt(1 + if_depth + | 302 current_function_builder_->EmitVarInt(1 + if_depth + |
| 303 case_to_block.at(node->begin)); | 303 case_to_block[node->begin]); |
| 304 current_function_builder_->Emit(kExprEnd); | 304 current_function_builder_->Emit(kExprEnd); |
| 305 } else { | 305 } else { |
| 306 if (node->begin != 0) { | 306 if (node->begin != 0) { |
| 307 VisitVariableProxy(tag); | 307 VisitVariableProxy(tag); |
| 308 current_function_builder_->EmitI32Const(node->begin); | 308 current_function_builder_->EmitI32Const(node->begin); |
| 309 current_function_builder_->Emit(kExprI32Sub); | 309 current_function_builder_->Emit(kExprI32Sub); |
| 310 } else { | 310 } else { |
| 311 VisitVariableProxy(tag); | 311 VisitVariableProxy(tag); |
| 312 } | 312 } |
| 313 current_function_builder_->EmitWithU8(kExprBrTable, ARITY_0); | 313 current_function_builder_->EmitWithU8(kExprBrTable, ARITY_0); |
| 314 current_function_builder_->EmitVarInt(node->end - node->begin + 1); | 314 current_function_builder_->EmitVarInt(node->end - node->begin + 1); |
| 315 for (int v = node->begin; v <= node->end; v++) { | 315 for (int v = node->begin; v <= node->end; v++) { |
| 316 if (case_to_block.find(v) != case_to_block.end()) { | 316 if (case_to_block.find(v) != case_to_block.end()) { |
| 317 byte break_code[] = {BR_TARGET(if_depth + case_to_block.at(v))}; | 317 byte break_code[] = {BR_TARGET(if_depth + case_to_block[v])}; |
| 318 current_function_builder_->EmitCode(break_code, sizeof(break_code)); | 318 current_function_builder_->EmitCode(break_code, sizeof(break_code)); |
| 319 } else { | 319 } else { |
| 320 byte break_code[] = {BR_TARGET(if_depth + default_block)}; | 320 byte break_code[] = {BR_TARGET(if_depth + default_block)}; |
| 321 current_function_builder_->EmitCode(break_code, sizeof(break_code)); | 321 current_function_builder_->EmitCode(break_code, sizeof(break_code)); |
| 322 } | 322 } |
| 323 if (v == kMaxInt) { | 323 if (v == kMaxInt) { |
| 324 break; | 324 break; |
| 325 } | 325 } |
| 326 } | 326 } |
| 327 byte break_code[] = {BR_TARGET(if_depth + default_block)}; | 327 byte break_code[] = {BR_TARGET(if_depth + default_block)}; |
| (...skipping 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1782 AsmWasmBuilderImpl impl(isolate_, zone_, literal_, typer_); | 1782 AsmWasmBuilderImpl impl(isolate_, zone_, literal_, typer_); |
| 1783 impl.Build(); | 1783 impl.Build(); |
| 1784 *foreign_args = impl.GetForeignArgs(); | 1784 *foreign_args = impl.GetForeignArgs(); |
| 1785 ZoneBuffer* buffer = new (zone_) ZoneBuffer(zone_); | 1785 ZoneBuffer* buffer = new (zone_) ZoneBuffer(zone_); |
| 1786 impl.builder_->WriteTo(*buffer); | 1786 impl.builder_->WriteTo(*buffer); |
| 1787 return buffer; | 1787 return buffer; |
| 1788 } | 1788 } |
| 1789 } // namespace wasm | 1789 } // namespace wasm |
| 1790 } // namespace internal | 1790 } // namespace internal |
| 1791 } // namespace v8 | 1791 } // namespace v8 |
| OLD | NEW |