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

Side by Side Diff: src/api.cc

Issue 2549133002: [debug] Remove DebugInterface class (Closed)
Patch Set: Fix overall CL ;) Created 4 years 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 | « src/api.h ('k') | src/debug/debug.h » ('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 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 8818 matching lines...) Expand 10 before | Expand all | Expand 10 after
8829 Local<Value> value) { 8829 Local<Value> value) {
8830 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); 8830 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
8831 ENTER_V8(isolate); 8831 ENTER_V8(isolate);
8832 i::Handle<i::Object> val = Utils::OpenHandle(*value); 8832 i::Handle<i::Object> val = Utils::OpenHandle(*value);
8833 i::Handle<i::JSArray> result; 8833 i::Handle<i::JSArray> result;
8834 if (!i::Runtime::GetInternalProperties(isolate, val).ToHandle(&result)) 8834 if (!i::Runtime::GetInternalProperties(isolate, val).ToHandle(&result))
8835 return MaybeLocal<Array>(); 8835 return MaybeLocal<Array>();
8836 return Utils::ToLocal(result); 8836 return Utils::ToLocal(result);
8837 } 8837 }
8838 8838
8839 bool DebugInterface::SetDebugEventListener(Isolate* isolate, 8839 bool debug::SetDebugEventListener(Isolate* isolate, debug::EventCallback that,
Yang 2016/12/05 18:48:36 wouldn't it make sense to wrap all of this in a n
Clemens Hammacher 2016/12/05 19:02:13 Depends (probably mostly a matter of style). I lik
8840 DebugInterface::EventCallback that, 8840 Local<Value> data) {
8841 Local<Value> data) {
8842 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 8841 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
8843 ENTER_V8(i_isolate); 8842 ENTER_V8(i_isolate);
8844 i::HandleScope scope(i_isolate); 8843 i::HandleScope scope(i_isolate);
8845 i::Handle<i::Object> foreign = i_isolate->factory()->undefined_value(); 8844 i::Handle<i::Object> foreign = i_isolate->factory()->undefined_value();
8846 if (that != NULL) { 8845 if (that != NULL) {
8847 foreign = i_isolate->factory()->NewForeign(FUNCTION_ADDR(that)); 8846 foreign = i_isolate->factory()->NewForeign(FUNCTION_ADDR(that));
8848 } 8847 }
8849 i_isolate->debug()->SetEventListener(foreign, Utils::OpenHandle(*data, true)); 8848 i_isolate->debug()->SetEventListener(foreign, Utils::OpenHandle(*data, true));
8850 return true; 8849 return true;
8851 } 8850 }
8852 8851
8853 Local<Context> DebugInterface::GetDebugContext(Isolate* isolate) { 8852 Local<Context> debug::GetDebugContext(Isolate* isolate) {
8854 return Debug::GetDebugContext(isolate); 8853 return Debug::GetDebugContext(isolate);
8855 } 8854 }
8856 8855
8857 MaybeLocal<Value> DebugInterface::Call(Local<Context> context, 8856 MaybeLocal<Value> debug::Call(Local<Context> context,
8858 v8::Local<v8::Function> fun, 8857 v8::Local<v8::Function> fun,
8859 v8::Local<v8::Value> data) { 8858 v8::Local<v8::Value> data) {
8860 return Debug::Call(context, fun, data); 8859 return Debug::Call(context, fun, data);
8861 } 8860 }
8862 8861
8863 void DebugInterface::SetLiveEditEnabled(Isolate* isolate, bool enable) { 8862 void debug::SetLiveEditEnabled(Isolate* isolate, bool enable) {
8864 Debug::SetLiveEditEnabled(isolate, enable); 8863 Debug::SetLiveEditEnabled(isolate, enable);
8865 } 8864 }
8866 8865
8867 void DebugInterface::DebugBreak(Isolate* isolate) { 8866 void debug::DebugBreak(Isolate* isolate) { Debug::DebugBreak(isolate); }
8868 Debug::DebugBreak(isolate);
8869 }
8870 8867
8871 void DebugInterface::CancelDebugBreak(Isolate* isolate) { 8868 void debug::CancelDebugBreak(Isolate* isolate) {
8872 Debug::CancelDebugBreak(isolate); 8869 Debug::CancelDebugBreak(isolate);
8873 } 8870 }
8874 8871
8875 MaybeLocal<Array> DebugInterface::GetInternalProperties(Isolate* isolate, 8872 MaybeLocal<Array> debug::GetInternalProperties(Isolate* isolate,
8876 Local<Value> value) { 8873 Local<Value> value) {
8877 return Debug::GetInternalProperties(isolate, value); 8874 return Debug::GetInternalProperties(isolate, value);
8878 } 8875 }
8879 8876
8880 void DebugInterface::ChangeBreakOnException(Isolate* isolate, 8877 void debug::ChangeBreakOnException(Isolate* isolate, ExceptionBreakState type) {
8881 ExceptionBreakState type) {
8882 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); 8878 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
8883 internal_isolate->debug()->ChangeBreakOnException( 8879 internal_isolate->debug()->ChangeBreakOnException(
8884 i::BreakException, type == BreakOnAnyException); 8880 i::BreakException, type == BreakOnAnyException);
8885 internal_isolate->debug()->ChangeBreakOnException(i::BreakUncaughtException, 8881 internal_isolate->debug()->ChangeBreakOnException(i::BreakUncaughtException,
8886 type != NoBreakOnException); 8882 type != NoBreakOnException);
8887 } 8883 }
8888 8884
8889 void DebugInterface::PrepareStep(Isolate* v8_isolate, StepAction action) { 8885 void debug::PrepareStep(Isolate* v8_isolate, StepAction action) {
8890 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); 8886 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
8891 ENTER_V8(isolate); 8887 ENTER_V8(isolate);
8892 CHECK(isolate->debug()->CheckExecutionState()); 8888 CHECK(isolate->debug()->CheckExecutionState());
8893 // Clear all current stepping setup. 8889 // Clear all current stepping setup.
8894 isolate->debug()->ClearStepping(); 8890 isolate->debug()->ClearStepping();
8895 // Prepare step. 8891 // Prepare step.
8896 isolate->debug()->PrepareStep(static_cast<i::StepAction>(action)); 8892 isolate->debug()->PrepareStep(static_cast<i::StepAction>(action));
8897 } 8893 }
8898 8894
8899 void DebugInterface::ClearStepping(Isolate* v8_isolate) { 8895 void debug::ClearStepping(Isolate* v8_isolate) {
8900 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); 8896 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
8901 ENTER_V8(isolate); 8897 ENTER_V8(isolate);
8902 // Clear all current stepping setup. 8898 // Clear all current stepping setup.
8903 isolate->debug()->ClearStepping(); 8899 isolate->debug()->ClearStepping();
8904 } 8900 }
8905 8901
8906 v8::Isolate* DebugInterface::Script::GetIsolate() const { 8902 v8::Isolate* debug::Script::GetIsolate() const {
8907 return reinterpret_cast<v8::Isolate*>(Utils::OpenHandle(this)->GetIsolate()); 8903 return reinterpret_cast<v8::Isolate*>(Utils::OpenHandle(this)->GetIsolate());
8908 } 8904 }
8909 8905
8910 ScriptOriginOptions DebugInterface::Script::OriginOptions() const { 8906 ScriptOriginOptions debug::Script::OriginOptions() const {
8911 return Utils::OpenHandle(this)->origin_options(); 8907 return Utils::OpenHandle(this)->origin_options();
8912 } 8908 }
8913 8909
8914 bool DebugInterface::Script::WasCompiled() const { 8910 bool debug::Script::WasCompiled() const {
8915 return Utils::OpenHandle(this)->compilation_state() == 8911 return Utils::OpenHandle(this)->compilation_state() ==
8916 i::Script::COMPILATION_STATE_COMPILED; 8912 i::Script::COMPILATION_STATE_COMPILED;
8917 } 8913 }
8918 8914
8919 int DebugInterface::Script::Id() const { return Utils::OpenHandle(this)->id(); } 8915 int debug::Script::Id() const { return Utils::OpenHandle(this)->id(); }
8920 8916
8921 int DebugInterface::Script::LineOffset() const { 8917 int debug::Script::LineOffset() const {
8922 return Utils::OpenHandle(this)->line_offset(); 8918 return Utils::OpenHandle(this)->line_offset();
8923 } 8919 }
8924 8920
8925 int DebugInterface::Script::ColumnOffset() const { 8921 int debug::Script::ColumnOffset() const {
8926 return Utils::OpenHandle(this)->column_offset(); 8922 return Utils::OpenHandle(this)->column_offset();
8927 } 8923 }
8928 8924
8929 std::vector<int> DebugInterface::Script::LineEnds() const { 8925 std::vector<int> debug::Script::LineEnds() const {
8930 i::Handle<i::Script> script = Utils::OpenHandle(this); 8926 i::Handle<i::Script> script = Utils::OpenHandle(this);
8931 if (script->type() == i::Script::TYPE_WASM) return std::vector<int>(); 8927 if (script->type() == i::Script::TYPE_WASM) return std::vector<int>();
8932 i::Isolate* isolate = script->GetIsolate(); 8928 i::Isolate* isolate = script->GetIsolate();
8933 i::HandleScope scope(isolate); 8929 i::HandleScope scope(isolate);
8934 i::Script::InitLineEnds(script); 8930 i::Script::InitLineEnds(script);
8935 CHECK(script->line_ends()->IsFixedArray()); 8931 CHECK(script->line_ends()->IsFixedArray());
8936 i::Handle<i::FixedArray> line_ends(i::FixedArray::cast(script->line_ends())); 8932 i::Handle<i::FixedArray> line_ends(i::FixedArray::cast(script->line_ends()));
8937 std::vector<int> result(line_ends->length()); 8933 std::vector<int> result(line_ends->length());
8938 for (int i = 0; i < line_ends->length(); ++i) { 8934 for (int i = 0; i < line_ends->length(); ++i) {
8939 i::Smi* line_end = i::Smi::cast(line_ends->get(i)); 8935 i::Smi* line_end = i::Smi::cast(line_ends->get(i));
8940 result[i] = line_end->value(); 8936 result[i] = line_end->value();
8941 } 8937 }
8942 return result; 8938 return result;
8943 } 8939 }
8944 8940
8945 MaybeLocal<String> DebugInterface::Script::Name() const { 8941 MaybeLocal<String> debug::Script::Name() const {
8946 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 8942 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
8947 i::HandleScope handle_scope(isolate); 8943 i::HandleScope handle_scope(isolate);
8948 i::Handle<i::Script> script = Utils::OpenHandle(this); 8944 i::Handle<i::Script> script = Utils::OpenHandle(this);
8949 i::Handle<i::Object> value(script->name(), isolate); 8945 i::Handle<i::Object> value(script->name(), isolate);
8950 if (!value->IsString()) return MaybeLocal<String>(); 8946 if (!value->IsString()) return MaybeLocal<String>();
8951 return Utils::ToLocal( 8947 return Utils::ToLocal(
8952 handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value))); 8948 handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value)));
8953 } 8949 }
8954 8950
8955 MaybeLocal<String> DebugInterface::Script::SourceURL() const { 8951 MaybeLocal<String> debug::Script::SourceURL() const {
8956 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 8952 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
8957 i::HandleScope handle_scope(isolate); 8953 i::HandleScope handle_scope(isolate);
8958 i::Handle<i::Script> script = Utils::OpenHandle(this); 8954 i::Handle<i::Script> script = Utils::OpenHandle(this);
8959 i::Handle<i::Object> value(script->source_url(), isolate); 8955 i::Handle<i::Object> value(script->source_url(), isolate);
8960 if (!value->IsString()) return MaybeLocal<String>(); 8956 if (!value->IsString()) return MaybeLocal<String>();
8961 return Utils::ToLocal( 8957 return Utils::ToLocal(
8962 handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value))); 8958 handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value)));
8963 } 8959 }
8964 8960
8965 MaybeLocal<String> DebugInterface::Script::SourceMappingURL() const { 8961 MaybeLocal<String> debug::Script::SourceMappingURL() const {
8966 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 8962 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
8967 i::HandleScope handle_scope(isolate); 8963 i::HandleScope handle_scope(isolate);
8968 i::Handle<i::Script> script = Utils::OpenHandle(this); 8964 i::Handle<i::Script> script = Utils::OpenHandle(this);
8969 i::Handle<i::Object> value(script->source_mapping_url(), isolate); 8965 i::Handle<i::Object> value(script->source_mapping_url(), isolate);
8970 if (!value->IsString()) return MaybeLocal<String>(); 8966 if (!value->IsString()) return MaybeLocal<String>();
8971 return Utils::ToLocal( 8967 return Utils::ToLocal(
8972 handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value))); 8968 handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value)));
8973 } 8969 }
8974 8970
8975 MaybeLocal<String> DebugInterface::Script::ContextData() const { 8971 MaybeLocal<String> debug::Script::ContextData() const {
8976 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 8972 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
8977 i::HandleScope handle_scope(isolate); 8973 i::HandleScope handle_scope(isolate);
8978 i::Handle<i::Script> script = Utils::OpenHandle(this); 8974 i::Handle<i::Script> script = Utils::OpenHandle(this);
8979 i::Handle<i::Object> value(script->context_data(), isolate); 8975 i::Handle<i::Object> value(script->context_data(), isolate);
8980 if (!value->IsString()) return MaybeLocal<String>(); 8976 if (!value->IsString()) return MaybeLocal<String>();
8981 return Utils::ToLocal( 8977 return Utils::ToLocal(
8982 handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value))); 8978 handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value)));
8983 } 8979 }
8984 8980
8985 MaybeLocal<String> DebugInterface::Script::Source() const { 8981 MaybeLocal<String> debug::Script::Source() const {
8986 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 8982 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
8987 i::HandleScope handle_scope(isolate); 8983 i::HandleScope handle_scope(isolate);
8988 i::Handle<i::Script> script = Utils::OpenHandle(this); 8984 i::Handle<i::Script> script = Utils::OpenHandle(this);
8989 i::Handle<i::Object> value(script->source(), isolate); 8985 i::Handle<i::Object> value(script->source(), isolate);
8990 if (!value->IsString()) return MaybeLocal<String>(); 8986 if (!value->IsString()) return MaybeLocal<String>();
8991 return Utils::ToLocal( 8987 return Utils::ToLocal(
8992 handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value))); 8988 handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value)));
8993 } 8989 }
8994 8990
8995 bool DebugInterface::Script::IsWasm() const { 8991 bool debug::Script::IsWasm() const {
8996 return Utils::OpenHandle(this)->type() == i::Script::TYPE_WASM; 8992 return Utils::OpenHandle(this)->type() == i::Script::TYPE_WASM;
8997 } 8993 }
8998 8994
8999 namespace { 8995 namespace {
9000 int GetSmiValue(i::Handle<i::FixedArray> array, int index) { 8996 int GetSmiValue(i::Handle<i::FixedArray> array, int index) {
9001 return i::Smi::cast(array->get(index))->value(); 8997 return i::Smi::cast(array->get(index))->value();
9002 } 8998 }
9003 } // namespace 8999 } // namespace
9004 9000
9005 bool DebugInterface::Script::GetPossibleBreakpoints( 9001 bool debug::Script::GetPossibleBreakpoints(
9006 const debug::Location& start, const debug::Location& end, 9002 const debug::Location& start, const debug::Location& end,
9007 std::vector<debug::Location>* locations) const { 9003 std::vector<debug::Location>* locations) const {
9008 CHECK(!start.IsEmpty()); 9004 CHECK(!start.IsEmpty());
9009 i::Handle<i::Script> script = Utils::OpenHandle(this); 9005 i::Handle<i::Script> script = Utils::OpenHandle(this);
9010 if (script->type() == i::Script::TYPE_WASM) { 9006 if (script->type() == i::Script::TYPE_WASM) {
9011 // TODO(clemensh): Return the proper thing once we support wasm breakpoints. 9007 // TODO(clemensh): Return the proper thing once we support wasm breakpoints.
9012 return false; 9008 return false;
9013 } 9009 }
9014 9010
9015 i::Script::InitLineEnds(script); 9011 i::Script::InitLineEnds(script);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
9047 line_offset = GetSmiValue(line_ends, current_line_end_index - 1) + 1; 9043 line_offset = GetSmiValue(line_ends, current_line_end_index - 1) + 1;
9048 } 9044 }
9049 locations->push_back(debug::Location( 9045 locations->push_back(debug::Location(
9050 current_line_end_index + script->line_offset(), 9046 current_line_end_index + script->line_offset(),
9051 offset - line_offset + 9047 offset - line_offset +
9052 (current_line_end_index == 0 ? script->column_offset() : 0))); 9048 (current_line_end_index == 0 ? script->column_offset() : 0)));
9053 } 9049 }
9054 return true; 9050 return true;
9055 } 9051 }
9056 9052
9057 int DebugInterface::Script::GetSourcePosition( 9053 int debug::Script::GetSourcePosition(const debug::Location& location) const {
9058 const debug::Location& location) const {
9059 i::Handle<i::Script> script = Utils::OpenHandle(this); 9054 i::Handle<i::Script> script = Utils::OpenHandle(this);
9060 if (script->type() == i::Script::TYPE_WASM) { 9055 if (script->type() == i::Script::TYPE_WASM) {
9061 // TODO(clemensh): Return the proper thing for wasm. 9056 // TODO(clemensh): Return the proper thing for wasm.
9062 return 0; 9057 return 0;
9063 } 9058 }
9064 9059
9065 int line = std::max(location.GetLineNumber() - script->line_offset(), 0); 9060 int line = std::max(location.GetLineNumber() - script->line_offset(), 0);
9066 int column = location.GetColumnNumber(); 9061 int column = location.GetColumnNumber();
9067 if (line == 0) { 9062 if (line == 0) {
9068 column = std::max(0, column - script->column_offset()); 9063 column = std::max(0, column - script->column_offset());
9069 } 9064 }
9070 9065
9071 i::Script::InitLineEnds(script); 9066 i::Script::InitLineEnds(script);
9072 CHECK(script->line_ends()->IsFixedArray()); 9067 CHECK(script->line_ends()->IsFixedArray());
9073 i::Handle<i::FixedArray> line_ends = i::Handle<i::FixedArray>::cast( 9068 i::Handle<i::FixedArray> line_ends = i::Handle<i::FixedArray>::cast(
9074 i::handle(script->line_ends(), script->GetIsolate())); 9069 i::handle(script->line_ends(), script->GetIsolate()));
9075 CHECK(line_ends->length()); 9070 CHECK(line_ends->length());
9076 if (line >= line_ends->length()) 9071 if (line >= line_ends->length())
9077 return GetSmiValue(line_ends, line_ends->length() - 1); 9072 return GetSmiValue(line_ends, line_ends->length() - 1);
9078 int line_offset = GetSmiValue(line_ends, line); 9073 int line_offset = GetSmiValue(line_ends, line);
9079 if (line == 0) return std::min(column, line_offset); 9074 if (line == 0) return std::min(column, line_offset);
9080 int prev_line_offset = GetSmiValue(line_ends, line - 1); 9075 int prev_line_offset = GetSmiValue(line_ends, line - 1);
9081 return std::min(prev_line_offset + column + 1, line_offset); 9076 return std::min(prev_line_offset + column + 1, line_offset);
9082 } 9077 }
9083 9078
9084 MaybeLocal<DebugInterface::Script> DebugInterface::Script::Wrap( 9079 MaybeLocal<debug::Script> debug::Script::Wrap(v8::Isolate* v8_isolate,
9085 v8::Isolate* v8_isolate, v8::Local<v8::Object> script) { 9080 v8::Local<v8::Object> script) {
9086 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); 9081 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
9087 ENTER_V8(isolate); 9082 ENTER_V8(isolate);
9088 i::HandleScope handle_scope(isolate); 9083 i::HandleScope handle_scope(isolate);
9089 i::Handle<i::JSReceiver> script_receiver(Utils::OpenHandle(*script)); 9084 i::Handle<i::JSReceiver> script_receiver(Utils::OpenHandle(*script));
9090 if (!script_receiver->IsJSValue()) return MaybeLocal<Script>(); 9085 if (!script_receiver->IsJSValue()) return MaybeLocal<Script>();
9091 i::Handle<i::Object> script_value( 9086 i::Handle<i::Object> script_value(
9092 i::Handle<i::JSValue>::cast(script_receiver)->value(), isolate); 9087 i::Handle<i::JSValue>::cast(script_receiver)->value(), isolate);
9093 if (!script_value->IsScript()) { 9088 if (!script_value->IsScript()) {
9094 return MaybeLocal<Script>(); 9089 return MaybeLocal<Script>();
9095 } 9090 }
9096 i::Handle<i::Script> script_obj = i::Handle<i::Script>::cast(script_value); 9091 i::Handle<i::Script> script_obj = i::Handle<i::Script>::cast(script_value);
9097 if (script_obj->type() != i::Script::TYPE_NORMAL && 9092 if (script_obj->type() != i::Script::TYPE_NORMAL &&
9098 script_obj->type() != i::Script::TYPE_WASM) { 9093 script_obj->type() != i::Script::TYPE_WASM) {
9099 return MaybeLocal<Script>(); 9094 return MaybeLocal<Script>();
9100 } 9095 }
9101 return ToApiHandle<DebugInterface::Script>( 9096 return ToApiHandle<debug::Script>(handle_scope.CloseAndEscape(script_obj));
9102 handle_scope.CloseAndEscape(script_obj));
9103 } 9097 }
9104 9098
9105 debug::Location::Location(int line_number, int column_number) 9099 debug::Location::Location(int line_number, int column_number)
9106 : line_number_(line_number), column_number_(column_number) { 9100 : line_number_(line_number), column_number_(column_number) {
9107 CHECK(line_number >= 0); 9101 CHECK(line_number >= 0);
9108 CHECK(column_number >= 0); 9102 CHECK(column_number >= 0);
9109 } 9103 }
9110 9104
9111 debug::Location::Location() : line_number_(-1), column_number_(-1) {} 9105 debug::Location::Location() : line_number_(-1), column_number_(-1) {}
9112 9106
9113 int debug::Location::GetLineNumber() const { 9107 int debug::Location::GetLineNumber() const {
9114 CHECK(line_number_ >= 0); 9108 CHECK(line_number_ >= 0);
9115 return line_number_; 9109 return line_number_;
9116 } 9110 }
9117 9111
9118 int debug::Location::GetColumnNumber() const { 9112 int debug::Location::GetColumnNumber() const {
9119 CHECK(column_number_ >= 0); 9113 CHECK(column_number_ >= 0);
9120 return column_number_; 9114 return column_number_;
9121 } 9115 }
9122 9116
9123 bool debug::Location::IsEmpty() const { 9117 bool debug::Location::IsEmpty() const {
9124 return line_number_ == -1 && column_number_ == -1; 9118 return line_number_ == -1 && column_number_ == -1;
9125 } 9119 }
9126 9120
9127 void DebugInterface::GetLoadedScripts( 9121 void debug::GetLoadedScripts(v8::Isolate* v8_isolate,
9128 v8::Isolate* v8_isolate, 9122 PersistentValueVector<debug::Script>& scripts) {
9129 PersistentValueVector<DebugInterface::Script>& scripts) {
9130 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); 9123 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
9131 ENTER_V8(isolate); 9124 ENTER_V8(isolate);
9132 // TODO(kozyatinskiy): remove this GC once tests are dealt with. 9125 // TODO(kozyatinskiy): remove this GC once tests are dealt with.
9133 isolate->heap()->CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask, 9126 isolate->heap()->CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask,
9134 i::GarbageCollectionReason::kDebugger); 9127 i::GarbageCollectionReason::kDebugger);
9135 { 9128 {
9136 i::DisallowHeapAllocation no_gc; 9129 i::DisallowHeapAllocation no_gc;
9137 i::Script::Iterator iterator(isolate); 9130 i::Script::Iterator iterator(isolate);
9138 i::Script* script; 9131 i::Script* script;
9139 while ((script = iterator.Next())) { 9132 while ((script = iterator.Next())) {
9140 if (script->type() != i::Script::TYPE_NORMAL) continue; 9133 if (script->type() != i::Script::TYPE_NORMAL) continue;
9141 if (script->HasValidSource()) { 9134 if (script->HasValidSource()) {
9142 i::HandleScope handle_scope(isolate); 9135 i::HandleScope handle_scope(isolate);
9143 i::Handle<i::Script> script_handle(script, isolate); 9136 i::Handle<i::Script> script_handle(script, isolate);
9144 scripts.Append(ToApiHandle<Script>(script_handle)); 9137 scripts.Append(ToApiHandle<Script>(script_handle));
9145 } 9138 }
9146 } 9139 }
9147 } 9140 }
9148 } 9141 }
9149 9142
9150 debug::WasmDisassembly DebugInterface::DisassembleWasmFunction( 9143 debug::WasmDisassembly debug::DisassembleWasmFunction(Isolate* v8_isolate,
9151 Isolate* v8_isolate, Local<Object> v8_script, int function_index) { 9144 Local<Object> v8_script,
9145 int function_index) {
9152 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); 9146 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
9153 if (v8_script.IsEmpty()) return {}; 9147 if (v8_script.IsEmpty()) return {};
9154 i::Handle<i::Object> script_wrapper = Utils::OpenHandle(*v8_script); 9148 i::Handle<i::Object> script_wrapper = Utils::OpenHandle(*v8_script);
9155 if (!script_wrapper->IsJSValue()) return {}; 9149 if (!script_wrapper->IsJSValue()) return {};
9156 i::Handle<i::Object> script_obj( 9150 i::Handle<i::Object> script_obj(
9157 i::Handle<i::JSValue>::cast(script_wrapper)->value(), isolate); 9151 i::Handle<i::JSValue>::cast(script_wrapper)->value(), isolate);
9158 if (!script_obj->IsScript()) return {}; 9152 if (!script_obj->IsScript()) return {};
9159 i::Handle<i::Script> script = i::Handle<i::Script>::cast(script_obj); 9153 i::Handle<i::Script> script = i::Handle<i::Script>::cast(script_obj);
9160 if (script->type() != i::Script::TYPE_WASM) return {}; 9154 if (script->type() != i::Script::TYPE_WASM) return {};
9161 i::Handle<i::WasmCompiledModule> compiled_module( 9155 i::Handle<i::WasmCompiledModule> compiled_module(
9162 i::WasmCompiledModule::cast(script->wasm_compiled_module()), isolate); 9156 i::WasmCompiledModule::cast(script->wasm_compiled_module()), isolate);
9163 return compiled_module->DisassembleFunction(function_index); 9157 return compiled_module->DisassembleFunction(function_index);
9164 } 9158 }
9165 9159
9166 MaybeLocal<UnboundScript> DebugInterface::CompileInspectorScript( 9160 MaybeLocal<UnboundScript> debug::CompileInspectorScript(Isolate* v8_isolate,
9167 Isolate* v8_isolate, Local<String> source) { 9161 Local<String> source) {
9168 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); 9162 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
9169 PREPARE_FOR_DEBUG_INTERFACE_EXECUTION_WITH_ISOLATE(isolate, UnboundScript); 9163 PREPARE_FOR_DEBUG_INTERFACE_EXECUTION_WITH_ISOLATE(isolate, UnboundScript);
9170 i::ScriptData* script_data = NULL; 9164 i::ScriptData* script_data = NULL;
9171 i::Handle<i::String> str = Utils::OpenHandle(*source); 9165 i::Handle<i::String> str = Utils::OpenHandle(*source);
9172 i::Handle<i::SharedFunctionInfo> result; 9166 i::Handle<i::SharedFunctionInfo> result;
9173 { 9167 {
9174 ScriptOriginOptions origin_options; 9168 ScriptOriginOptions origin_options;
9175 result = i::Compiler::GetSharedFunctionInfoForScript( 9169 result = i::Compiler::GetSharedFunctionInfoForScript(
9176 str, i::Handle<i::Object>(), 0, 0, origin_options, 9170 str, i::Handle<i::Object>(), 0, 0, origin_options,
9177 i::Handle<i::Object>(), isolate->native_context(), NULL, &script_data, 9171 i::Handle<i::Object>(), isolate->native_context(), NULL, &script_data,
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
9863 Address callback_address = 9857 Address callback_address =
9864 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 9858 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
9865 VMState<EXTERNAL> state(isolate); 9859 VMState<EXTERNAL> state(isolate);
9866 ExternalCallbackScope call_scope(isolate, callback_address); 9860 ExternalCallbackScope call_scope(isolate, callback_address);
9867 callback(info); 9861 callback(info);
9868 } 9862 }
9869 9863
9870 9864
9871 } // namespace internal 9865 } // namespace internal
9872 } // namespace v8 9866 } // namespace v8
OLDNEW
« no previous file with comments | « src/api.h ('k') | src/debug/debug.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698