Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Merged: Squashed multiple commits.
Browse files Browse the repository at this point in the history
Merged: [ic] Don't share LoadGlobalIC slots inside typeof and outside typeof.
Revision: d634e65

Merged: [ic] Merge LoadGlobalIC_Slow builtins for inside typeof and outside typeof cases.
Revision: b558894

BUG=chromium:634467,chromium:634467
LOG=N
NOTRY=true
NOPRESUBMIT=true
NOTREECHECKS=true
[email protected]

Review URL: https://codereview.chromium.org/2237983004 .

Cr-Commit-Position: refs/branch-heads/5.3@{#42}
Cr-Branched-From: 820a23a-refs/heads/5.3.332@{#2}
Cr-Branched-From: 37538cb-refs/heads/master@{#37308}
  • Loading branch information
jakobkummerow committed Aug 12, 2016
1 parent f4bb828 commit 426f518
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 92 deletions.
15 changes: 2 additions & 13 deletions src/builtins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5612,25 +5612,14 @@ void Generate_LoadIC_Slow(CodeStubAssembler* assembler) {
assembler->TailCallRuntime(Runtime::kGetProperty, context, receiver, name);
}

void Generate_LoadGlobalIC_SlowInsideTypeof(CodeStubAssembler* assembler) {
void Generate_LoadGlobalIC_Slow(CodeStubAssembler* assembler) {
typedef compiler::Node Node;

Node* slot = assembler->Parameter(0);
Node* vector = assembler->Parameter(1);
Node* context = assembler->Parameter(2);

assembler->TailCallRuntime(Runtime::kGetGlobalInsideTypeof, context, slot,
vector);
}

void Generate_LoadGlobalIC_SlowNotInsideTypeof(CodeStubAssembler* assembler) {
typedef compiler::Node Node;

Node* slot = assembler->Parameter(0);
Node* vector = assembler->Parameter(1);
Node* context = assembler->Parameter(2);

assembler->TailCallRuntime(Runtime::kGetGlobalNotInsideTypeof, context, slot,
assembler->TailCallRuntime(Runtime::kLoadGlobalIC_Slow, context, slot,
vector);
}

Expand Down
11 changes: 4 additions & 7 deletions src/builtins.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,10 @@ class CodeStubAssembler;
V(AtomicsStore, 4)

// Define list of builtins implemented in TurboFan (with CallStub linkage).
#define BUILTIN_LIST_S(V) \
V(LoadGlobalIC_Miss, BUILTIN, kNoExtraICState, LoadGlobalWithVector) \
V(LoadGlobalIC_SlowNotInsideTypeof, HANDLER, Code::LOAD_GLOBAL_IC, \
LoadGlobalWithVector) \
V(LoadGlobalIC_SlowInsideTypeof, HANDLER, Code::LOAD_GLOBAL_IC, \
LoadGlobalWithVector) \
V(LoadIC_Miss, BUILTIN, kNoExtraICState, LoadWithVector) \
#define BUILTIN_LIST_S(V) \
V(LoadGlobalIC_Miss, BUILTIN, kNoExtraICState, LoadGlobalWithVector) \
V(LoadGlobalIC_Slow, HANDLER, Code::LOAD_GLOBAL_IC, LoadGlobalWithVector) \
V(LoadIC_Miss, BUILTIN, kNoExtraICState, LoadWithVector) \
V(LoadIC_Slow, HANDLER, Code::LOAD_IC, LoadWithVector)

// Define list of builtin handlers implemented in assembly.
Expand Down
48 changes: 48 additions & 0 deletions src/ic/ic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2320,6 +2320,54 @@ RUNTIME_FUNCTION(Runtime_LoadGlobalIC_Miss) {
return *result;
}

RUNTIME_FUNCTION(Runtime_LoadGlobalIC_Slow) {
HandleScope scope(isolate);
DCHECK_EQ(2, args.length());
CONVERT_SMI_ARG_CHECKED(slot, 0);
CONVERT_ARG_HANDLE_CHECKED(TypeFeedbackVector, vector, 1);

FeedbackVectorSlot vector_slot = vector->ToSlot(slot);
DCHECK_EQ(FeedbackVectorSlotKind::LOAD_GLOBAL_IC,
vector->GetKind(vector_slot));
Handle<String> name(vector->GetName(vector_slot), isolate);
DCHECK_NE(*name, *isolate->factory()->empty_string());

Handle<JSGlobalObject> global = isolate->global_object();

Handle<ScriptContextTable> script_contexts(
global->native_context()->script_context_table());

ScriptContextTable::LookupResult lookup_result;
if (ScriptContextTable::Lookup(script_contexts, name, &lookup_result)) {
Handle<Context> script_context = ScriptContextTable::GetContext(
script_contexts, lookup_result.context_index);
Handle<Object> result =
FixedArray::get(*script_context, lookup_result.slot_index, isolate);
if (*result == *isolate->factory()->the_hole_value()) {
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewReferenceError(MessageTemplate::kNotDefined, name));
}
return *result;
}

Handle<Object> result;
bool is_found = false;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
Runtime::GetObjectProperty(isolate, global, name, &is_found));
if (!is_found) {
LoadICNexus nexus(isolate);
LoadIC ic(IC::NO_EXTRA_FRAME, isolate, &nexus);
// It is actually a LoadGlobalICs here but the predicate handles this case
// properly.
if (ic.ShouldThrowReferenceError()) {
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewReferenceError(MessageTemplate::kNotDefined, name));
}
}
return *result;
}

// Used from ic-<arch>.cc
RUNTIME_FUNCTION(Runtime_KeyedLoadIC_Miss) {
TimerEventScope<TimerEventIcMiss> timer(isolate);
Expand Down
7 changes: 1 addition & 6 deletions src/ic/ic.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,7 @@ class LoadGlobalIC : public LoadIC {

protected:
Handle<Code> slow_stub() const override {
if (LoadGlobalICState::GetTypeofMode(extra_ic_state()) ==
NOT_INSIDE_TYPEOF) {
return isolate()->builtins()->LoadGlobalIC_SlowNotInsideTypeof();
} else {
return isolate()->builtins()->LoadGlobalIC_SlowInsideTypeof();
}
return isolate()->builtins()->LoadGlobalIC_Slow();
}
};

Expand Down
66 changes: 5 additions & 61 deletions src/runtime/runtime-object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
namespace v8 {
namespace internal {

MaybeHandle<Object> Runtime::GetObjectProperty(
Isolate* isolate, Handle<Object> object, Handle<Object> key,
bool should_throw_reference_error) {
MaybeHandle<Object> Runtime::GetObjectProperty(Isolate* isolate,
Handle<Object> object,
Handle<Object> key,
bool* is_found_out) {
if (object->IsUndefined(isolate) || object->IsNull(isolate)) {
THROW_NEW_ERROR(
isolate,
Expand All @@ -31,10 +32,7 @@ MaybeHandle<Object> Runtime::GetObjectProperty(
if (!success) return MaybeHandle<Object>();

MaybeHandle<Object> result = Object::GetProperty(&it);
if (!result.is_null() && should_throw_reference_error && !it.IsFound()) {
THROW_NEW_ERROR(
isolate, NewReferenceError(MessageTemplate::kNotDefined, key), Object);
}
if (is_found_out) *is_found_out = it.IsFound();
return result;
}

Expand Down Expand Up @@ -348,60 +346,6 @@ RUNTIME_FUNCTION(Runtime_GetProperty) {
Runtime::GetObjectProperty(isolate, object, key));
}

namespace {

Object* GetGlobal(Isolate* isolate, int slot, Handle<TypeFeedbackVector> vector,
bool should_throw_reference_error) {
FeedbackVectorSlot vector_slot = vector->ToSlot(slot);
DCHECK_EQ(FeedbackVectorSlotKind::LOAD_GLOBAL_IC,
vector->GetKind(vector_slot));
Handle<String> name(vector->GetName(vector_slot), isolate);
DCHECK_NE(*name, *isolate->factory()->empty_string());

Handle<JSGlobalObject> global = isolate->global_object();

Handle<ScriptContextTable> script_contexts(
global->native_context()->script_context_table());

ScriptContextTable::LookupResult lookup_result;
if (ScriptContextTable::Lookup(script_contexts, name, &lookup_result)) {
Handle<Context> script_context = ScriptContextTable::GetContext(
script_contexts, lookup_result.context_index);
Handle<Object> result =
FixedArray::get(*script_context, lookup_result.slot_index, isolate);
if (*result == *isolate->factory()->the_hole_value()) {
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewReferenceError(MessageTemplate::kNotDefined, name));
}
return *result;
}

Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
Runtime::GetObjectProperty(isolate, global, name,
should_throw_reference_error));
return *result;
}

} // namespace

RUNTIME_FUNCTION(Runtime_GetGlobalInsideTypeof) {
HandleScope scope(isolate);
DCHECK_EQ(2, args.length());
CONVERT_SMI_ARG_CHECKED(slot, 0);
CONVERT_ARG_HANDLE_CHECKED(TypeFeedbackVector, vector, 1);
return GetGlobal(isolate, slot, vector, false);
}

RUNTIME_FUNCTION(Runtime_GetGlobalNotInsideTypeof) {
HandleScope scope(isolate);
DCHECK_EQ(2, args.length());
CONVERT_SMI_ARG_CHECKED(slot, 0);
CONVERT_ARG_HANDLE_CHECKED(TypeFeedbackVector, vector, 1);
return GetGlobal(isolate, slot, vector, true);
}

// KeyedGetProperty is called from KeyedLoadIC::GenerateGeneric.
RUNTIME_FUNCTION(Runtime_KeyedGetProperty) {
HandleScope scope(isolate);
Expand Down
5 changes: 2 additions & 3 deletions src/runtime/runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,6 @@ namespace internal {
F(SetPrototype, 2, 1) \
F(OptimizeObjectForAddingMultipleProperties, 2, 1) \
F(GetProperty, 2, 1) \
F(GetGlobalInsideTypeof, 2, 1) \
F(GetGlobalNotInsideTypeof, 2, 1) \
F(KeyedGetProperty, 2, 1) \
F(StoreGlobalViaContext_Sloppy, 2, 1) \
F(StoreGlobalViaContext_Strict, 2, 1) \
Expand Down Expand Up @@ -954,6 +952,7 @@ namespace internal {
F(KeyedStoreIC_Slow, 5, 1) \
F(LoadElementWithInterceptor, 2, 1) \
F(LoadGlobalIC_Miss, 2, 1) \
F(LoadGlobalIC_Slow, 2, 1) \
F(LoadIC_Miss, 4, 1) \
F(LoadIC_MissFromStubFailure, 4, 1) \
F(LoadPropertyWithInterceptor, 3, 1) \
Expand Down Expand Up @@ -1075,7 +1074,7 @@ class Runtime : public AllStatic {

MUST_USE_RESULT static MaybeHandle<Object> GetObjectProperty(
Isolate* isolate, Handle<Object> object, Handle<Object> key,
bool should_throw_reference_error = false);
bool* is_found_out = nullptr);

enum TypedArrayId {
// arrayIds below should be synchronized with typedarray.js natives.
Expand Down
18 changes: 16 additions & 2 deletions test/cctest/test-api-interceptors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,21 @@ THREADED_TEST(InterceptorLoadGlobalICGlobalWithInterceptor) {
v8::Local<Value> value = CompileRun(
"var f = function() { "
" try {"
" x;"
" x1;"
" } catch(e) {"
" }"
" return typeof x1 === 'undefined';"
"};"
"for (var i = 0; i < 10; i++) {"
" f();"
"};"
"f();");
CHECK_EQ(true, value->BooleanValue(context.local()).FromJust());

value = CompileRun(
"var f = function() { "
" try {"
" x2;"
" return false;"
" } catch(e) {"
" return true;"
Expand All @@ -888,7 +902,7 @@ THREADED_TEST(InterceptorLoadGlobalICGlobalWithInterceptor) {
value = CompileRun(
"var f = function() { "
" try {"
" typeof(x);"
" typeof(x3);"
" return true;"
" } catch(e) {"
" return false;"
Expand Down

0 comments on commit 426f518

Please sign in to comment.