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

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 v8::Isolate* DebugInterface::Script::GetIsolate() const {
8833 return reinterpret_cast<v8::Isolate*>(Utils::OpenHandle(this)->GetIsolate());
8834 }
8835
8836 ScriptOriginOptions DebugInterface::Script::OriginOptions() const {
8837 return Utils::OpenHandle(this)->origin_options();
8838 }
8839
8840 bool DebugInterface::Script::WasCompiled() const {
8841 return Utils::OpenHandle(this)->compilation_state() ==
8842 i::Script::COMPILATION_STATE_COMPILED;
8843 }
8844
8845 int DebugInterface::Script::Id() const { return Utils::OpenHandle(this)->id(); }
8846
8847 int DebugInterface::Script::LineOffset() const {
8848 return Utils::OpenHandle(this)->line_offset();
8849 }
8850
8851 int DebugInterface::Script::ColumnOffset() const {
8852 return Utils::OpenHandle(this)->column_offset();
8853 }
8854
8855 std::vector<int> DebugInterface::Script::LineEnds() const {
8856 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
8857 i::HandleScope scope(isolate);
8858 i::Script::InitLineEnds(Utils::OpenHandle(this));
8859 i::Handle<i::Object> line_ends_obj(Utils::OpenHandle(this)->line_ends(),
8860 isolate);
8861 std::vector<int> result;
8862 if (!line_ends_obj->IsFixedArray()) return result;
8863 i::Handle<i::FixedArray> line_ends =
8864 i::Handle<i::FixedArray>::cast(line_ends_obj);
8865 for (int i = 0; i < line_ends->length(); ++i) {
8866 i::Handle<i::Object> line_end = i::FixedArray::get(*line_ends, i, isolate);
8867 if (line_end->IsSmi()) {
8868 result.push_back(i::Handle<i::Smi>::cast(line_end)->value());
8869 } else {
8870 result.push_back(0);
8871 }
8872 }
8873 return result;
8874 }
8875
8876 MaybeLocal<String> DebugInterface::Script::Name() const {
8877 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
8878 i::HandleScope handle_scope(isolate);
8879 i::Handle<i::Script> script = Utils::OpenHandle(this);
8880 i::Handle<i::Object> value(script->name(), isolate);
8881 if (!value->IsString()) return MaybeLocal<String>();
8882 return Utils::ToLocal(
8883 handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value)));
8884 }
8885
8886 MaybeLocal<String> DebugInterface::Script::SourceURL() const {
8887 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
8888 i::HandleScope handle_scope(isolate);
8889 i::Handle<i::Script> script = Utils::OpenHandle(this);
8890 i::Handle<i::Object> value(script->source_url(), isolate);
8891 if (!value->IsString()) return MaybeLocal<String>();
8892 return Utils::ToLocal(
8893 handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value)));
8894 }
8895
8896 MaybeLocal<String> DebugInterface::Script::SourceMappingURL() const {
8897 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
8898 i::HandleScope handle_scope(isolate);
8899 i::Handle<i::Script> script = Utils::OpenHandle(this);
8900 i::Handle<i::Object> value(script->source_mapping_url(), isolate);
8901 if (!value->IsString()) return MaybeLocal<String>();
8902 return Utils::ToLocal(
8903 handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value)));
8904 }
8905
8906 MaybeLocal<String> DebugInterface::Script::ContextData() const {
8907 i::Isolate* isolate = Utils::OpenHandle(this)->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() const {
8917 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
8918 i::HandleScope handle_scope(isolate);
8919 i::Handle<i::Script> script = Utils::OpenHandle(this);
8920 i::Handle<i::Object> value(script->source(), isolate);
8921 if (!value->IsString()) return MaybeLocal<String>();
8922 return Utils::ToLocal(
8923 handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value)));
8924 }
8925
8926 MaybeLocal<DebugInterface::Script> DebugInterface::Script::Wrap(
8927 v8::Isolate* v8_isolate, v8::Local<v8::Object> script) {
8928 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
8929 ENTER_V8(isolate);
8930 i::HandleScope handle_scope(isolate);
8931 i::Handle<i::JSReceiver> script_receiver(Utils::OpenHandle(*script));
8932 if (!script_receiver->IsJSValue()) return MaybeLocal<Script>();
8933 i::Handle<i::Object> script_value(
8934 i::Handle<i::JSValue>::cast(script_receiver)->value(), isolate);
8935 if (!script_value->IsScript()) {
8936 return MaybeLocal<Script>();
8937 }
8938 i::Handle<i::Script> script_obj = i::Handle<i::Script>::cast(script_value);
8939 if (script_obj->type() != i::Script::TYPE_NORMAL) return MaybeLocal<Script>();
8940 return ToApiHandle<DebugInterface::Script>(
8941 handle_scope.CloseAndEscape(script_obj));
8942 }
8943
8944 void DebugInterface::GetLoadedScripts(
8945 v8::Isolate* v8_isolate,
8946 PersistentValueVector<DebugInterface::Script>& scripts) {
8947 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
8948 ENTER_V8(isolate);
8949 i::HandleScope handle_scope(isolate);
8950 i::Handle<i::FixedArray> instances = isolate->debug()->GetLoadedScripts();
8951 for (int i = 0; i < instances->length(); i++) {
8952 i::Handle<i::Script> script =
8953 i::Handle<i::Script>(i::Script::cast(instances->get(i)));
8954 if (script->type() != i::Script::TYPE_NORMAL) continue;
8955 scripts.Append(ToApiHandle<Script>(script));
8956 }
8957 }
8958
8832 Local<String> CpuProfileNode::GetFunctionName() const { 8959 Local<String> CpuProfileNode::GetFunctionName() const {
8833 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); 8960 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
8834 i::Isolate* isolate = node->isolate(); 8961 i::Isolate* isolate = node->isolate();
8835 const i::CodeEntry* entry = node->entry(); 8962 const i::CodeEntry* entry = node->entry();
8836 i::Handle<i::String> name = 8963 i::Handle<i::String> name =
8837 isolate->factory()->InternalizeUtf8String(entry->name()); 8964 isolate->factory()->InternalizeUtf8String(entry->name());
8838 if (!entry->has_name_prefix()) { 8965 if (!entry->has_name_prefix()) {
8839 return ToApiHandle<String>(name); 8966 return ToApiHandle<String>(name);
8840 } else { 8967 } else {
8841 // We do not expect this to fail. Change this if it does. 8968 // 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 = 9637 Address callback_address =
9511 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 9638 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
9512 VMState<EXTERNAL> state(isolate); 9639 VMState<EXTERNAL> state(isolate);
9513 ExternalCallbackScope call_scope(isolate, callback_address); 9640 ExternalCallbackScope call_scope(isolate, callback_address);
9514 callback(info); 9641 callback(info);
9515 } 9642 }
9516 9643
9517 9644
9518 } // namespace internal 9645 } // namespace internal
9519 } // namespace v8 9646 } // namespace v8
OLDNEW
« no previous file with comments | « src/api.h ('k') | src/debug/debug-interface.h » ('j') | src/inspector/v8-debugger-script.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698