| 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 13357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13368 DCHECK(position >= 0); | 13368 DCHECK(position >= 0); |
| 13369 set_eval_from_position(position); | 13369 set_eval_from_position(position); |
| 13370 } | 13370 } |
| 13371 return position; | 13371 return position; |
| 13372 } | 13372 } |
| 13373 | 13373 |
| 13374 void Script::InitLineEnds(Handle<Script> script) { | 13374 void Script::InitLineEnds(Handle<Script> script) { |
| 13375 Isolate* isolate = script->GetIsolate(); | 13375 Isolate* isolate = script->GetIsolate(); |
| 13376 if (!script->line_ends()->IsUndefined(isolate)) return; | 13376 if (!script->line_ends()->IsUndefined(isolate)) return; |
| 13377 | 13377 |
| 13378 if (!script->source()->IsString()) { | 13378 Object* src_obj = script->source(); |
| 13379 DCHECK(script->source()->IsUndefined(isolate)); | 13379 if (!src_obj->IsString()) { |
| 13380 Handle<FixedArray> empty = isolate->factory()->NewFixedArray(0); | 13380 DCHECK(src_obj->IsUndefined(isolate)); |
| 13381 script->set_line_ends(*empty); | 13381 script->set_line_ends(isolate->heap()->empty_fixed_array()); |
| 13382 DCHECK(script->line_ends()->IsFixedArray()); | 13382 } else { |
| 13383 return; | 13383 DCHECK(src_obj->IsString()); |
| 13384 Handle<String> src(String::cast(src_obj), isolate); |
| 13385 Handle<FixedArray> array = String::CalculateLineEnds(src, true); |
| 13386 script->set_line_ends(*array); |
| 13384 } | 13387 } |
| 13385 | 13388 |
| 13386 Handle<String> src(String::cast(script->source()), isolate); | |
| 13387 | |
| 13388 Handle<FixedArray> array = String::CalculateLineEnds(src, true); | |
| 13389 | |
| 13390 if (*array != isolate->heap()->empty_fixed_array()) { | |
| 13391 array->set_map(isolate->heap()->fixed_cow_array_map()); | |
| 13392 } | |
| 13393 | |
| 13394 script->set_line_ends(*array); | |
| 13395 DCHECK(script->line_ends()->IsFixedArray()); | 13389 DCHECK(script->line_ends()->IsFixedArray()); |
| 13396 } | 13390 } |
| 13397 | 13391 |
| 13398 #define SMI_VALUE(x) (Smi::cast(x)->value()) | 13392 #define SMI_VALUE(x) (Smi::cast(x)->value()) |
| 13399 bool Script::GetPositionInfo(int position, PositionInfo* info, | 13393 bool Script::GetPositionInfo(int position, PositionInfo* info, |
| 13400 OffsetFlag offset_flag) { | 13394 OffsetFlag offset_flag) { |
| 13401 Handle<Script> script(this); | 13395 Handle<Script> script(this); |
| 13402 InitLineEnds(script); | 13396 InitLineEnds(script); |
| 13403 | 13397 |
| 13404 DisallowHeapAllocation no_allocation; | 13398 DisallowHeapAllocation no_allocation; |
| (...skipping 6904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20309 // Check if the accessor uses a cached property. | 20303 // Check if the accessor uses a cached property. |
| 20310 if (!fti->cached_property_name()->IsTheHole(isolate)) { | 20304 if (!fti->cached_property_name()->IsTheHole(isolate)) { |
| 20311 return handle(Name::cast(fti->cached_property_name())); | 20305 return handle(Name::cast(fti->cached_property_name())); |
| 20312 } | 20306 } |
| 20313 } | 20307 } |
| 20314 return MaybeHandle<Name>(); | 20308 return MaybeHandle<Name>(); |
| 20315 } | 20309 } |
| 20316 | 20310 |
| 20317 } // namespace internal | 20311 } // namespace internal |
| 20318 } // namespace v8 | 20312 } // namespace v8 |
| OLD | NEW |