Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/isolate.h" | 5 #include "src/isolate.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include <fstream> // NOLINT(readability/streams) | 9 #include <fstream> // NOLINT(readability/streams) |
| 10 #include <sstream> | 10 #include <sstream> |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 540 constructor_key_ = factory()->InternalizeOneByteString( | 540 constructor_key_ = factory()->InternalizeOneByteString( |
| 541 STATIC_CHAR_VECTOR("isConstructor")); | 541 STATIC_CHAR_VECTOR("isConstructor")); |
| 542 } | 542 } |
| 543 } | 543 } |
| 544 | 544 |
| 545 Handle<JSObject> NewStackFrameObject(Handle<JSFunction> fun, int position, | 545 Handle<JSObject> NewStackFrameObject(Handle<JSFunction> fun, int position, |
| 546 bool is_constructor) { | 546 bool is_constructor) { |
| 547 Handle<JSObject> stack_frame = | 547 Handle<JSObject> stack_frame = |
| 548 factory()->NewJSObject(isolate_->object_function()); | 548 factory()->NewJSObject(isolate_->object_function()); |
| 549 | 549 |
| 550 Handle<Script> script(Script::cast(fun->shared()->script())); | 550 if (!fun->shared()->script()->IsUndefined()) { |
|
JF
2016/04/11 17:46:33
In which cases is script() undefined? When coming
Clemens Hammacher
2016/04/12 09:30:57
Yes, just for wasm functions. I added a TODO.
| |
| 551 Handle<Script> script(Script::cast(fun->shared()->script())); | |
| 551 | 552 |
| 552 if (!line_key_.is_null()) { | 553 if (!line_key_.is_null()) { |
| 553 int script_line_offset = script->line_offset(); | 554 int script_line_offset = script->line_offset(); |
| 554 int line_number = Script::GetLineNumber(script, position); | 555 int line_number = Script::GetLineNumber(script, position); |
| 555 // line_number is already shifted by the script_line_offset. | 556 // line_number is already shifted by the script_line_offset. |
| 556 int relative_line_number = line_number - script_line_offset; | 557 int relative_line_number = line_number - script_line_offset; |
| 557 if (!column_key_.is_null() && relative_line_number >= 0) { | 558 if (!column_key_.is_null() && relative_line_number >= 0) { |
| 558 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); | 559 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); |
| 559 int start = (relative_line_number == 0) ? 0 : | 560 int start = (relative_line_number == 0) |
| 560 Smi::cast(line_ends->get(relative_line_number - 1))->value() + 1; | 561 ? 0 |
| 561 int column_offset = position - start; | 562 : Smi::cast(line_ends->get(relative_line_number - 1)) |
| 562 if (relative_line_number == 0) { | 563 ->value() + |
| 563 // For the case where the code is on the same line as the script | 564 1; |
| 564 // tag. | 565 int column_offset = position - start; |
| 565 column_offset += script->column_offset(); | 566 if (relative_line_number == 0) { |
| 567 // For the case where the code is on the same line as the script | |
| 568 // tag. | |
| 569 column_offset += script->column_offset(); | |
| 570 } | |
| 571 JSObject::AddProperty( | |
| 572 stack_frame, column_key_, | |
| 573 handle(Smi::FromInt(column_offset + 1), isolate_), NONE); | |
| 566 } | 574 } |
| 567 JSObject::AddProperty(stack_frame, column_key_, | 575 JSObject::AddProperty(stack_frame, line_key_, |
| 568 handle(Smi::FromInt(column_offset + 1), isolate_), | 576 handle(Smi::FromInt(line_number + 1), isolate_), |
| 569 NONE); | 577 NONE); |
| 570 } | 578 } |
| 571 JSObject::AddProperty(stack_frame, line_key_, | |
| 572 handle(Smi::FromInt(line_number + 1), isolate_), | |
| 573 NONE); | |
| 574 } | |
| 575 | 579 |
| 576 if (!script_id_key_.is_null()) { | 580 if (!script_id_key_.is_null()) { |
| 577 JSObject::AddProperty(stack_frame, script_id_key_, | 581 JSObject::AddProperty(stack_frame, script_id_key_, |
| 578 handle(Smi::FromInt(script->id()), isolate_), NONE); | 582 handle(Smi::FromInt(script->id()), isolate_), |
| 579 } | 583 NONE); |
| 584 } | |
| 580 | 585 |
| 581 if (!script_name_key_.is_null()) { | 586 if (!script_name_key_.is_null()) { |
| 582 JSObject::AddProperty(stack_frame, script_name_key_, | 587 JSObject::AddProperty(stack_frame, script_name_key_, |
| 583 handle(script->name(), isolate_), NONE); | 588 handle(script->name(), isolate_), NONE); |
| 584 } | 589 } |
| 585 | 590 |
| 586 if (!script_name_or_source_url_key_.is_null()) { | 591 if (!script_name_or_source_url_key_.is_null()) { |
| 587 Handle<Object> result = Script::GetNameOrSourceURL(script); | 592 Handle<Object> result = Script::GetNameOrSourceURL(script); |
| 588 JSObject::AddProperty(stack_frame, script_name_or_source_url_key_, result, | 593 JSObject::AddProperty(stack_frame, script_name_or_source_url_key_, |
| 589 NONE); | 594 result, NONE); |
| 595 } | |
| 596 | |
| 597 if (!eval_key_.is_null()) { | |
| 598 Handle<Object> is_eval = factory()->ToBoolean( | |
| 599 script->compilation_type() == Script::COMPILATION_TYPE_EVAL); | |
| 600 JSObject::AddProperty(stack_frame, eval_key_, is_eval, NONE); | |
| 601 } | |
| 590 } | 602 } |
| 591 | 603 |
| 592 if (!function_key_.is_null()) { | 604 if (!function_key_.is_null()) { |
| 593 Handle<Object> fun_name = JSFunction::GetDebugName(fun); | 605 Handle<Object> fun_name = JSFunction::GetDebugName(fun); |
| 594 JSObject::AddProperty(stack_frame, function_key_, fun_name, NONE); | 606 JSObject::AddProperty(stack_frame, function_key_, fun_name, NONE); |
| 595 } | 607 } |
| 596 | 608 |
| 597 if (!eval_key_.is_null()) { | |
| 598 Handle<Object> is_eval = factory()->ToBoolean( | |
| 599 script->compilation_type() == Script::COMPILATION_TYPE_EVAL); | |
| 600 JSObject::AddProperty(stack_frame, eval_key_, is_eval, NONE); | |
| 601 } | |
| 602 | |
| 603 if (!constructor_key_.is_null()) { | 609 if (!constructor_key_.is_null()) { |
| 604 Handle<Object> is_constructor_obj = factory()->ToBoolean(is_constructor); | 610 Handle<Object> is_constructor_obj = factory()->ToBoolean(is_constructor); |
| 605 JSObject::AddProperty(stack_frame, constructor_key_, is_constructor_obj, | 611 JSObject::AddProperty(stack_frame, constructor_key_, is_constructor_obj, |
| 606 NONE); | 612 NONE); |
| 607 } | 613 } |
| 608 | 614 |
| 609 return stack_frame; | 615 return stack_frame; |
| 610 } | 616 } |
| 611 | 617 |
| 612 private: | 618 private: |
| (...skipping 2367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2980 // Then check whether this scope intercepts. | 2986 // Then check whether this scope intercepts. |
| 2981 if ((flag & intercept_mask_)) { | 2987 if ((flag & intercept_mask_)) { |
| 2982 intercepted_flags_ |= flag; | 2988 intercepted_flags_ |= flag; |
| 2983 return true; | 2989 return true; |
| 2984 } | 2990 } |
| 2985 return false; | 2991 return false; |
| 2986 } | 2992 } |
| 2987 | 2993 |
| 2988 } // namespace internal | 2994 } // namespace internal |
| 2989 } // namespace v8 | 2995 } // namespace v8 |
| OLD | NEW |