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

Side by Side Diff: src/objects.cc

Issue 2512833003: [wasm] Translate locations to positions properly (Closed)
Patch Set: Address comment Created 4 years, 1 month 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 | « no previous file | src/runtime/runtime-debug.cc » ('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/objects.h" 5 #include "src/objects.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <iomanip> 8 #include <iomanip>
9 #include <memory> 9 #include <memory>
10 #include <sstream> 10 #include <sstream>
(...skipping 13405 matching lines...) Expand 10 before | Expand all | Expand 10 after
13416 script->set_line_ends(*array); 13416 script->set_line_ends(*array);
13417 } 13417 }
13418 13418
13419 DCHECK(script->line_ends()->IsFixedArray()); 13419 DCHECK(script->line_ends()->IsFixedArray());
13420 } 13420 }
13421 13421
13422 bool Script::GetPositionInfo(Handle<Script> script, int position, 13422 bool Script::GetPositionInfo(Handle<Script> script, int position,
13423 PositionInfo* info, OffsetFlag offset_flag) { 13423 PositionInfo* info, OffsetFlag offset_flag) {
13424 // For wasm, we do not create an artificial line_ends array, but do the 13424 // For wasm, we do not create an artificial line_ends array, but do the
13425 // translation directly. 13425 // translation directly.
13426 if (script->type() == Script::TYPE_WASM) { 13426 if (script->type() != Script::TYPE_WASM) InitLineEnds(script);
13427 Handle<WasmCompiledModule> compiled_module(
13428 WasmCompiledModule::cast(script->wasm_compiled_module()));
13429 DCHECK_LE(0, position);
13430 return wasm::GetPositionInfo(compiled_module,
13431 static_cast<uint32_t>(position), info);
13432 }
13433
13434 InitLineEnds(script);
13435 return script->GetPositionInfo(position, info, offset_flag); 13427 return script->GetPositionInfo(position, info, offset_flag);
13436 } 13428 }
13437 13429
13438 namespace { 13430 namespace {
13439 bool GetPositionInfoSlow(const Script* script, int position, 13431 bool GetPositionInfoSlow(const Script* script, int position,
13440 Script::PositionInfo* info) { 13432 Script::PositionInfo* info) {
13441 if (!script->source()->IsString()) return false; 13433 if (!script->source()->IsString()) return false;
13442 if (position < 0) position = 0; 13434 if (position < 0) position = 0;
13443 13435
13444 String* source_string = String::cast(script->source()); 13436 String* source_string = String::cast(script->source());
(...skipping 15 matching lines...) Expand all
13460 } 13452 }
13461 return false; 13453 return false;
13462 } 13454 }
13463 } // namespace 13455 } // namespace
13464 13456
13465 #define SMI_VALUE(x) (Smi::cast(x)->value()) 13457 #define SMI_VALUE(x) (Smi::cast(x)->value())
13466 bool Script::GetPositionInfo(int position, PositionInfo* info, 13458 bool Script::GetPositionInfo(int position, PositionInfo* info,
13467 OffsetFlag offset_flag) const { 13459 OffsetFlag offset_flag) const {
13468 DisallowHeapAllocation no_allocation; 13460 DisallowHeapAllocation no_allocation;
13469 13461
13462 // For wasm, we do not rely on the line_ends array, but do the translation
13463 // directly.
13464 if (type() == Script::TYPE_WASM) {
13465 Handle<WasmCompiledModule> compiled_module(
13466 WasmCompiledModule::cast(wasm_compiled_module()));
13467 DCHECK_LE(0, position);
13468 return wasm::GetPositionInfo(compiled_module,
13469 static_cast<uint32_t>(position), info);
13470 }
13471
13470 if (line_ends()->IsUndefined(GetIsolate())) { 13472 if (line_ends()->IsUndefined(GetIsolate())) {
13471 // Slow mode: we do not have line_ends. We have to iterate through source. 13473 // Slow mode: we do not have line_ends. We have to iterate through source.
13472 if (!GetPositionInfoSlow(this, position, info)) return false; 13474 if (!GetPositionInfoSlow(this, position, info)) return false;
13473 } else { 13475 } else {
13474 DCHECK(line_ends()->IsFixedArray()); 13476 DCHECK(line_ends()->IsFixedArray());
13475 FixedArray* ends = FixedArray::cast(line_ends()); 13477 FixedArray* ends = FixedArray::cast(line_ends());
13476 13478
13477 const int ends_len = ends->length(); 13479 const int ends_len = ends->length();
13478 if (ends_len == 0) return false; 13480 if (ends_len == 0) return false;
13479 13481
(...skipping 6937 matching lines...) Expand 10 before | Expand all | Expand 10 after
20417 // depend on this. 20419 // depend on this.
20418 return DICTIONARY_ELEMENTS; 20420 return DICTIONARY_ELEMENTS;
20419 } 20421 }
20420 DCHECK_LE(kind, LAST_ELEMENTS_KIND); 20422 DCHECK_LE(kind, LAST_ELEMENTS_KIND);
20421 return kind; 20423 return kind;
20422 } 20424 }
20423 } 20425 }
20424 20426
20425 } // namespace internal 20427 } // namespace internal
20426 } // namespace v8 20428 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/runtime/runtime-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698