Skip to content

Commit

Permalink
Revert of [inspector] move console to builtins (patchset crosswalk-pr…
Browse files Browse the repository at this point in the history
…oject#7 id:140001 of https://codereview.chromium.org/2785293002/ )

Reason for revert:
http://crbug.com/v8/6198

Original issue's description:
> [inspector] move console to builtins
>
> What will we get:
> - console would be included into snapshot and allow us to reduce time that we spent in contextCreated function (~5 times faster),
> - it allows us to make further small improvement of console methods, e.g. we can implement super quick return from console.assert if first argument is true,
> - console calls are ~ 15% faster.
>
> BUG=v8:6175
> R=dgozman@chromium.org
>
> Review-Url: https://codereview.chromium.org/2785293002
> Cr-Original-Commit-Position: refs/heads/master@{#44353}
> Committed: https://chromium.googlesource.com/v8/v8/+/55905f85d63d75aaa9313e51eb7bede754a8e41c
> Review-Url: https://codereview.chromium.org/2785293002
> Cr-Commit-Position: refs/heads/master@{#44355}
> Committed: https://chromium.googlesource.com/v8/v8/+/cc74ea0bc4fe4a71fa53d08b62cc18d15e01fbb3

TBR=dgozman@chromium.org,kozyatinskiy@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=v8:6175

Review-Url: https://codereview.chromium.org/2790343002
Cr-Commit-Position: refs/heads/master@{#44358}
  • Loading branch information
mi-ac authored and Commit bot committed Apr 4, 2017
1 parent 238d5b4 commit 7c10795
Show file tree
Hide file tree
Showing 17 changed files with 160 additions and 386 deletions.
1 change: 0 additions & 1 deletion BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,6 @@ v8_source_set("v8_builtins_generators") {
"src/builtins/builtins-async-generator-gen.cc",
"src/builtins/builtins-async-iterator-gen.cc",
"src/builtins/builtins-boolean-gen.cc",
"src/builtins/builtins-console.cc",
"src/builtins/builtins-constructor-gen.cc",
"src/builtins/builtins-constructor-gen.h",
"src/builtins/builtins-constructor.h",
Expand Down
4 changes: 0 additions & 4 deletions include/v8.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,6 @@ class FunctionCallbackArguments;
class GlobalHandles;
} // namespace internal

namespace debug {
class ConsoleCallArguments;
} // namespace debug

// --- Handles ---

Expand Down Expand Up @@ -3569,7 +3566,6 @@ class FunctionCallbackInfo {
protected:
friend class internal::FunctionCallbackArguments;
friend class internal::CustomArguments<FunctionCallbackInfo>;
friend class debug::ConsoleCallArguments;
static const int kHolderIndex = 0;
static const int kIsolateIndex = 1;
static const int kReturnValueDefaultValueIndex = 2;
Expand Down
17 changes: 0 additions & 17 deletions src/api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "src/base/safe_conversions.h"
#include "src/base/utils/random-number-generator.h"
#include "src/bootstrapper.h"
#include "src/builtins/builtins-utils.h"
#include "src/char-predicates-inl.h"
#include "src/code-stubs.h"
#include "src/compiler-dispatcher/compiler-dispatcher.h"
Expand Down Expand Up @@ -9565,22 +9564,6 @@ Local<Function> debug::GetBuiltin(Isolate* v8_isolate, Builtin builtin) {
return Utils::ToLocal(handle_scope.CloseAndEscape(fun));
}

void debug::SetConsoleDelegate(Isolate* v8_isolate, ConsoleDelegate* delegate) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
ENTER_V8(isolate);
isolate->set_console_delegate(delegate);
}

debug::ConsoleCallArguments::ConsoleCallArguments(
const v8::FunctionCallbackInfo<v8::Value>& info)
: v8::FunctionCallbackInfo<v8::Value>(nullptr, info.values_, info.length_) {
}

debug::ConsoleCallArguments::ConsoleCallArguments(
internal::BuiltinArguments& args)
: v8::FunctionCallbackInfo<v8::Value>(nullptr, &args[0] - 1,
args.length() - 1) {}

MaybeLocal<debug::Script> debug::GeneratorObject::Script() {
i::Handle<i::JSGeneratorObject> obj = Utils::OpenHandle(this);
i::Object* maybe_script = obj->function()->shared()->script();
Expand Down
48 changes: 0 additions & 48 deletions src/bootstrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2604,54 +2604,6 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
}

{ // -- C o n s o l e
Handle<String> name = factory->InternalizeUtf8String("console");
Handle<JSFunction> cons = factory->NewFunction(name);
Handle<JSObject> empty = factory->NewJSObject(isolate->object_function());
JSFunction::SetInstancePrototype(cons, empty);
Handle<JSObject> console = factory->NewJSObject(cons, TENURED);
DCHECK(console->IsJSObject());
JSObject::AddProperty(global, name, console, DONT_ENUM);
SimpleInstallFunction(console, "debug", Builtins::kConsoleDebug, 1, false);
SimpleInstallFunction(console, "error", Builtins::kConsoleError, 1, false);
SimpleInstallFunction(console, "info", Builtins::kConsoleInfo, 1, false);
SimpleInstallFunction(console, "log", Builtins::kConsoleLog, 1, false);
SimpleInstallFunction(console, "warn", Builtins::kConsoleWarn, 1, false);
SimpleInstallFunction(console, "dir", Builtins::kConsoleDir, 1, false);
SimpleInstallFunction(console, "dirxml", Builtins::kConsoleDirXml, 1,
false);
SimpleInstallFunction(console, "table", Builtins::kConsoleTable, 1, false);
SimpleInstallFunction(console, "trace", Builtins::kConsoleTrace, 1, false);
SimpleInstallFunction(console, "group", Builtins::kConsoleGroup, 1, false);
SimpleInstallFunction(console, "groupCollapsed",
Builtins::kConsoleGroupCollapsed, 1, false);
SimpleInstallFunction(console, "groupEnd", Builtins::kConsoleGroupEnd, 1,
false);
SimpleInstallFunction(console, "clear", Builtins::kConsoleClear, 1, false);
SimpleInstallFunction(console, "count", Builtins::kConsoleCount, 1, false);
SimpleInstallFunction(console, "assert", Builtins::kConsoleAssert, 1,
false);
SimpleInstallFunction(console, "markTimeline",
Builtins::kConsoleMarkTimeline, 1, false);
SimpleInstallFunction(console, "profile", Builtins::kConsoleProfile, 1,
false);
SimpleInstallFunction(console, "profileEnd", Builtins::kConsoleProfileEnd,
1, false);
SimpleInstallFunction(console, "timeline", Builtins::kConsoleTimeline, 1,
false);
SimpleInstallFunction(console, "timelineEnd", Builtins::kConsoleTimelineEnd,
1, false);
SimpleInstallFunction(console, "time", Builtins::kConsoleTime, 1, false);
SimpleInstallFunction(console, "timeEnd", Builtins::kConsoleTimeEnd, 1,
false);
SimpleInstallFunction(console, "timeStamp", Builtins::kConsoleTimeStamp, 1,
false);
JSObject::AddProperty(
console, factory->to_string_tag_symbol(),
factory->NewStringFromAsciiChecked("Object"),
static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
}

#ifdef V8_I18N_SUPPORT
{ // -- I n t l
Handle<String> name = factory->InternalizeUtf8String("Intl");
Expand Down
56 changes: 0 additions & 56 deletions src/builtins/builtins-console.cc

This file was deleted.

25 changes: 0 additions & 25 deletions src/builtins/builtins-definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,31 +335,6 @@ namespace internal {
CPP(CallSitePrototypeIsToplevel) \
CPP(CallSitePrototypeToString) \
\
/* Console */ \
CPP(ConsoleDebug) \
CPP(ConsoleError) \
CPP(ConsoleInfo) \
CPP(ConsoleLog) \
CPP(ConsoleWarn) \
CPP(ConsoleDir) \
CPP(ConsoleDirXml) \
CPP(ConsoleTable) \
CPP(ConsoleTrace) \
CPP(ConsoleGroup) \
CPP(ConsoleGroupCollapsed) \
CPP(ConsoleGroupEnd) \
CPP(ConsoleClear) \
CPP(ConsoleCount) \
CPP(ConsoleAssert) \
CPP(ConsoleMarkTimeline) \
CPP(ConsoleProfile) \
CPP(ConsoleProfileEnd) \
CPP(ConsoleTimeline) \
CPP(ConsoleTimelineEnd) \
CPP(ConsoleTime) \
CPP(ConsoleTimeEnd) \
CPP(ConsoleTimeStamp) \
\
/* DataView */ \
CPP(DataViewConstructor) \
CPP(DataViewConstructor_ConstructStub) \
Expand Down
2 changes: 0 additions & 2 deletions src/debug/debug-interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,6 @@ enum Builtin {

Local<Function> GetBuiltin(Isolate* isolate, Builtin builtin);

void SetConsoleDelegate(Isolate* isolate, ConsoleDelegate* delegate);

/**
* Native wrapper around v8::internal::JSGeneratorObject object.
*/
Expand Down
47 changes: 0 additions & 47 deletions src/debug/interface-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,9 @@
#include <string>
#include <vector>

#include "include/v8.h"
#include "src/globals.h"

namespace v8 {

namespace internal {
class BuiltinArguments;
} // internal

namespace debug {

/**
Expand Down Expand Up @@ -96,47 +90,6 @@ class V8_EXPORT_PRIVATE BreakLocation : public Location {
BreakLocationType type_;
};

class ConsoleCallArguments : private v8::FunctionCallbackInfo<v8::Value> {
public:
int Length() const { return v8::FunctionCallbackInfo<v8::Value>::Length(); }
V8_INLINE Local<Value> operator[](int i) const {
return v8::FunctionCallbackInfo<v8::Value>::operator[](i);
}

explicit ConsoleCallArguments(const v8::FunctionCallbackInfo<v8::Value>&);
explicit ConsoleCallArguments(internal::BuiltinArguments&);
};

// v8::FunctionCallbackInfo could be used for getting arguments only. Calling
// of any other getter will produce a crash.
class ConsoleDelegate {
public:
virtual void Debug(const ConsoleCallArguments& args) {}
virtual void Error(const ConsoleCallArguments& args) {}
virtual void Info(const ConsoleCallArguments& args) {}
virtual void Log(const ConsoleCallArguments& args) {}
virtual void Warn(const ConsoleCallArguments& args) {}
virtual void Dir(const ConsoleCallArguments& args) {}
virtual void DirXml(const ConsoleCallArguments& args) {}
virtual void Table(const ConsoleCallArguments& args) {}
virtual void Trace(const ConsoleCallArguments& args) {}
virtual void Group(const ConsoleCallArguments& args) {}
virtual void GroupCollapsed(const ConsoleCallArguments& args) {}
virtual void GroupEnd(const ConsoleCallArguments& args) {}
virtual void Clear(const ConsoleCallArguments& args) {}
virtual void Count(const ConsoleCallArguments& args) {}
virtual void Assert(const ConsoleCallArguments& args) {}
virtual void MarkTimeline(const ConsoleCallArguments& args) {}
virtual void Profile(const ConsoleCallArguments& args) {}
virtual void ProfileEnd(const ConsoleCallArguments& args) {}
virtual void Timeline(const ConsoleCallArguments& args) {}
virtual void TimelineEnd(const ConsoleCallArguments& args) {}
virtual void Time(const ConsoleCallArguments& args) {}
virtual void TimeEnd(const ConsoleCallArguments& args) {}
virtual void TimeStamp(const ConsoleCallArguments& args) {}
virtual ~ConsoleDelegate() = default;
};

} // namespace debug
} // namespace v8

Expand Down
18 changes: 10 additions & 8 deletions src/inspector/inspected-context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@ InspectedContext::InspectedContext(V8InspectorImpl* inspector,
v8::Isolate* isolate = m_inspector->isolate();
info.context->SetEmbedderData(static_cast<int>(v8::Context::kDebugIdIndex),
v8::Int32::New(isolate, contextId));
if (!info.hasMemoryOnConsole) return;
v8::Context::Scope contextScope(info.context);
v8::Local<v8::Object> global = info.context->Global();
v8::Local<v8::Value> console;
if (global->Get(info.context, toV8String(m_inspector->isolate(), "console"))
.ToLocal(&console) &&
console->IsObject()) {
m_inspector->console()->installMemoryGetter(
info.context, v8::Local<v8::Object>::Cast(console));
v8::Local<v8::Object> console =
m_inspector->console()->createConsole(info.context);
if (info.hasMemoryOnConsole) {
m_inspector->console()->installMemoryGetter(info.context, console);
}
if (!global
->Set(info.context, toV8StringInternalized(isolate, "console"),
console)
.FromMaybe(false)) {
return;
}
}

Expand Down
Loading

0 comments on commit 7c10795

Please sign in to comment.