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> {
yield_count_(0),
properties_(zone),
slot_cache_(zone),
slot_cache_inside_typeof_(zone),
dont_optimize_reason_(kNoReason),
typeof_mode_(NOT_INSIDE_TYPEOF),
catch_prediction_(HandlerTable::UNCAUGHT) {
InitializeAstVisitor(isolate);
}
......@@ -64,9 +62,7 @@ class AstNumberingVisitor final : public AstVisitor<AstNumberingVisitor> {
template <typename Node>
void ReserveFeedbackSlots(Node* node) {
node->AssignFeedbackVectorSlots(isolate_, properties_.get_spec(),
typeof_mode_ == INSIDE_TYPEOF
? &slot_cache_inside_typeof_
: &slot_cache_);
&slot_cache_);
}
BailoutReason dont_optimize_reason() const { return dont_optimize_reason_; }
......@@ -78,9 +74,7 @@ class AstNumberingVisitor final : public AstVisitor<AstNumberingVisitor> {
AstProperties properties_;
// The slot cache allows us to reuse certain feedback vector slots.
FeedbackVectorSlotCache slot_cache_;
FeedbackVectorSlotCache slot_cache_inside_typeof_;
BailoutReason dont_optimize_reason_;
TypeofMode typeof_mode_;
HandlerTable::CatchPrediction catch_prediction_;
DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
......@@ -222,13 +216,9 @@ void AstNumberingVisitor::VisitThrow(Throw* node) {
void AstNumberingVisitor::VisitUnaryOperation(UnaryOperation* node) {
Token::Value op = node->op();
TypeofMode old_typeof_mode = typeof_mode_;
IncrementNodeCount();
if (op == Token::TYPEOF) typeof_mode_ = INSIDE_TYPEOF;
node->set_base_id(ReserveIdRange(UnaryOperation::num_ids()));
Visit(node->expression());
typeof_mode_ = old_typeof_mode;
}
......
......@@ -49,29 +49,16 @@ void Builtins::Generate_LoadGlobalIC_Miss(CodeStubAssembler* assembler) {
vector);
}
namespace {
void Generate_LoadGlobalIC_Slow(CodeStubAssembler* assembler, TypeofMode mode) {
void Builtins::Generate_LoadGlobalIC_Slow(CodeStubAssembler* assembler) {
typedef compiler::Node Node;
typedef LoadGlobalWithVectorDescriptor Descriptor;
Node* slot = assembler->Parameter(Descriptor::kSlot);
Node* vector = assembler->Parameter(Descriptor::kVector);
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(
CodeStubAssembler* assembler) {
Generate_LoadGlobalIC_Slow(assembler, INSIDE_TYPEOF);
}
void Builtins::Generate_LoadGlobalIC_SlowNotInsideTypeof(
CodeStubAssembler* assembler) {
Generate_LoadGlobalIC_Slow(assembler, NOT_INSIDE_TYPEOF);
assembler->TailCallRuntime(Runtime::kLoadGlobalIC_Slow, context, slot,
vector);
}
void Builtins::Generate_LoadIC_Getter_ForDeopt(MacroAssembler* masm) {
......
This diff is collapsed.
......@@ -2311,6 +2311,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);
......
......@@ -320,12 +320,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();
}
};
......
......@@ -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,
......@@ -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;
}
......@@ -348,47 +346,6 @@ RUNTIME_FUNCTION(Runtime_GetProperty) {
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.
RUNTIME_FUNCTION(Runtime_KeyedGetProperty) {
HandleScope scope(isolate);
......
......@@ -372,7 +372,6 @@ namespace internal {
F(SetPrototype, 2, 1) \
F(OptimizeObjectForAddingMultipleProperties, 2, 1) \
F(GetProperty, 2, 1) \
F(GetGlobal, 3, 1) \
F(KeyedGetProperty, 2, 1) \
F(StoreGlobalViaContext_Sloppy, 2, 1) \
F(StoreGlobalViaContext_Strict, 2, 1) \
......@@ -941,6 +940,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) \
......@@ -1063,7 +1063,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.
......
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