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/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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 #include "src/prototype.h" | 55 #include "src/prototype.h" |
56 #include "src/regexp/jsregexp.h" | 56 #include "src/regexp/jsregexp.h" |
57 #include "src/safepoint-table.h" | 57 #include "src/safepoint-table.h" |
58 #include "src/snapshot/code-serializer.h" | 58 #include "src/snapshot/code-serializer.h" |
59 #include "src/source-position-table.h" | 59 #include "src/source-position-table.h" |
60 #include "src/string-builder.h" | 60 #include "src/string-builder.h" |
61 #include "src/string-search.h" | 61 #include "src/string-search.h" |
62 #include "src/string-stream.h" | 62 #include "src/string-stream.h" |
63 #include "src/utils.h" | 63 #include "src/utils.h" |
64 #include "src/wasm/wasm-module.h" | 64 #include "src/wasm/wasm-module.h" |
| 65 #include "src/wasm/wasm-objects.h" |
65 #include "src/zone/zone.h" | 66 #include "src/zone/zone.h" |
66 | 67 |
67 #ifdef ENABLE_DISASSEMBLER | 68 #ifdef ENABLE_DISASSEMBLER |
68 #include "src/disasm.h" | 69 #include "src/disasm.h" |
69 #include "src/disassembler.h" | 70 #include "src/disassembler.h" |
70 #include "src/eh-frame.h" | 71 #include "src/eh-frame.h" |
71 #endif | 72 #endif |
72 | 73 |
73 namespace v8 { | 74 namespace v8 { |
74 namespace internal { | 75 namespace internal { |
(...skipping 13321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13396 } | 13397 } |
13397 DCHECK(position >= 0); | 13398 DCHECK(position >= 0); |
13398 set_eval_from_position(position); | 13399 set_eval_from_position(position); |
13399 } | 13400 } |
13400 return position; | 13401 return position; |
13401 } | 13402 } |
13402 | 13403 |
13403 void Script::InitLineEnds(Handle<Script> script) { | 13404 void Script::InitLineEnds(Handle<Script> script) { |
13404 Isolate* isolate = script->GetIsolate(); | 13405 Isolate* isolate = script->GetIsolate(); |
13405 if (!script->line_ends()->IsUndefined(isolate)) return; | 13406 if (!script->line_ends()->IsUndefined(isolate)) return; |
| 13407 DCHECK_NE(Script::TYPE_WASM, script->type()); |
13406 | 13408 |
13407 Object* src_obj = script->source(); | 13409 Object* src_obj = script->source(); |
13408 if (!src_obj->IsString()) { | 13410 if (!src_obj->IsString()) { |
13409 DCHECK(src_obj->IsUndefined(isolate)); | 13411 DCHECK(src_obj->IsUndefined(isolate)); |
13410 script->set_line_ends(isolate->heap()->empty_fixed_array()); | 13412 script->set_line_ends(isolate->heap()->empty_fixed_array()); |
13411 } else { | 13413 } else { |
13412 DCHECK(src_obj->IsString()); | 13414 DCHECK(src_obj->IsString()); |
13413 Handle<String> src(String::cast(src_obj), isolate); | 13415 Handle<String> src(String::cast(src_obj), isolate); |
13414 Handle<FixedArray> array = String::CalculateLineEnds(src, true); | 13416 Handle<FixedArray> array = String::CalculateLineEnds(src, true); |
13415 script->set_line_ends(*array); | 13417 script->set_line_ends(*array); |
13416 } | 13418 } |
13417 | 13419 |
13418 DCHECK(script->line_ends()->IsFixedArray()); | 13420 DCHECK(script->line_ends()->IsFixedArray()); |
13419 } | 13421 } |
13420 | 13422 |
13421 bool Script::GetPositionInfo(Handle<Script> script, int position, | 13423 bool Script::GetPositionInfo(Handle<Script> script, int position, |
13422 PositionInfo* info, OffsetFlag offset_flag) { | 13424 PositionInfo* info, OffsetFlag offset_flag) { |
| 13425 // For wasm, we do not create an artificial line_ends array, but do the |
| 13426 // translation directly. |
| 13427 if (script->type() == Script::TYPE_WASM) { |
| 13428 Handle<WasmCompiledModule> compiled_module( |
| 13429 WasmCompiledModule::cast(script->wasm_compiled_module())); |
| 13430 DCHECK_LE(0, position); |
| 13431 return wasm::GetPositionInfo(compiled_module, |
| 13432 static_cast<uint32_t>(position), info); |
| 13433 } |
| 13434 |
13423 InitLineEnds(script); | 13435 InitLineEnds(script); |
13424 return script->GetPositionInfo(position, info, offset_flag); | 13436 return script->GetPositionInfo(position, info, offset_flag); |
13425 } | 13437 } |
13426 | 13438 |
13427 namespace { | 13439 namespace { |
13428 bool GetPositionInfoSlow(const Script* script, int position, | 13440 bool GetPositionInfoSlow(const Script* script, int position, |
13429 Script::PositionInfo* info) { | 13441 Script::PositionInfo* info) { |
13430 if (!script->source()->IsString()) return false; | 13442 if (!script->source()->IsString()) return false; |
13431 if (position < 0) position = 0; | 13443 if (position < 0) position = 0; |
13432 | 13444 |
(...skipping 6967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20400 // depend on this. | 20412 // depend on this. |
20401 return DICTIONARY_ELEMENTS; | 20413 return DICTIONARY_ELEMENTS; |
20402 } | 20414 } |
20403 DCHECK_LE(kind, LAST_ELEMENTS_KIND); | 20415 DCHECK_LE(kind, LAST_ELEMENTS_KIND); |
20404 return kind; | 20416 return kind; |
20405 } | 20417 } |
20406 } | 20418 } |
20407 | 20419 |
20408 } // namespace internal | 20420 } // namespace internal |
20409 } // namespace v8 | 20421 } // namespace v8 |
OLD | NEW |