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

Side by Side Diff: src/api.cc

Issue 2449213002: [inspector] migrate scriptParsed and getCompiledScripts to native (Closed)
Patch Set: addressed comments Created 4 years, 1 month 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
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 8811 matching lines...) Expand 10 before | Expand all | Expand 10 after
8822 isolate->debug()->PrepareStep(static_cast<i::StepAction>(action)); 8822 isolate->debug()->PrepareStep(static_cast<i::StepAction>(action));
8823 } 8823 }
8824 8824
8825 void DebugInterface::ClearStepping(Isolate* v8_isolate) { 8825 void DebugInterface::ClearStepping(Isolate* v8_isolate) {
8826 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); 8826 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
8827 ENTER_V8(isolate); 8827 ENTER_V8(isolate);
8828 // Clear all current stepping setup. 8828 // Clear all current stepping setup.
8829 isolate->debug()->ClearStepping(); 8829 isolate->debug()->ClearStepping();
8830 } 8830 }
8831 8831
8832 ScriptOriginOptions DebugInterface::Script::OriginOptions() const {
8833 i::Handle<i::Script> script = Utils::OpenHandle(this);
8834 return script->origin_options();
8835 }
8836
8837 bool DebugInterface::Script::WasCompiled() const {
8838 i::Handle<i::Script> script = Utils::OpenHandle(this);
8839 return script->compilation_state() == i::Script::COMPILATION_STATE_COMPILED;
8840 }
8841
8842 int DebugInterface::Script::Id() const {
8843 i::Handle<i::Script> script = Utils::OpenHandle(this);
8844 return script->id();
8845 }
8846
8847 int DebugInterface::Script::LineOffset() const {
8848 i::Handle<i::Script> script = Utils::OpenHandle(this);
8849 return script->line_offset();
8850 }
8851
8852 int DebugInterface::Script::ColumnOffset() const {
8853 i::Handle<i::Script> script = Utils::OpenHandle(this);
8854 return script->column_offset();
8855 }
8856
8857 MaybeLocal<Array> DebugInterface::Script::LineEnds(
8858 v8::Local<v8::Context> context) const {
8859 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
8860 i::HandleScope handle_scope(isolate);
8861 i::Handle<i::Script> script = Utils::OpenHandle(this);
8862 i::Script::InitLineEnds(script);
8863 i::Handle<i::Object> line_ends_obj(script->line_ends(), isolate);
8864 if (!line_ends_obj->IsFixedArray()) return MaybeLocal<Array>();
8865 i::Handle<i::FixedArray> line_ends =
8866 i::Handle<i::FixedArray>::cast(line_ends_obj);
8867 auto result = isolate->factory()->NewJSArrayWithElements(line_ends);
8868 CHECK(!result.is_null());
8869 return Utils::ToLocal(handle_scope.CloseAndEscape(result));
8870 }
8871
8872 MaybeLocal<String> DebugInterface::Script::Name(
8873 v8::Local<v8::Context> context) const {
8874 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
8875 i::HandleScope handle_scope(isolate);
8876 i::Handle<i::Script> script = Utils::OpenHandle(this);
8877 i::Handle<i::Object> value(script->name(), isolate);
8878 if (!value->IsString()) return MaybeLocal<String>();
8879 return Utils::ToLocal(
8880 handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value)));
8881 }
8882
8883 MaybeLocal<String> DebugInterface::Script::SourceURL(
8884 v8::Local<v8::Context> context) const {
8885 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
8886 i::HandleScope handle_scope(isolate);
8887 i::Handle<i::Script> script = Utils::OpenHandle(this);
8888 i::Handle<i::Object> value(script->source_url(), isolate);
8889 if (!value->IsString()) return MaybeLocal<String>();
8890 return Utils::ToLocal(
8891 handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value)));
8892 }
8893
8894 MaybeLocal<String> DebugInterface::Script::SourceMappingURL(
8895 v8::Local<v8::Context> context) const {
8896 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
8897 i::HandleScope handle_scope(isolate);
8898 i::Handle<i::Script> script = Utils::OpenHandle(this);
8899 i::Handle<i::Object> value(script->source_mapping_url(), isolate);
8900 if (!value->IsString()) return MaybeLocal<String>();
8901 return Utils::ToLocal(
8902 handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value)));
8903 }
8904
8905 MaybeLocal<String> DebugInterface::Script::ContextData(
8906 v8::Local<v8::Context> context) const {
8907 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
8908 i::HandleScope handle_scope(isolate);
8909 i::Handle<i::Script> script = Utils::OpenHandle(this);
8910 i::Handle<i::Object> value(script->context_data(), isolate);
8911 if (!value->IsString()) return MaybeLocal<String>();
8912 return Utils::ToLocal(
8913 handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value)));
8914 }
8915
8916 MaybeLocal<String> DebugInterface::Script::Source(
8917 v8::Local<v8::Context> context) const {
8918 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
8919 i::HandleScope handle_scope(isolate);
8920 i::Handle<i::Script> script = Utils::OpenHandle(this);
8921 i::Handle<i::Object> value(script->source(), isolate);
8922 if (!value->IsString()) return MaybeLocal<String>();
8923 return Utils::ToLocal(
8924 handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value)));
8925 }
8926
8927 MaybeLocal<DebugInterface::Script> DebugInterface::Script::Wrap(
8928 v8::Local<v8::Context> context, v8::Local<v8::Object> script) {
8929 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
8930 ENTER_V8(isolate);
8931 i::HandleScope handle_scope(isolate);
8932 i::Handle<i::JSReceiver> script_receiver(Utils::OpenHandle(*script));
8933 if (!script_receiver->IsJSValue()) return MaybeLocal<Script>();
8934 i::Handle<i::Object> script_value(
8935 i::Handle<i::JSValue>::cast(script_receiver)->value(), isolate);
8936 if (!script_value->IsScript()) {
8937 return MaybeLocal<Script>();
8938 }
8939 i::Handle<i::Script> script_obj = i::Handle<i::Script>::cast(script_value);
8940 if (script_obj->type() != i::Script::TYPE_NORMAL) return MaybeLocal<Script>();
8941 return ToApiHandle<DebugInterface::Script>(
8942 handle_scope.CloseAndEscape(script_obj));
8943 }
8944
8945 void DebugInterface::GetLoadedScripts(
8946 v8::Isolate* v8_isolate,
8947 PersistentValueVector<DebugInterface::Script>& scripts) {
8948 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
8949 ENTER_V8(isolate);
8950 i::HandleScope handle_scope(isolate);
8951 i::Handle<i::FixedArray> instances = isolate->debug()->GetLoadedScripts();
8952 for (int i = 0; i < instances->length(); i++) {
8953 i::Handle<i::Script> script =
8954 i::Handle<i::Script>(i::Script::cast(instances->get(i)));
8955 if (script->type() != i::Script::TYPE_NORMAL) continue;
8956 scripts.Append(ToApiHandle<Script>(script));
8957 }
8958 }
8959
8832 Local<String> CpuProfileNode::GetFunctionName() const { 8960 Local<String> CpuProfileNode::GetFunctionName() const {
8833 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); 8961 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
8834 i::Isolate* isolate = node->isolate(); 8962 i::Isolate* isolate = node->isolate();
8835 const i::CodeEntry* entry = node->entry(); 8963 const i::CodeEntry* entry = node->entry();
8836 i::Handle<i::String> name = 8964 i::Handle<i::String> name =
8837 isolate->factory()->InternalizeUtf8String(entry->name()); 8965 isolate->factory()->InternalizeUtf8String(entry->name());
8838 if (!entry->has_name_prefix()) { 8966 if (!entry->has_name_prefix()) {
8839 return ToApiHandle<String>(name); 8967 return ToApiHandle<String>(name);
8840 } else { 8968 } else {
8841 // We do not expect this to fail. Change this if it does. 8969 // We do not expect this to fail. Change this if it does.
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
9510 Address callback_address = 9638 Address callback_address =
9511 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 9639 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
9512 VMState<EXTERNAL> state(isolate); 9640 VMState<EXTERNAL> state(isolate);
9513 ExternalCallbackScope call_scope(isolate, callback_address); 9641 ExternalCallbackScope call_scope(isolate, callback_address);
9514 callback(info); 9642 callback(info);
9515 } 9643 }
9516 9644
9517 9645
9518 } // namespace internal 9646 } // namespace internal
9519 } // namespace v8 9647 } // namespace v8
OLDNEW
« no previous file with comments | « src/api.h ('k') | src/debug/debug-interface.h » ('j') | src/debug/debug-interface.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698