Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Side by Side Diff: src/compiler/wasm-compiler.cc

Issue 2563613003: Revert of [wasm] Fix location for error in asm.js ToNumber conversion (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/wasm-compiler.h ('k') | src/frames.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/compiler/wasm-compiler.h" 5 #include "src/compiler/wasm-compiler.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/isolate-inl.h" 9 #include "src/isolate-inl.h"
10 10
(...skipping 2433 matching lines...) Expand 10 before | Expand all | Expand 10 after
2444 Node* WasmGraphBuilder::BuildJavaScriptToNumber(Node* node, Node* context) { 2444 Node* WasmGraphBuilder::BuildJavaScriptToNumber(Node* node, Node* context) {
2445 Callable callable = CodeFactory::ToNumber(jsgraph()->isolate()); 2445 Callable callable = CodeFactory::ToNumber(jsgraph()->isolate());
2446 CallDescriptor* desc = Linkage::GetStubCallDescriptor( 2446 CallDescriptor* desc = Linkage::GetStubCallDescriptor(
2447 jsgraph()->isolate(), jsgraph()->zone(), callable.descriptor(), 0, 2447 jsgraph()->isolate(), jsgraph()->zone(), callable.descriptor(), 0,
2448 CallDescriptor::kNoFlags, Operator::kNoProperties); 2448 CallDescriptor::kNoFlags, Operator::kNoProperties);
2449 Node* stub_code = jsgraph()->HeapConstant(callable.code()); 2449 Node* stub_code = jsgraph()->HeapConstant(callable.code());
2450 2450
2451 Node* result = graph()->NewNode(jsgraph()->common()->Call(desc), stub_code, 2451 Node* result = graph()->NewNode(jsgraph()->common()->Call(desc), stub_code,
2452 node, context, *effect_, *control_); 2452 node, context, *effect_, *control_);
2453 2453
2454 SetSourcePosition(result, 1);
2455
2456 *effect_ = result; 2454 *effect_ = result;
2457 2455
2458 return result; 2456 return result;
2459 } 2457 }
2460 2458
2461 bool CanCover(Node* value, IrOpcode::Value opcode) { 2459 bool CanCover(Node* value, IrOpcode::Value opcode) {
2462 if (value->opcode() != opcode) return false; 2460 if (value->opcode() != opcode) return false;
2463 bool first = true; 2461 bool first = true;
2464 for (Edge const edge : value->use_edges()) { 2462 for (Edge const edge : value->use_edges()) {
2465 if (NodeProperties::IsControlEdge(edge)) continue; 2463 if (NodeProperties::IsControlEdge(edge)) continue;
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
2845 // the target is a native function, or if the target is a callable JSObject, 2843 // the target is a native function, or if the target is a callable JSObject,
2846 // which can only be constructed by the runtime. 2844 // which can only be constructed by the runtime.
2847 args[pos++] = HeapConstant(isolate->native_context()); 2845 args[pos++] = HeapConstant(isolate->native_context());
2848 args[pos++] = *effect_; 2846 args[pos++] = *effect_;
2849 args[pos++] = *control_; 2847 args[pos++] = *control_;
2850 2848
2851 call = graph()->NewNode(jsgraph()->common()->Call(desc), pos, args); 2849 call = graph()->NewNode(jsgraph()->common()->Call(desc), pos, args);
2852 } 2850 }
2853 2851
2854 *effect_ = call; 2852 *effect_ = call;
2855 SetSourcePosition(call, 0);
2856 2853
2857 // Convert the return value back. 2854 // Convert the return value back.
2858 Node* i32_zero = jsgraph()->Int32Constant(0); 2855 Node* i32_zero = jsgraph()->Int32Constant(0);
2859 Node* val = sig->return_count() == 0 2856 Node* val = sig->return_count() == 0
2860 ? i32_zero 2857 ? i32_zero
2861 : FromJS(call, HeapConstant(isolate->native_context()), 2858 : FromJS(call, HeapConstant(isolate->native_context()),
2862 sig->GetReturn()); 2859 sig->GetReturn());
2863 Node* ret = graph()->NewNode(jsgraph()->common()->Return(), i32_zero, val, 2860 Node* ret = graph()->NewNode(jsgraph()->common()->Return(), i32_zero, val,
2864 *effect_, start); 2861 *effect_, start);
2865 2862
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
3320 RecordFunctionCompilation(CodeEventListener::FUNCTION_TAG, isolate, code, 3317 RecordFunctionCompilation(CodeEventListener::FUNCTION_TAG, isolate, code,
3321 "js-to-wasm", index, wasm::WasmName("export"), 3318 "js-to-wasm", index, wasm::WasmName("export"),
3322 CStrVector(func_name)); 3319 CStrVector(func_name));
3323 } 3320 }
3324 return code; 3321 return code;
3325 } 3322 }
3326 3323
3327 Handle<Code> CompileWasmToJSWrapper(Isolate* isolate, Handle<JSReceiver> target, 3324 Handle<Code> CompileWasmToJSWrapper(Isolate* isolate, Handle<JSReceiver> target,
3328 wasm::FunctionSig* sig, uint32_t index, 3325 wasm::FunctionSig* sig, uint32_t index,
3329 Handle<String> module_name, 3326 Handle<String> module_name,
3330 MaybeHandle<String> import_name, 3327 MaybeHandle<String> import_name) {
3331 wasm::ModuleOrigin origin) {
3332 //---------------------------------------------------------------------------- 3328 //----------------------------------------------------------------------------
3333 // Create the Graph 3329 // Create the Graph
3334 //---------------------------------------------------------------------------- 3330 //----------------------------------------------------------------------------
3335 Zone zone(isolate->allocator(), ZONE_NAME); 3331 Zone zone(isolate->allocator(), ZONE_NAME);
3336 Graph graph(&zone); 3332 Graph graph(&zone);
3337 CommonOperatorBuilder common(&zone); 3333 CommonOperatorBuilder common(&zone);
3338 MachineOperatorBuilder machine(&zone); 3334 MachineOperatorBuilder machine(&zone);
3339 JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, &machine); 3335 JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, &machine);
3340 3336
3341 Node* control = nullptr; 3337 Node* control = nullptr;
3342 Node* effect = nullptr; 3338 Node* effect = nullptr;
3343 3339
3344 SourcePositionTable* source_position_table = 3340 WasmGraphBuilder builder(&zone, &jsgraph, sig);
3345 origin == wasm::kAsmJsOrigin ? new (&zone) SourcePositionTable(&graph)
3346 : nullptr;
3347
3348 WasmGraphBuilder builder(&zone, &jsgraph, sig, source_position_table);
3349 builder.set_control_ptr(&control); 3341 builder.set_control_ptr(&control);
3350 builder.set_effect_ptr(&effect); 3342 builder.set_effect_ptr(&effect);
3351 builder.BuildWasmToJSWrapper(target, sig); 3343 builder.BuildWasmToJSWrapper(target, sig);
3352 3344
3353 Handle<Code> code = Handle<Code>::null(); 3345 Handle<Code> code = Handle<Code>::null();
3354 { 3346 {
3355 if (FLAG_trace_turbo_graph) { // Simple textual RPO. 3347 if (FLAG_trace_turbo_graph) { // Simple textual RPO.
3356 OFStream os(stdout); 3348 OFStream os(stdout);
3357 os << "-- Graph after change lowering -- " << std::endl; 3349 os << "-- Graph after change lowering -- " << std::endl;
3358 os << AsRPO(graph); 3350 os << AsRPO(graph);
(...skipping 15 matching lines...) Expand all
3374 Vector<const char> func_name = ArrayVector("wasm-to-js"); 3366 Vector<const char> func_name = ArrayVector("wasm-to-js");
3375 static unsigned id = 0; 3367 static unsigned id = 0;
3376 Vector<char> buffer; 3368 Vector<char> buffer;
3377 if (debugging) { 3369 if (debugging) {
3378 buffer = Vector<char>::New(128); 3370 buffer = Vector<char>::New(128);
3379 int chars = SNPrintF(buffer, "wasm-to-js#%d", id); 3371 int chars = SNPrintF(buffer, "wasm-to-js#%d", id);
3380 func_name = Vector<const char>::cast(buffer.SubVector(0, chars)); 3372 func_name = Vector<const char>::cast(buffer.SubVector(0, chars));
3381 } 3373 }
3382 3374
3383 CompilationInfo info(func_name, isolate, &zone, flags); 3375 CompilationInfo info(func_name, isolate, &zone, flags);
3384 code = Pipeline::GenerateCodeForTesting(&info, incoming, &graph, nullptr, 3376 code = Pipeline::GenerateCodeForTesting(&info, incoming, &graph, nullptr);
3385 source_position_table);
3386 #ifdef ENABLE_DISASSEMBLER 3377 #ifdef ENABLE_DISASSEMBLER
3387 if (FLAG_print_opt_code && !code.is_null()) { 3378 if (FLAG_print_opt_code && !code.is_null()) {
3388 OFStream os(stdout); 3379 OFStream os(stdout);
3389 code->Disassemble(buffer.start(), os); 3380 code->Disassemble(buffer.start(), os);
3390 } 3381 }
3391 #endif 3382 #endif
3392 if (debugging) { 3383 if (debugging) {
3393 buffer.Dispose(); 3384 buffer.Dispose();
3394 } 3385 }
3395 } 3386 }
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
3609 Smi::FromInt(instruction.instr_offset)); 3600 Smi::FromInt(instruction.instr_offset));
3610 fn_protected->set(Code::kTrapDataSize * i + Code::kTrapLandingOffset, 3601 fn_protected->set(Code::kTrapDataSize * i + Code::kTrapLandingOffset,
3611 Smi::FromInt(instruction.landing_offset)); 3602 Smi::FromInt(instruction.landing_offset));
3612 } 3603 }
3613 return fn_protected; 3604 return fn_protected;
3614 } 3605 }
3615 3606
3616 } // namespace compiler 3607 } // namespace compiler
3617 } // namespace internal 3608 } // namespace internal
3618 } // namespace v8 3609 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/wasm-compiler.h ('k') | src/frames.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698