Commit d9ceb017 authored by cbruni's avatar cbruni Committed by Commit bot

More inlineable Isolate functions

The showed up unnaturally high while profiling DOM node creation.

BUG=chromium:630217

Review-Url: https://codereview.chromium.org/2181323002
Cr-Commit-Position: refs/heads/master@{#38068}
parent 77d6ef38
......@@ -17,6 +17,11 @@ void Isolate::set_context(Context* context) {
thread_local_top_.context_ = context;
}
Handle<Context> Isolate::native_context() {
return handle(context()->native_context(), this);
}
Context* Isolate::raw_native_context() { return context()->native_context(); }
Object* Isolate::pending_exception() {
DCHECK(has_pending_exception());
......@@ -71,6 +76,11 @@ bool Isolate::is_catchable_by_javascript(Object* exception) {
return exception != heap()->termination_exception();
}
void Isolate::FireBeforeCallEnteredCallback() {
for (int i = 0; i < before_call_entered_callbacks_.length(); i++) {
before_call_entered_callbacks_.at(i)(reinterpret_cast<v8::Isolate*>(this));
}
}
Handle<JSGlobalObject> Isolate::global_object() {
return handle(context()->global_object(), this);
......@@ -90,13 +100,12 @@ Isolate::ExceptionScope::~ExceptionScope() {
isolate_->set_pending_exception(*pending_exception_);
}
#define NATIVE_CONTEXT_FIELD_ACCESSOR(index, type, name) \
Handle<type> Isolate::name() { \
return Handle<type>(native_context()->name(), this); \
} \
bool Isolate::is_##name(type* value) { \
return native_context()->is_##name(value); \
#define NATIVE_CONTEXT_FIELD_ACCESSOR(index, type, name) \
Handle<type> Isolate::name() { \
return Handle<type>(raw_native_context()->name(), this); \
} \
bool Isolate::is_##name(type* value) { \
return raw_native_context()->is_##name(value); \
}
NATIVE_CONTEXT_FIELDS(NATIVE_CONTEXT_FIELD_ACCESSOR)
#undef NATIVE_CONTEXT_FIELD_ACCESSOR
......
......@@ -515,7 +515,7 @@ Handle<Object> Isolate::CaptureSimpleStackTrace(Handle<JSReceiver> error_object,
// we reuse the receiver field to pass along a special symbol.
Handle<Object> recv;
if (exit_frame->IsConstructor()) {
recv = handle(heap()->call_site_constructor_symbol(), this);
recv = factory()->call_site_constructor_symbol();
} else {
recv = handle(exit_frame->receiver(), this);
}
......@@ -532,7 +532,7 @@ Handle<Object> Isolate::CaptureSimpleStackTrace(Handle<JSReceiver> error_object,
WasmFrame* wasm_frame = WasmFrame::cast(frame);
Code* code = wasm_frame->unchecked_code();
Handle<AbstractCode> abstract_code =
Handle<AbstractCode>(AbstractCode::cast(code));
Handle<AbstractCode>(AbstractCode::cast(code), this);
int offset =
static_cast<int>(wasm_frame->pc() - code->instruction_start());
elements = MaybeGrow(this, elements, cursor, cursor + 4);
......@@ -642,7 +642,7 @@ class CaptureStackTraceHelper {
bool is_constructor) {
Handle<JSObject> stack_frame =
factory()->NewJSObject(isolate_->object_function());
Handle<Script> script(Script::cast(fun->shared()->script()));
Handle<Script> script(Script::cast(fun->shared()->script()), isolate_);
if (!line_key_.is_null()) {
Script::PositionInfo info;
......@@ -1404,7 +1404,7 @@ void Isolate::PrintCurrentStackTrace(FILE* out) {
JavaScriptFrame* js_frame = JavaScriptFrame::cast(frame);
Handle<Object> pos_obj(Smi::FromInt(pos), this);
// Fetch function and receiver.
Handle<JSFunction> fun(js_frame->function());
Handle<JSFunction> fun(js_frame->function(), this);
Handle<Object> recv(js_frame->receiver(), this);
// Advance to the next JavaScript frame and determine if the
// current frame is the top-level frame.
......@@ -1432,7 +1432,7 @@ bool Isolate::ComputeLocation(MessageLocation* target) {
(Script::cast(script)->source()->IsUndefined(this))) {
return false;
}
Handle<Script> casted_script(Script::cast(script));
Handle<Script> casted_script(Script::cast(script), this);
// Compute the location from the function and the relocation info of the
// baseline code. For optimized code this will use the deoptimization
// information to get canonical location information.
......@@ -1440,7 +1440,7 @@ bool Isolate::ComputeLocation(MessageLocation* target) {
JavaScriptFrame::cast(frame)->Summarize(&frames);
FrameSummary& summary = frames.last();
int pos = summary.abstract_code()->SourcePosition(summary.code_offset());
*target = MessageLocation(casted_script, pos, pos + 1, handle(fun));
*target = MessageLocation(casted_script, pos, pos + 1, handle(fun, this));
return true;
}
......@@ -1620,9 +1620,9 @@ void Isolate::ReportPendingMessages() {
// Actually report the pending message to all message handlers.
if (!message_obj->IsTheHole(this) && should_report_exception) {
HandleScope scope(this);
Handle<JSMessageObject> message(JSMessageObject::cast(message_obj));
Handle<JSValue> script_wrapper(JSValue::cast(message->script()));
Handle<Script> script(Script::cast(script_wrapper->value()));
Handle<JSMessageObject> message(JSMessageObject::cast(message_obj), this);
Handle<JSValue> script_wrapper(JSValue::cast(message->script()), this);
Handle<Script> script(Script::cast(script_wrapper->value()), this);
int start_pos = message->start_position();
int end_pos = message->end_position();
MessageLocation location(script, start_pos, end_pos);
......@@ -1637,9 +1637,9 @@ MessageLocation Isolate::GetMessageLocation() {
if (thread_local_top_.pending_exception_ != heap()->termination_exception() &&
!thread_local_top_.pending_message_obj_->IsTheHole(this)) {
Handle<JSMessageObject> message_obj(
JSMessageObject::cast(thread_local_top_.pending_message_obj_));
Handle<JSValue> script_wrapper(JSValue::cast(message_obj->script()));
Handle<Script> script(Script::cast(script_wrapper->value()));
JSMessageObject::cast(thread_local_top_.pending_message_obj_), this);
Handle<JSValue> script_wrapper(JSValue::cast(message_obj->script()), this);
Handle<Script> script(Script::cast(script_wrapper->value()), this);
int start_pos = message_obj->start_position();
int end_pos = message_obj->end_position();
return MessageLocation(script, start_pos, end_pos);
......@@ -1749,11 +1749,6 @@ void Isolate::SetAbortOnUncaughtExceptionCallback(
}
Handle<Context> Isolate::native_context() {
return handle(context()->native_context());
}
Handle<Context> Isolate::GetCallingNativeContext() {
JavaScriptFrameIterator it(this);
if (debug_->in_debug_scope()) {
......@@ -1770,7 +1765,7 @@ Handle<Context> Isolate::GetCallingNativeContext() {
if (it.done()) return Handle<Context>::null();
JavaScriptFrame* frame = it.frame();
Context* context = Context::cast(frame->context());
return Handle<Context>(context->native_context());
return Handle<Context>(context->native_context(), this);
}
......@@ -2866,13 +2861,6 @@ void Isolate::RemoveBeforeCallEnteredCallback(
}
void Isolate::FireBeforeCallEnteredCallback() {
for (int i = 0; i < before_call_entered_callbacks_.length(); i++) {
before_call_entered_callbacks_.at(i)(reinterpret_cast<v8::Isolate*>(this));
}
}
void Isolate::AddCallCompletedCallback(CallCompletedCallback callback) {
for (int i = 0; i < call_completed_callbacks_.length(); i++) {
if (callback == call_completed_callbacks_.at(i)) return;
......@@ -3084,7 +3072,7 @@ void Isolate::SetTailCallEliminationEnabled(bool enabled) {
void Isolate::AddDetachedContext(Handle<Context> context) {
HandleScope scope(this);
Handle<WeakCell> cell = factory()->NewWeakCell(context);
Handle<FixedArray> detached_contexts(heap()->detached_contexts());
Handle<FixedArray> detached_contexts = factory()->detached_contexts();
int length = detached_contexts->length();
detached_contexts = factory()->CopyFixedArrayAndGrow(detached_contexts, 2);
detached_contexts->set(length, Smi::FromInt(0));
......@@ -3095,7 +3083,7 @@ void Isolate::AddDetachedContext(Handle<Context> context) {
void Isolate::CheckDetachedContextsAfterGC() {
HandleScope scope(this);
Handle<FixedArray> detached_contexts(heap()->detached_contexts());
Handle<FixedArray> detached_contexts = factory()->detached_contexts();
int length = detached_contexts->length();
if (length == 0) return;
int new_length = 0;
......
......@@ -778,7 +778,8 @@ class Isolate {
void IterateThread(ThreadVisitor* v, char* t);
// Returns the current native context.
Handle<Context> native_context();
inline Handle<Context> native_context();
inline Context* raw_native_context();
// Returns the native context of the calling JavaScript code. That
// is, the native context of the top-most JavaScript frame.
......@@ -1079,7 +1080,7 @@ class Isolate {
void AddBeforeCallEnteredCallback(BeforeCallEnteredCallback callback);
void RemoveBeforeCallEnteredCallback(BeforeCallEnteredCallback callback);
void FireBeforeCallEnteredCallback();
inline void FireBeforeCallEnteredCallback();
void AddMicrotasksCompletedCallback(MicrotasksCompletedCallback callback);
void RemoveMicrotasksCompletedCallback(MicrotasksCompletedCallback callback);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment