[interpreter] Port GetDispatchCountersObject to internal
Make the GetDispatchCountersObject function return an internal Handle rather than an API Local. Also, port its implementation to use internal methods rather than API methods. Change-Id: I191e0483263009c835c801462822e4fc7e78680e Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3110198 Commit-Queue: Leszek Swirski <leszeks@chromium.org> Reviewed-by: Dan Elphick <delphick@chromium.org> Reviewed-by: Camillo Bruni <cbruni@chromium.org> Cr-Commit-Position: refs/heads/main@{#76485}
This commit is contained in:
parent
40af03b8c3
commit
9a54cc55c7
10
src/d8/d8.cc
10
src/d8/d8.cc
@ -3183,13 +3183,15 @@ void Shell::WriteIgnitionDispatchCountersFile(v8::Isolate* isolate) {
|
||||
Local<Context> context = Context::New(isolate);
|
||||
Context::Scope context_scope(context);
|
||||
|
||||
Local<Object> dispatch_counters = reinterpret_cast<i::Isolate*>(isolate)
|
||||
->interpreter()
|
||||
->GetDispatchCountersObject();
|
||||
i::Handle<i::JSObject> dispatch_counters =
|
||||
reinterpret_cast<i::Isolate*>(isolate)
|
||||
->interpreter()
|
||||
->GetDispatchCountersObject();
|
||||
std::ofstream dispatch_counters_stream(
|
||||
i::FLAG_trace_ignition_dispatches_output_file);
|
||||
dispatch_counters_stream << *String::Utf8Value(
|
||||
isolate, JSON::Stringify(context, dispatch_counters).ToLocalChecked());
|
||||
isolate, JSON::Stringify(context, Utils::ToLocal(dispatch_counters))
|
||||
.ToLocalChecked());
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "src/extensions/ignition-statistics-extension.h"
|
||||
|
||||
#include "include/v8-template.h"
|
||||
#include "src/api/api-inl.h"
|
||||
#include "src/base/logging.h"
|
||||
#include "src/execution/isolate.h"
|
||||
#include "src/interpreter/bytecodes.h"
|
||||
@ -28,9 +29,10 @@ const char* const IgnitionStatisticsExtension::kSource =
|
||||
|
||||
void IgnitionStatisticsExtension::GetIgnitionDispatchCounters(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
args.GetReturnValue().Set(reinterpret_cast<Isolate*>(args.GetIsolate())
|
||||
->interpreter()
|
||||
->GetDispatchCountersObject());
|
||||
args.GetReturnValue().Set(
|
||||
Utils::ToLocal(reinterpret_cast<Isolate*>(args.GetIsolate())
|
||||
->interpreter()
|
||||
->GetDispatchCountersObject()));
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "src/ast/scopes.h"
|
||||
#include "src/codegen/compiler.h"
|
||||
#include "src/codegen/unoptimized-compilation-info.h"
|
||||
#include "src/common/globals.h"
|
||||
#include "src/execution/local-isolate.h"
|
||||
#include "src/heap/parked-scope.h"
|
||||
#include "src/init/bootstrapper.h"
|
||||
@ -389,11 +390,9 @@ uintptr_t Interpreter::GetDispatchCounter(Bytecode from, Bytecode to) const {
|
||||
to_index];
|
||||
}
|
||||
|
||||
Local<v8::Object> Interpreter::GetDispatchCountersObject() {
|
||||
v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(isolate_);
|
||||
Local<v8::Context> context = isolate->GetCurrentContext();
|
||||
|
||||
Local<v8::Object> counters_map = v8::Object::New(isolate);
|
||||
Handle<JSObject> Interpreter::GetDispatchCountersObject() {
|
||||
Handle<JSObject> counters_map =
|
||||
isolate_->factory()->NewJSObjectWithNullProto();
|
||||
|
||||
// Output is a JSON-encoded object of objects.
|
||||
//
|
||||
@ -408,30 +407,23 @@ Local<v8::Object> Interpreter::GetDispatchCountersObject() {
|
||||
|
||||
for (int from_index = 0; from_index < kNumberOfBytecodes; ++from_index) {
|
||||
Bytecode from_bytecode = Bytecodes::FromByte(from_index);
|
||||
Local<v8::Object> counters_row = v8::Object::New(isolate);
|
||||
Handle<JSObject> counters_row =
|
||||
isolate_->factory()->NewJSObjectWithNullProto();
|
||||
|
||||
for (int to_index = 0; to_index < kNumberOfBytecodes; ++to_index) {
|
||||
Bytecode to_bytecode = Bytecodes::FromByte(to_index);
|
||||
uintptr_t counter = GetDispatchCounter(from_bytecode, to_bytecode);
|
||||
|
||||
if (counter > 0) {
|
||||
std::string to_name = Bytecodes::ToString(to_bytecode);
|
||||
Local<v8::String> to_name_object =
|
||||
v8::String::NewFromUtf8(isolate, to_name.c_str()).ToLocalChecked();
|
||||
Local<v8::Number> counter_object = v8::Number::New(isolate, counter);
|
||||
CHECK(counters_row
|
||||
->DefineOwnProperty(context, to_name_object, counter_object)
|
||||
.IsJust());
|
||||
Handle<Object> value = isolate_->factory()->NewNumberFromSize(counter);
|
||||
JSObject::AddProperty(isolate_, counters_row,
|
||||
Bytecodes::ToString(to_bytecode), value, NONE);
|
||||
}
|
||||
}
|
||||
|
||||
std::string from_name = Bytecodes::ToString(from_bytecode);
|
||||
Local<v8::String> from_name_object =
|
||||
v8::String::NewFromUtf8(isolate, from_name.c_str()).ToLocalChecked();
|
||||
|
||||
CHECK(
|
||||
counters_map->DefineOwnProperty(context, from_name_object, counters_row)
|
||||
.IsJust());
|
||||
JSObject::AddProperty(isolate_, counters_map,
|
||||
Bytecodes::ToString(from_bytecode), counters_row,
|
||||
NONE);
|
||||
}
|
||||
|
||||
return counters_map;
|
||||
|
@ -10,16 +10,12 @@
|
||||
// Clients of this interface shouldn't depend on lots of interpreter internals.
|
||||
// Do not include anything from src/interpreter other than
|
||||
// src/interpreter/bytecodes.h here!
|
||||
#include "include/v8-local-handle.h"
|
||||
#include "src/base/macros.h"
|
||||
#include "src/builtins/builtins.h"
|
||||
#include "src/interpreter/bytecodes.h"
|
||||
#include "src/runtime/runtime.h"
|
||||
|
||||
namespace v8 {
|
||||
|
||||
class Object;
|
||||
|
||||
namespace internal {
|
||||
|
||||
class BytecodeArray;
|
||||
@ -76,9 +72,7 @@ class Interpreter {
|
||||
// Disassembler support.
|
||||
V8_EXPORT_PRIVATE const char* LookupNameOfBytecodeHandler(const Code code);
|
||||
|
||||
// TODO(leszeks): Convert to Handle/raw object to avoid v8-local-handle.h
|
||||
// include and separate this from external interface.
|
||||
V8_EXPORT_PRIVATE Local<v8::Object> GetDispatchCountersObject();
|
||||
V8_EXPORT_PRIVATE Handle<JSObject> GetDispatchCountersObject();
|
||||
|
||||
void ForEachBytecode(const std::function<void(Bytecode, OperandScale)>& f);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user