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/api.h" | 5 #include "src/api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
(...skipping 8793 matching lines...) Loading... | |
8804 isolate->debug()->PrepareStep(static_cast<i::StepAction>(action)); | 8804 isolate->debug()->PrepareStep(static_cast<i::StepAction>(action)); |
8805 } | 8805 } |
8806 | 8806 |
8807 void DebugInterface::ClearStepping(Isolate* v8_isolate) { | 8807 void DebugInterface::ClearStepping(Isolate* v8_isolate) { |
8808 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 8808 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
8809 ENTER_V8(isolate); | 8809 ENTER_V8(isolate); |
8810 // Clear all current stepping setup. | 8810 // Clear all current stepping setup. |
8811 isolate->debug()->ClearStepping(); | 8811 isolate->debug()->ClearStepping(); |
8812 } | 8812 } |
8813 | 8813 |
8814 ScriptOriginOptions DebugInterface::Script::OriginOptions() const { | |
8815 i::Handle<i::Script> script = Utils::OpenHandle(this); | |
8816 return script->origin_options(); | |
8817 } | |
8818 | |
8819 bool DebugInterface::Script::WasCompiled() const { | |
8820 i::Handle<i::Script> script = Utils::OpenHandle(this); | |
8821 return script->compilation_state() == i::Script::COMPILATION_STATE_COMPILED; | |
8822 } | |
8823 | |
8824 int DebugInterface::Script::Id() const { | |
8825 i::Handle<i::Script> script = Utils::OpenHandle(this); | |
8826 return script->id(); | |
8827 } | |
8828 | |
8829 int DebugInterface::Script::LineOffset() const { | |
8830 i::Handle<i::Script> script = Utils::OpenHandle(this); | |
8831 return script->line_offset(); | |
8832 } | |
8833 | |
8834 int DebugInterface::Script::ColumnOffset() const { | |
8835 i::Handle<i::Script> script = Utils::OpenHandle(this); | |
8836 return script->column_offset(); | |
8837 } | |
8838 | |
8839 MaybeLocal<Array> DebugInterface::Script::LineEnds( | |
8840 v8::Local<v8::Context> context) const { | |
8841 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate()); | |
8842 i::HandleScope handle_scope(isolate); | |
8843 i::Handle<i::Script> script = Utils::OpenHandle(this); | |
8844 i::Script::InitLineEnds(script); | |
8845 i::Handle<i::Object> line_ends_obj(script->line_ends(), isolate); | |
8846 if (!line_ends_obj->IsFixedArray()) return MaybeLocal<Array>(); | |
8847 i::Handle<i::FixedArray> line_ends = | |
8848 i::Handle<i::FixedArray>::cast(line_ends_obj); | |
8849 auto result = isolate->factory()->NewJSArrayWithElements(line_ends); | |
8850 CHECK(!result.is_null()); | |
8851 return Utils::ToLocal(handle_scope.CloseAndEscape(result)); | |
8852 } | |
8853 | |
8854 MaybeLocal<String> DebugInterface::Script::Name( | |
8855 v8::Local<v8::Context> context) const { | |
8856 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate()); | |
8857 i::HandleScope handle_scope(isolate); | |
8858 i::Handle<i::Script> script = Utils::OpenHandle(this); | |
8859 i::Handle<i::Object> value(script->name(), isolate); | |
8860 if (!value->IsString()) return MaybeLocal<String>(); | |
8861 return Utils::ToLocal( | |
8862 handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value))); | |
8863 } | |
8864 | |
8865 MaybeLocal<String> DebugInterface::Script::SourceURL( | |
8866 v8::Local<v8::Context> context) const { | |
8867 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate()); | |
8868 i::HandleScope handle_scope(isolate); | |
8869 i::Handle<i::Script> script = Utils::OpenHandle(this); | |
8870 i::Handle<i::Object> value(script->source_url(), isolate); | |
8871 if (!value->IsString()) return MaybeLocal<String>(); | |
8872 return Utils::ToLocal( | |
8873 handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value))); | |
8874 } | |
8875 | |
8876 MaybeLocal<String> DebugInterface::Script::SourceMappingURL( | |
8877 v8::Local<v8::Context> context) const { | |
8878 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate()); | |
8879 i::HandleScope handle_scope(isolate); | |
8880 i::Handle<i::Script> script = Utils::OpenHandle(this); | |
8881 i::Handle<i::Object> value(script->source_mapping_url(), isolate); | |
8882 if (!value->IsString()) return MaybeLocal<String>(); | |
8883 return Utils::ToLocal( | |
8884 handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value))); | |
8885 } | |
8886 | |
8887 MaybeLocal<String> DebugInterface::Script::ContextData( | |
8888 v8::Local<v8::Context> context) const { | |
8889 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate()); | |
8890 i::HandleScope handle_scope(isolate); | |
8891 i::Handle<i::Script> script = Utils::OpenHandle(this); | |
8892 i::Handle<i::Object> value(script->context_data(), isolate); | |
8893 if (!value->IsString()) return MaybeLocal<String>(); | |
8894 return Utils::ToLocal( | |
8895 handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value))); | |
8896 } | |
8897 | |
8898 MaybeLocal<String> DebugInterface::Script::Source( | |
8899 v8::Local<v8::Context> context) const { | |
8900 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate()); | |
8901 i::HandleScope handle_scope(isolate); | |
8902 i::Handle<i::Script> script = Utils::OpenHandle(this); | |
8903 i::Handle<i::Object> value(script->source(), isolate); | |
8904 if (!value->IsString()) return MaybeLocal<String>(); | |
8905 return Utils::ToLocal( | |
8906 handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value))); | |
8907 } | |
8908 | |
8909 MaybeLocal<DebugInterface::Script> DebugInterface::Script::Wrap( | |
8910 v8::Local<v8::Context> context, v8::Local<v8::Object> script) { | |
8911 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate()); | |
8912 ENTER_V8(isolate); | |
8913 i::HandleScope handle_scope(isolate); | |
8914 i::Handle<i::JSReceiver> script_receiver(Utils::OpenHandle(*script)); | |
8915 if (!script_receiver->IsJSValue()) return MaybeLocal<Script>(); | |
8916 i::Handle<i::Object> script_value( | |
8917 i::Handle<i::JSValue>::cast(script_receiver)->value(), isolate); | |
8918 if (!script_value->IsScript()) { | |
8919 return MaybeLocal<Script>(); | |
8920 } | |
8921 i::Handle<i::Script> script_obj = i::Handle<i::Script>::cast(script_value); | |
8922 if (script_obj->type() != i::Script::TYPE_NORMAL) return MaybeLocal<Script>(); | |
8923 return ToApiHandle<DebugInterface::Script>( | |
8924 handle_scope.CloseAndEscape(script_obj)); | |
8925 } | |
8926 | |
8927 MaybeLocal<Array> DebugInterface::GetLoadedScripts(v8::Isolate* v8_isolate) { | |
8928 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | |
8929 ENTER_V8(isolate); | |
8930 i::HandleScope handle_scope(isolate); | |
8931 | |
8932 i::Handle<i::FixedArray> instances = isolate->debug()->GetLoadedScripts(); | |
8933 // Convert the script objects to proper JS objects. | |
8934 for (int i = 0; i < instances->length(); i++) { | |
8935 i::Handle<i::Script> script = | |
8936 i::Handle<i::Script>(i::Script::cast(instances->get(i))); | |
8937 i::Handle<i::JSObject> wrapper = i::Script::GetWrapper(script); | |
Yang
2016/10/28 05:39:24
If would be awesome if we could get rid of script
kozy
2016/10/28 05:50:44
We still pass wrapped script as argument of event
| |
8938 instances->set(i, *wrapper); | |
8939 } | |
8940 auto result = isolate->factory()->NewJSArrayWithElements(instances); | |
8941 return Utils::ToLocal(handle_scope.CloseAndEscape(result)); | |
8942 } | |
8943 | |
8814 Local<String> CpuProfileNode::GetFunctionName() const { | 8944 Local<String> CpuProfileNode::GetFunctionName() const { |
8815 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); | 8945 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); |
8816 i::Isolate* isolate = node->isolate(); | 8946 i::Isolate* isolate = node->isolate(); |
8817 const i::CodeEntry* entry = node->entry(); | 8947 const i::CodeEntry* entry = node->entry(); |
8818 i::Handle<i::String> name = | 8948 i::Handle<i::String> name = |
8819 isolate->factory()->InternalizeUtf8String(entry->name()); | 8949 isolate->factory()->InternalizeUtf8String(entry->name()); |
8820 if (!entry->has_name_prefix()) { | 8950 if (!entry->has_name_prefix()) { |
8821 return ToApiHandle<String>(name); | 8951 return ToApiHandle<String>(name); |
8822 } else { | 8952 } else { |
8823 // We do not expect this to fail. Change this if it does. | 8953 // We do not expect this to fail. Change this if it does. |
(...skipping 668 matching lines...) Loading... | |
9492 Address callback_address = | 9622 Address callback_address = |
9493 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 9623 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
9494 VMState<EXTERNAL> state(isolate); | 9624 VMState<EXTERNAL> state(isolate); |
9495 ExternalCallbackScope call_scope(isolate, callback_address); | 9625 ExternalCallbackScope call_scope(isolate, callback_address); |
9496 callback(info); | 9626 callback(info); |
9497 } | 9627 } |
9498 | 9628 |
9499 | 9629 |
9500 } // namespace internal | 9630 } // namespace internal |
9501 } // namespace v8 | 9631 } // namespace v8 |
OLD | NEW |