Commit b558894a authored by ishell's avatar ishell Committed by Commit bot

[ic] Merge LoadGlobalIC_Slow builtins for inside typeof and outside typeof cases.

... and let the stub ask the IC whether it should throw or not when the property was not found.
This CL undoes ast-numbering changes made here: https://codereview.chromium.org/2219303002/

BUG=chromium:634467
TBR=verwaest@chromium.org

Review-Url: https://codereview.chromium.org/2220203002
Cr-Commit-Position: refs/heads/master@{#38549}
parent 685210ec
...@@ -19,9 +19,7 @@ class AstNumberingVisitor final : public AstVisitor<AstNumberingVisitor> { ...@@ -19,9 +19,7 @@ class AstNumberingVisitor final : public AstVisitor<AstNumberingVisitor> {
yield_count_(0), yield_count_(0),
properties_(zone), properties_(zone),
slot_cache_(zone), slot_cache_(zone),
slot_cache_inside_typeof_(zone),
dont_optimize_reason_(kNoReason), dont_optimize_reason_(kNoReason),
typeof_mode_(NOT_INSIDE_TYPEOF),
catch_prediction_(HandlerTable::UNCAUGHT) { catch_prediction_(HandlerTable::UNCAUGHT) {
InitializeAstVisitor(isolate); InitializeAstVisitor(isolate);
} }
...@@ -64,9 +62,7 @@ class AstNumberingVisitor final : public AstVisitor<AstNumberingVisitor> { ...@@ -64,9 +62,7 @@ class AstNumberingVisitor final : public AstVisitor<AstNumberingVisitor> {
template <typename Node> template <typename Node>
void ReserveFeedbackSlots(Node* node) { void ReserveFeedbackSlots(Node* node) {
node->AssignFeedbackVectorSlots(isolate_, properties_.get_spec(), node->AssignFeedbackVectorSlots(isolate_, properties_.get_spec(),
typeof_mode_ == INSIDE_TYPEOF &slot_cache_);
? &slot_cache_inside_typeof_
: &slot_cache_);
} }
BailoutReason dont_optimize_reason() const { return dont_optimize_reason_; } BailoutReason dont_optimize_reason() const { return dont_optimize_reason_; }
...@@ -78,9 +74,7 @@ class AstNumberingVisitor final : public AstVisitor<AstNumberingVisitor> { ...@@ -78,9 +74,7 @@ class AstNumberingVisitor final : public AstVisitor<AstNumberingVisitor> {
AstProperties properties_; AstProperties properties_;
// The slot cache allows us to reuse certain feedback vector slots. // The slot cache allows us to reuse certain feedback vector slots.
FeedbackVectorSlotCache slot_cache_; FeedbackVectorSlotCache slot_cache_;
FeedbackVectorSlotCache slot_cache_inside_typeof_;
BailoutReason dont_optimize_reason_; BailoutReason dont_optimize_reason_;
TypeofMode typeof_mode_;
HandlerTable::CatchPrediction catch_prediction_; HandlerTable::CatchPrediction catch_prediction_;
DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
...@@ -222,13 +216,9 @@ void AstNumberingVisitor::VisitThrow(Throw* node) { ...@@ -222,13 +216,9 @@ void AstNumberingVisitor::VisitThrow(Throw* node) {
void AstNumberingVisitor::VisitUnaryOperation(UnaryOperation* node) { void AstNumberingVisitor::VisitUnaryOperation(UnaryOperation* node) {
Token::Value op = node->op();
TypeofMode old_typeof_mode = typeof_mode_;
IncrementNodeCount(); IncrementNodeCount();
if (op == Token::TYPEOF) typeof_mode_ = INSIDE_TYPEOF;
node->set_base_id(ReserveIdRange(UnaryOperation::num_ids())); node->set_base_id(ReserveIdRange(UnaryOperation::num_ids()));
Visit(node->expression()); Visit(node->expression());
typeof_mode_ = old_typeof_mode;
} }
......
...@@ -49,29 +49,16 @@ void Builtins::Generate_LoadGlobalIC_Miss(CodeStubAssembler* assembler) { ...@@ -49,29 +49,16 @@ void Builtins::Generate_LoadGlobalIC_Miss(CodeStubAssembler* assembler) {
vector); vector);
} }
namespace { void Builtins::Generate_LoadGlobalIC_Slow(CodeStubAssembler* assembler) {
void Generate_LoadGlobalIC_Slow(CodeStubAssembler* assembler, TypeofMode mode) {
typedef compiler::Node Node; typedef compiler::Node Node;
typedef LoadGlobalWithVectorDescriptor Descriptor; typedef LoadGlobalWithVectorDescriptor Descriptor;
Node* slot = assembler->Parameter(Descriptor::kSlot); Node* slot = assembler->Parameter(Descriptor::kSlot);
Node* vector = assembler->Parameter(Descriptor::kVector); Node* vector = assembler->Parameter(Descriptor::kVector);
Node* context = assembler->Parameter(Descriptor::kContext); Node* context = assembler->Parameter(Descriptor::kContext);
Node* typeof_mode = assembler->SmiConstant(Smi::FromInt(mode));
assembler->TailCallRuntime(Runtime::kGetGlobal, context, slot, vector,
typeof_mode);
}
} // anonymous namespace
void Builtins::Generate_LoadGlobalIC_SlowInsideTypeof( assembler->TailCallRuntime(Runtime::kLoadGlobalIC_Slow, context, slot,
CodeStubAssembler* assembler) { vector);
Generate_LoadGlobalIC_Slow(assembler, INSIDE_TYPEOF);
}
void Builtins::Generate_LoadGlobalIC_SlowNotInsideTypeof(
CodeStubAssembler* assembler) {
Generate_LoadGlobalIC_Slow(assembler, NOT_INSIDE_TYPEOF);
} }
void Builtins::Generate_LoadIC_Getter_ForDeopt(MacroAssembler* masm) { void Builtins::Generate_LoadIC_Getter_ForDeopt(MacroAssembler* masm) {
......
...@@ -59,10 +59,7 @@ namespace internal { ...@@ -59,10 +59,7 @@ namespace internal {
ASM(KeyedStoreIC_Miss) \ ASM(KeyedStoreIC_Miss) \
ASH(KeyedStoreIC_Slow, HANDLER, Code::KEYED_STORE_IC) \ ASH(KeyedStoreIC_Slow, HANDLER, Code::KEYED_STORE_IC) \
TFS(LoadGlobalIC_Miss, BUILTIN, kNoExtraICState, LoadGlobalWithVector) \ TFS(LoadGlobalIC_Miss, BUILTIN, kNoExtraICState, LoadGlobalWithVector) \
TFS(LoadGlobalIC_SlowInsideTypeof, HANDLER, Code::LOAD_GLOBAL_IC, \ TFS(LoadGlobalIC_Slow, HANDLER, Code::LOAD_GLOBAL_IC, LoadGlobalWithVector) \
LoadGlobalWithVector) \
TFS(LoadGlobalIC_SlowNotInsideTypeof, HANDLER, Code::LOAD_GLOBAL_IC, \
LoadGlobalWithVector) \
ASH(LoadIC_Getter_ForDeopt, LOAD_IC, kNoExtraICState) \ ASH(LoadIC_Getter_ForDeopt, LOAD_IC, kNoExtraICState) \
TFS(LoadIC_Miss, BUILTIN, kNoExtraICState, LoadWithVector) \ TFS(LoadIC_Miss, BUILTIN, kNoExtraICState, LoadWithVector) \
ASH(LoadIC_Normal, HANDLER, Code::LOAD_IC) \ ASH(LoadIC_Normal, HANDLER, Code::LOAD_IC) \
......
...@@ -2311,6 +2311,54 @@ RUNTIME_FUNCTION(Runtime_LoadGlobalIC_Miss) { ...@@ -2311,6 +2311,54 @@ RUNTIME_FUNCTION(Runtime_LoadGlobalIC_Miss) {
return *result; 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 // Used from ic-<arch>.cc
RUNTIME_FUNCTION(Runtime_KeyedLoadIC_Miss) { RUNTIME_FUNCTION(Runtime_KeyedLoadIC_Miss) {
TimerEventScope<TimerEventIcMiss> timer(isolate); TimerEventScope<TimerEventIcMiss> timer(isolate);
......
...@@ -320,12 +320,7 @@ class LoadGlobalIC : public LoadIC { ...@@ -320,12 +320,7 @@ class LoadGlobalIC : public LoadIC {
protected: protected:
Handle<Code> slow_stub() const override { Handle<Code> slow_stub() const override {
if (LoadGlobalICState::GetTypeofMode(extra_ic_state()) == return isolate()->builtins()->LoadGlobalIC_Slow();
NOT_INSIDE_TYPEOF) {
return isolate()->builtins()->LoadGlobalIC_SlowNotInsideTypeof();
} else {
return isolate()->builtins()->LoadGlobalIC_SlowInsideTypeof();
}
} }
}; };
......
...@@ -15,9 +15,10 @@ ...@@ -15,9 +15,10 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
MaybeHandle<Object> Runtime::GetObjectProperty( MaybeHandle<Object> Runtime::GetObjectProperty(Isolate* isolate,
Isolate* isolate, Handle<Object> object, Handle<Object> key, Handle<Object> object,
bool should_throw_reference_error) { Handle<Object> key,
bool* is_found_out) {
if (object->IsUndefined(isolate) || object->IsNull(isolate)) { if (object->IsUndefined(isolate) || object->IsNull(isolate)) {
THROW_NEW_ERROR( THROW_NEW_ERROR(
isolate, isolate,
...@@ -31,10 +32,7 @@ MaybeHandle<Object> Runtime::GetObjectProperty( ...@@ -31,10 +32,7 @@ MaybeHandle<Object> Runtime::GetObjectProperty(
if (!success) return MaybeHandle<Object>(); if (!success) return MaybeHandle<Object>();
MaybeHandle<Object> result = Object::GetProperty(&it); MaybeHandle<Object> result = Object::GetProperty(&it);
if (!result.is_null() && should_throw_reference_error && !it.IsFound()) { if (is_found_out) *is_found_out = it.IsFound();
THROW_NEW_ERROR(
isolate, NewReferenceError(MessageTemplate::kNotDefined, key), Object);
}
return result; return result;
} }
...@@ -348,47 +346,6 @@ RUNTIME_FUNCTION(Runtime_GetProperty) { ...@@ -348,47 +346,6 @@ RUNTIME_FUNCTION(Runtime_GetProperty) {
Runtime::GetObjectProperty(isolate, object, key)); Runtime::GetObjectProperty(isolate, object, key));
} }
RUNTIME_FUNCTION(Runtime_GetGlobal) {
HandleScope scope(isolate);
DCHECK_EQ(3, args.length());
CONVERT_SMI_ARG_CHECKED(slot, 0);
CONVERT_ARG_HANDLE_CHECKED(TypeFeedbackVector, vector, 1);
CONVERT_SMI_ARG_CHECKED(typeof_mode_value, 2);
TypeofMode typeof_mode = static_cast<TypeofMode>(typeof_mode_value);
bool should_throw_reference_error = typeof_mode == NOT_INSIDE_TYPEOF;
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;
}
// KeyedGetProperty is called from KeyedLoadIC::GenerateGeneric. // KeyedGetProperty is called from KeyedLoadIC::GenerateGeneric.
RUNTIME_FUNCTION(Runtime_KeyedGetProperty) { RUNTIME_FUNCTION(Runtime_KeyedGetProperty) {
HandleScope scope(isolate); HandleScope scope(isolate);
......
...@@ -372,7 +372,6 @@ namespace internal { ...@@ -372,7 +372,6 @@ namespace internal {
F(SetPrototype, 2, 1) \ F(SetPrototype, 2, 1) \
F(OptimizeObjectForAddingMultipleProperties, 2, 1) \ F(OptimizeObjectForAddingMultipleProperties, 2, 1) \
F(GetProperty, 2, 1) \ F(GetProperty, 2, 1) \
F(GetGlobal, 3, 1) \
F(KeyedGetProperty, 2, 1) \ F(KeyedGetProperty, 2, 1) \
F(StoreGlobalViaContext_Sloppy, 2, 1) \ F(StoreGlobalViaContext_Sloppy, 2, 1) \
F(StoreGlobalViaContext_Strict, 2, 1) \ F(StoreGlobalViaContext_Strict, 2, 1) \
...@@ -941,6 +940,7 @@ namespace internal { ...@@ -941,6 +940,7 @@ namespace internal {
F(KeyedStoreIC_Slow, 5, 1) \ F(KeyedStoreIC_Slow, 5, 1) \
F(LoadElementWithInterceptor, 2, 1) \ F(LoadElementWithInterceptor, 2, 1) \
F(LoadGlobalIC_Miss, 2, 1) \ F(LoadGlobalIC_Miss, 2, 1) \
F(LoadGlobalIC_Slow, 2, 1) \
F(LoadIC_Miss, 4, 1) \ F(LoadIC_Miss, 4, 1) \
F(LoadIC_MissFromStubFailure, 4, 1) \ F(LoadIC_MissFromStubFailure, 4, 1) \
F(LoadPropertyWithInterceptor, 3, 1) \ F(LoadPropertyWithInterceptor, 3, 1) \
...@@ -1063,7 +1063,7 @@ class Runtime : public AllStatic { ...@@ -1063,7 +1063,7 @@ class Runtime : public AllStatic {
MUST_USE_RESULT static MaybeHandle<Object> GetObjectProperty( MUST_USE_RESULT static MaybeHandle<Object> GetObjectProperty(
Isolate* isolate, Handle<Object> object, Handle<Object> key, Isolate* isolate, Handle<Object> object, Handle<Object> key,
bool should_throw_reference_error = false); bool* is_found_out = nullptr);
enum TypedArrayId { enum TypedArrayId {
// arrayIds below should be synchronized with typedarray.js natives. // arrayIds below should be synchronized with typedarray.js natives.
......
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