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

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

Issue 2555243002: [wasm] Fix location for error in asm.js ToNumber conversion (Closed)
Patch Set: Fix gc error by storing callee_pc_address 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
2454 *effect_ = result; 2456 *effect_ = result;
2455 2457
2456 return result; 2458 return result;
2457 } 2459 }
2458 2460
2459 bool CanCover(Node* value, IrOpcode::Value opcode) { 2461 bool CanCover(Node* value, IrOpcode::Value opcode) {
2460 if (value->opcode() != opcode) return false; 2462 if (value->opcode() != opcode) return false;
2461 bool first = true; 2463 bool first = true;
2462 for (Edge const edge : value->use_edges()) { 2464 for (Edge const edge : value->use_edges()) {
2463 if (NodeProperties::IsControlEdge(edge)) continue; 2465 if (NodeProperties::IsControlEdge(edge)) continue;
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
2843 // the target is a native function, or if the target is a callable JSObject, 2845 // the target is a native function, or if the target is a callable JSObject,
2844 // which can only be constructed by the runtime. 2846 // which can only be constructed by the runtime.
2845 args[pos++] = HeapConstant(isolate->native_context()); 2847 args[pos++] = HeapConstant(isolate->native_context());
2846 args[pos++] = *effect_; 2848 args[pos++] = *effect_;
2847 args[pos++] = *control_; 2849 args[pos++] = *control_;
2848 2850
2849 call = graph()->NewNode(jsgraph()->common()->Call(desc), pos, args); 2851 call = graph()->NewNode(jsgraph()->common()->Call(desc), pos, args);
2850 } 2852 }
2851 2853
2852 *effect_ = call; 2854 *effect_ = call;
2855 SetSourcePosition(call, 0);
2853 2856
2854 // Convert the return value back. 2857 // Convert the return value back.
2855 Node* i32_zero = jsgraph()->Int32Constant(0); 2858 Node* i32_zero = jsgraph()->Int32Constant(0);
2856 Node* val = sig->return_count() == 0 2859 Node* val = sig->return_count() == 0
2857 ? i32_zero 2860 ? i32_zero
2858 : FromJS(call, HeapConstant(isolate->native_context()), 2861 : FromJS(call, HeapConstant(isolate->native_context()),
2859 sig->GetReturn()); 2862 sig->GetReturn());
2860 Node* ret = graph()->NewNode(jsgraph()->common()->Return(), i32_zero, val, 2863 Node* ret = graph()->NewNode(jsgraph()->common()->Return(), i32_zero, val,
2861 *effect_, start); 2864 *effect_, start);
2862 2865
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
3317 RecordFunctionCompilation(CodeEventListener::FUNCTION_TAG, isolate, code, 3320 RecordFunctionCompilation(CodeEventListener::FUNCTION_TAG, isolate, code,
3318 "js-to-wasm", index, wasm::WasmName("export"), 3321 "js-to-wasm", index, wasm::WasmName("export"),
3319 CStrVector(func_name)); 3322 CStrVector(func_name));
3320 } 3323 }
3321 return code; 3324 return code;
3322 } 3325 }
3323 3326
3324 Handle<Code> CompileWasmToJSWrapper(Isolate* isolate, Handle<JSReceiver> target, 3327 Handle<Code> CompileWasmToJSWrapper(Isolate* isolate, Handle<JSReceiver> target,
3325 wasm::FunctionSig* sig, uint32_t index, 3328 wasm::FunctionSig* sig, uint32_t index,
3326 Handle<String> module_name, 3329 Handle<String> module_name,
3327 MaybeHandle<String> import_name) { 3330 MaybeHandle<String> import_name,
3331 wasm::ModuleOrigin origin) {
3328 //---------------------------------------------------------------------------- 3332 //----------------------------------------------------------------------------
3329 // Create the Graph 3333 // Create the Graph
3330 //---------------------------------------------------------------------------- 3334 //----------------------------------------------------------------------------
3331 Zone zone(isolate->allocator(), ZONE_NAME); 3335 Zone zone(isolate->allocator(), ZONE_NAME);
3332 Graph graph(&zone); 3336 Graph graph(&zone);
3333 CommonOperatorBuilder common(&zone); 3337 CommonOperatorBuilder common(&zone);
3334 MachineOperatorBuilder machine(&zone); 3338 MachineOperatorBuilder machine(&zone);
3335 JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, &machine); 3339 JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, &machine);
3336 3340
3337 Node* control = nullptr; 3341 Node* control = nullptr;
3338 Node* effect = nullptr; 3342 Node* effect = nullptr;
3339 3343
3340 WasmGraphBuilder builder(&zone, &jsgraph, sig); 3344 SourcePositionTable* source_position_table =
3345 origin == wasm::kAsmJsOrigin ? new (&zone) SourcePositionTable(&graph)
3346 : nullptr;
3347
3348 WasmGraphBuilder builder(&zone, &jsgraph, sig, source_position_table);
3341 builder.set_control_ptr(&control); 3349 builder.set_control_ptr(&control);
3342 builder.set_effect_ptr(&effect); 3350 builder.set_effect_ptr(&effect);
3343 builder.BuildWasmToJSWrapper(target, sig); 3351 builder.BuildWasmToJSWrapper(target, sig);
3344 3352
3345 Handle<Code> code = Handle<Code>::null(); 3353 Handle<Code> code = Handle<Code>::null();
3346 { 3354 {
3347 if (FLAG_trace_turbo_graph) { // Simple textual RPO. 3355 if (FLAG_trace_turbo_graph) { // Simple textual RPO.
3348 OFStream os(stdout); 3356 OFStream os(stdout);
3349 os << "-- Graph after change lowering -- " << std::endl; 3357 os << "-- Graph after change lowering -- " << std::endl;
3350 os << AsRPO(graph); 3358 os << AsRPO(graph);
(...skipping 15 matching lines...) Expand all
3366 Vector<const char> func_name = ArrayVector("wasm-to-js"); 3374 Vector<const char> func_name = ArrayVector("wasm-to-js");
3367 static unsigned id = 0; 3375 static unsigned id = 0;
3368 Vector<char> buffer; 3376 Vector<char> buffer;
3369 if (debugging) { 3377 if (debugging) {
3370 buffer = Vector<char>::New(128); 3378 buffer = Vector<char>::New(128);
3371 int chars = SNPrintF(buffer, "wasm-to-js#%d", id); 3379 int chars = SNPrintF(buffer, "wasm-to-js#%d", id);
3372 func_name = Vector<const char>::cast(buffer.SubVector(0, chars)); 3380 func_name = Vector<const char>::cast(buffer.SubVector(0, chars));
3373 } 3381 }
3374 3382
3375 CompilationInfo info(func_name, isolate, &zone, flags); 3383 CompilationInfo info(func_name, isolate, &zone, flags);
3376 code = Pipeline::GenerateCodeForTesting(&info, incoming, &graph, nullptr); 3384 code = Pipeline::GenerateCodeForTesting(&info, incoming, &graph, nullptr,
3385 source_position_table);
3377 #ifdef ENABLE_DISASSEMBLER 3386 #ifdef ENABLE_DISASSEMBLER
3378 if (FLAG_print_opt_code && !code.is_null()) { 3387 if (FLAG_print_opt_code && !code.is_null()) {
3379 OFStream os(stdout); 3388 OFStream os(stdout);
3380 code->Disassemble(buffer.start(), os); 3389 code->Disassemble(buffer.start(), os);
3381 } 3390 }
3382 #endif 3391 #endif
3383 if (debugging) { 3392 if (debugging) {
3384 buffer.Dispose(); 3393 buffer.Dispose();
3385 } 3394 }
3386 } 3395 }
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
3600 Smi::FromInt(instruction.instr_offset)); 3609 Smi::FromInt(instruction.instr_offset));
3601 fn_protected->set(Code::kTrapDataSize * i + Code::kTrapLandingOffset, 3610 fn_protected->set(Code::kTrapDataSize * i + Code::kTrapLandingOffset,
3602 Smi::FromInt(instruction.landing_offset)); 3611 Smi::FromInt(instruction.landing_offset));
3603 } 3612 }
3604 return fn_protected; 3613 return fn_protected;
3605 } 3614 }
3606 3615
3607 } // namespace compiler 3616 } // namespace compiler
3608 } // namespace internal 3617 } // namespace internal
3609 } // namespace v8 3618 } // 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