// Update the static counter each time a new code stub is generated.
isolate()->counters()->code_stubs()->Increment();
- CodeStubInterfaceDescriptor* descriptor = GetInterfaceDescriptor();
- int param_count = descriptor->GetEnvironmentParameterCount();
+ CodeStubInterfaceDescriptor descriptor;
+ InitializeInterfaceDescriptor(&descriptor);
+ int param_count = descriptor.GetEnvironmentParameterCount();
{
// Call the runtime system in a fresh internal frame.
FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
DCHECK(param_count == 0 ||
- r0.is(descriptor->GetEnvironmentParameterRegister(
- param_count - 1)));
+ r0.is(descriptor.GetEnvironmentParameterRegister(param_count - 1)));
// Push arguments
for (int i = 0; i < param_count; ++i) {
- __ push(descriptor->GetEnvironmentParameterRegister(i));
+ __ push(descriptor.GetEnvironmentParameterRegister(i));
}
- ExternalReference miss = descriptor->miss_handler();
+ ExternalReference miss = descriptor.miss_handler();
__ CallExternalReference(miss, param_count);
}
return DefineAsSpilled(result, spill_index);
} else {
DCHECK(info()->IsStub());
- CodeStubInterfaceDescriptor* descriptor =
- info()->code_stub()->GetInterfaceDescriptor();
+ CodeStubInterfaceDescriptor descriptor;
+ info()->code_stub()->InitializeInterfaceDescriptor(&descriptor);
int index = static_cast<int>(instr->index());
- Register reg = descriptor->GetEnvironmentParameterRegister(index);
+ Register reg = descriptor.GetEnvironmentParameterRegister(index);
return DefineFixed(result, reg);
}
}
// Update the static counter each time a new code stub is generated.
isolate()->counters()->code_stubs()->Increment();
- CodeStubInterfaceDescriptor* descriptor = GetInterfaceDescriptor();
- int param_count = descriptor->GetEnvironmentParameterCount();
+ CodeStubInterfaceDescriptor descriptor;
+ InitializeInterfaceDescriptor(&descriptor);
+ int param_count = descriptor.GetEnvironmentParameterCount();
{
// Call the runtime system in a fresh internal frame.
FrameScope scope(masm, StackFrame::INTERNAL);
DCHECK((param_count == 0) ||
- x0.Is(descriptor->GetEnvironmentParameterRegister(param_count - 1)));
+ x0.Is(descriptor.GetEnvironmentParameterRegister(param_count - 1)));
// Push arguments
MacroAssembler::PushPopQueue queue(masm);
for (int i = 0; i < param_count; ++i) {
- queue.Queue(descriptor->GetEnvironmentParameterRegister(i));
+ queue.Queue(descriptor.GetEnvironmentParameterRegister(i));
}
queue.PushQueued();
- ExternalReference miss = descriptor->miss_handler();
+ ExternalReference miss = descriptor.miss_handler();
__ CallExternalReference(miss, param_count);
}
arguments_length_(NULL),
info_(stub, isolate),
context_(NULL) {
- descriptor_ = stub->GetInterfaceDescriptor();
- int parameter_count = descriptor_->GetEnvironmentParameterCount();
+ stub->InitializeInterfaceDescriptor(&descriptor_);
+ int parameter_count = descriptor_.GetEnvironmentParameterCount();
parameters_.Reset(new HParameter*[parameter_count]);
}
virtual bool BuildGraph();
protected:
virtual HValue* BuildCodeStub() = 0;
HParameter* GetParameter(int parameter) {
- DCHECK(parameter < descriptor_->GetEnvironmentParameterCount());
+ DCHECK(parameter < descriptor_.GetEnvironmentParameterCount());
return parameters_[parameter];
}
HValue* GetArgumentsLength() {
SmartArrayPointer<HParameter*> parameters_;
HValue* arguments_length_;
CompilationInfoWithZone info_;
- CodeStubInterfaceDescriptor* descriptor_;
+ CodeStubInterfaceDescriptor descriptor_;
HContext* context_;
};
isolate()->GetHTracer()->TraceCompilation(&info_);
}
- int param_count = descriptor_->GetEnvironmentParameterCount();
+ int param_count = descriptor_.GetEnvironmentParameterCount();
HEnvironment* start_environment = graph()->start_environment();
HBasicBlock* next_block = CreateBasicBlock(start_environment);
Goto(next_block);
next_block->SetJoinId(BailoutId::StubEntry());
set_current_block(next_block);
- bool runtime_stack_params = descriptor_->stack_parameter_count().is_valid();
+ bool runtime_stack_params = descriptor_.stack_parameter_count().is_valid();
HInstruction* stack_parameter_count = NULL;
for (int i = 0; i < param_count; ++i) {
- Representation r = descriptor_->GetEnvironmentParameterRepresentation(i);
+ Representation r = descriptor_.GetEnvironmentParameterRepresentation(i);
HParameter* param = Add<HParameter>(i,
HParameter::REGISTER_PARAMETER, r);
start_environment->Bind(i, param);
parameters_[i] = param;
- if (descriptor_->IsEnvironmentParameterCountRegister(i)) {
+ if (descriptor_.IsEnvironmentParameterCountRegister(i)) {
param->set_type(HType::Smi());
stack_parameter_count = param;
arguments_length_ = stack_parameter_count;
// We might have extra expressions to pop from the stack in addition to the
// arguments above.
HInstruction* stack_pop_count = stack_parameter_count;
- if (descriptor_->function_mode() == JS_FUNCTION_STUB_MODE) {
+ if (descriptor_.function_mode() == JS_FUNCTION_STUB_MODE) {
if (!stack_parameter_count->IsConstant() &&
- descriptor_->hint_stack_parameter_count() < 0) {
+ descriptor_.hint_stack_parameter_count() < 0) {
HInstruction* constant_one = graph()->GetConstant1();
stack_pop_count = AddUncasted<HAdd>(stack_parameter_count, constant_one);
stack_pop_count->ClearFlag(HValue::kCanOverflow);
// TODO(mvstanton): verify that stack_parameter_count+1 really fits in a
// smi.
} else {
- int count = descriptor_->hint_stack_parameter_count();
+ int count = descriptor_.hint_stack_parameter_count();
stack_pop_count = Add<HConstant>(count);
}
}
template <class Stub>
static Handle<Code> DoGenerateCode(Stub* stub) {
Isolate* isolate = stub->isolate();
- CodeStub::Major major_key = static_cast<CodeStub*>(stub)->MajorKey();
- CodeStubInterfaceDescriptor* descriptor =
- isolate->code_stub_interface_descriptor(major_key);
- if (!descriptor->IsInitialized()) {
- stub->InitializeInterfaceDescriptor(descriptor);
- }
+ CodeStubInterfaceDescriptor descriptor;
+ stub->InitializeInterfaceDescriptor(&descriptor);
// If we are uninitialized we can use a light-weight stub to enter
// the runtime that is significantly faster than using the standard
// stub-failure deopt mechanism.
- if (stub->IsUninitialized() && descriptor->has_miss_handler()) {
- DCHECK(!descriptor->stack_parameter_count().is_valid());
+ if (stub->IsUninitialized() && descriptor.has_miss_handler()) {
+ DCHECK(!descriptor.stack_parameter_count().is_valid());
return stub->GenerateLightweightMissCode();
}
base::ElapsedTimer timer;
#define DEF_CASE(name) case name: return #name "Stub";
CODE_STUB_LIST(DEF_CASE)
#undef DEF_CASE
- case UninitializedMajorKey: return "<UninitializedMajorKey>Stub";
case NoCache:
return "<NoCache>Stub";
- default:
- if (!allow_unknown_keys) {
- UNREACHABLE();
- }
+ case NUMBER_OF_IDS:
+ UNREACHABLE();
return NULL;
}
+ return NULL;
}
}
+void CodeStub::Dispatch(Isolate* isolate, uint32_t key, void** value_out,
+ DispatchedCall call) {
+ switch (MajorKeyFromKey(key)) {
+#define DEF_CASE(NAME) \
+ case NAME: { \
+ NAME##Stub stub(key, isolate); \
+ CodeStub* pstub = &stub; \
+ call(pstub, value_out); \
+ break; \
+ }
+ CODE_STUB_LIST(DEF_CASE)
+#undef DEF_CASE
+ case NUMBER_OF_IDS:
+ UNREACHABLE();
+ case NoCache:
+ *value_out = NULL;
+ break;
+ }
+}
+
+
+static void GetInterfaceDescriptorDispatchedCall(CodeStub* stub,
+ void** value_out) {
+ CodeStubInterfaceDescriptor* descriptor_out =
+ reinterpret_cast<CodeStubInterfaceDescriptor*>(value_out);
+ stub->InitializeInterfaceDescriptor(descriptor_out);
+}
+
+
+void CodeStub::InitializeInterfaceDescriptor(
+ Isolate* isolate, uint32_t key, CodeStubInterfaceDescriptor* desc) {
+ void** value_out = reinterpret_cast<void**>(desc);
+ Dispatch(isolate, key, value_out, &GetInterfaceDescriptorDispatchedCall);
+}
+
+
// static
void BinaryOpICStub::GenerateAheadOfTime(Isolate* isolate) {
// Generate the uninitialized versions of the stub.
}
-static void InstallDescriptor(Isolate* isolate, HydrogenCodeStub* stub) {
- int major_key = stub->MajorKey();
- CodeStubInterfaceDescriptor* descriptor =
- isolate->code_stub_interface_descriptor(major_key);
- if (!descriptor->IsInitialized()) {
- stub->InitializeInterfaceDescriptor(descriptor);
- }
-}
-
-
-void ArrayConstructorStubBase::InstallDescriptors(Isolate* isolate) {
- ArrayNoArgumentConstructorStub stub1(isolate, GetInitialFastElementsKind());
- InstallDescriptor(isolate, &stub1);
- ArraySingleArgumentConstructorStub stub2(isolate,
- GetInitialFastElementsKind());
- InstallDescriptor(isolate, &stub2);
- ArrayNArgumentsConstructorStub stub3(isolate, GetInitialFastElementsKind());
- InstallDescriptor(isolate, &stub3);
-}
-
-
-void NumberToStringStub::InstallDescriptors(Isolate* isolate) {
- NumberToStringStub stub(isolate);
- InstallDescriptor(isolate, &stub);
-}
-
-
-void FastNewClosureStub::InstallDescriptors(Isolate* isolate) {
- FastNewClosureStub stub(isolate, STRICT, false);
- InstallDescriptor(isolate, &stub);
-}
-
-
-void FastNewContextStub::InstallDescriptors(Isolate* isolate) {
- FastNewContextStub stub(isolate, FastNewContextStub::kMaximumSlots);
- InstallDescriptor(isolate, &stub);
-}
-
-
-// static
-void FastCloneShallowArrayStub::InstallDescriptors(Isolate* isolate) {
- FastCloneShallowArrayStub stub(isolate, DONT_TRACK_ALLOCATION_SITE);
- InstallDescriptor(isolate, &stub);
-}
-
-
-// static
-void BinaryOpICStub::InstallDescriptors(Isolate* isolate) {
- BinaryOpICStub stub(isolate, Token::ADD, NO_OVERWRITE);
- InstallDescriptor(isolate, &stub);
-}
-
-
-// static
-void BinaryOpWithAllocationSiteStub::InstallDescriptors(Isolate* isolate) {
- BinaryOpWithAllocationSiteStub stub(isolate, Token::ADD, NO_OVERWRITE);
- InstallDescriptor(isolate, &stub);
-}
-
-
-// static
-void StringAddStub::InstallDescriptors(Isolate* isolate) {
- StringAddStub stub(isolate, STRING_ADD_CHECK_NONE, NOT_TENURED);
- InstallDescriptor(isolate, &stub);
-}
-
-
-// static
-void RegExpConstructResultStub::InstallDescriptors(Isolate* isolate) {
- RegExpConstructResultStub stub(isolate);
- InstallDescriptor(isolate, &stub);
-}
-
-
-// static
-void KeyedLoadGenericStub::InstallDescriptors(Isolate* isolate) {
- KeyedLoadGenericStub stub(isolate);
- InstallDescriptor(isolate, &stub);
-}
-
-
-// static
-void StoreFieldStub::InstallDescriptors(Isolate* isolate) {
- StoreFieldStub stub(isolate, FieldIndex::ForInObjectOffset(0),
- Representation::None());
- InstallDescriptor(isolate, &stub);
-}
-
-
-// static
-void LoadFastElementStub::InstallDescriptors(Isolate* isolate) {
- LoadFastElementStub stub(isolate, true, FAST_ELEMENTS);
- InstallDescriptor(isolate, &stub);
-}
-
-
ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate)
: PlatformCodeStub(isolate) {
minor_key_ = ArgumentCountBits::encode(ANY);
}
-void InternalArrayConstructorStubBase::InstallDescriptors(Isolate* isolate) {
- InternalArrayNoArgumentConstructorStub stub1(isolate, FAST_ELEMENTS);
- InstallDescriptor(isolate, &stub1);
- InternalArraySingleArgumentConstructorStub stub2(isolate, FAST_ELEMENTS);
- InstallDescriptor(isolate, &stub2);
- InternalArrayNArgumentsConstructorStub stub3(isolate, FAST_ELEMENTS);
- InstallDescriptor(isolate, &stub3);
-}
-
InternalArrayConstructorStub::InternalArrayConstructorStub(
Isolate* isolate) : PlatformCodeStub(isolate) {
InternalArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate);
class CodeStub BASE_EMBEDDED {
public:
enum Major {
- UninitializedMajorKey = 0,
#define DEF_ENUM(name) name,
CODE_STUB_LIST(DEF_ENUM)
#undef DEF_ENUM
// Lookup the code in the (possibly custom) cache.
bool FindCodeInCache(Code** code_out);
+ virtual void InitializeInterfaceDescriptor(
+ CodeStubInterfaceDescriptor* descriptor) {}
+
+ static void InitializeInterfaceDescriptor(Isolate* isolate, uint32_t key,
+ CodeStubInterfaceDescriptor* desc);
+
// Returns information for computing the number key.
virtual Major MajorKey() const = 0;
uint32_t MinorKey() const { return minor_key_; }
// If a stub uses a special cache override this.
virtual bool UseSpecialCache() { return false; }
+ // We use this dispatch to statically instantiate the correct code stub for
+ // the given stub key and call the passed function with that code stub.
+ typedef void (*DispatchedCall)(CodeStub* stub, void** value_out);
+ static void Dispatch(Isolate* isolate, uint32_t key, void** value_out,
+ DispatchedCall call);
+
STATIC_ASSERT(NUMBER_OF_IDS < (1 << kStubMajorKeyBits));
class MajorKeyBits: public BitField<uint32_t, 0, kStubMajorKeyBits> {};
class MinorKeyBits: public BitField<uint32_t,
virtual Code::Kind GetCodeKind() const { return Code::STUB; }
- CodeStubInterfaceDescriptor* GetInterfaceDescriptor() {
- return isolate()->code_stub_interface_descriptor(MajorKey());
- }
-
template<class SubClass>
static Handle<Code> GetUninitialized(Isolate* isolate) {
SubClass::GenerateAheadOfTime(isolate);
return SubClass().GetCode(isolate);
}
- virtual void InitializeInterfaceDescriptor(
- CodeStubInterfaceDescriptor* descriptor) = 0;
-
// Retrieve the code for the stub. Generate the code if needed.
virtual Handle<Code> GenerateCode() = 0;
public:
explicit ToNumberStub(Isolate* isolate) : HydrogenCodeStub(isolate) { }
- static void InstallDescriptors(Isolate* isolate) {
- ToNumberStub stub(isolate);
- stub.InitializeInterfaceDescriptor(
- isolate->code_stub_interface_descriptor(CodeStub::ToNumber));
- }
-
DEFINE_HYDROGEN_CODE_STUB(ToNumber, HydrogenCodeStub);
};
public:
explicit NumberToStringStub(Isolate* isolate) : HydrogenCodeStub(isolate) {}
- static void InstallDescriptors(Isolate* isolate);
-
// Parameters accessed via CodeStubGraphBuilder::GetParameter()
static const int kNumber = 0;
IsGeneratorBits::encode(is_generator));
}
- static void InstallDescriptors(Isolate* isolate);
-
StrictMode strict_mode() const {
return StrictModeBits::decode(sub_minor_key());
}
set_sub_minor_key(SlotsBits::encode(slots));
}
- static void InstallDescriptors(Isolate* isolate);
-
int slots() const { return SlotsBits::decode(sub_minor_key()); }
// Parameters accessed via CodeStubGraphBuilder::GetParameter()
return AllocationSiteModeBits::decode(sub_minor_key());
}
- static void InstallDescriptors(Isolate* isolate);
-
private:
class AllocationSiteModeBits: public BitField<AllocationSiteMode, 0, 1> {};
return PropertyDetails::DecodeRepresentation(repr);
}
- static void InstallDescriptors(Isolate* isolate);
-
protected:
virtual Code::Kind kind() const { return Code::STORE_IC; }
virtual Code::StubType GetStubType() { return Code::FAST; }
static void GenerateAheadOfTime(Isolate* isolate);
- static void InstallDescriptors(Isolate* isolate);
-
virtual Code::Kind GetCodeKind() const OVERRIDE {
return Code::BINARY_OP_IC;
}
const BinaryOpIC::State& state)
: BinaryOpICStub(isolate, state) {}
- static void InstallDescriptors(Isolate* isolate);
-
virtual Code::Kind GetCodeKind() const FINAL OVERRIDE {
return Code::STUB;
}
return PretenureFlagBits::decode(sub_minor_key());
}
- static void InstallDescriptors(Isolate* isolate);
-
// Parameters accessed via CodeStubGraphBuilder::GetParameter()
static const int kLeft = 0;
static const int kRight = 1;
return CompareNilICStub(isolate, nil, UNINITIALIZED).GetCode();
}
- static void InstallDescriptors(Isolate* isolate) {
- CompareNilICStub compare_stub(isolate, kNullValue, UNINITIALIZED);
- compare_stub.InitializeInterfaceDescriptor(
- isolate->code_stub_interface_descriptor(CodeStub::CompareNilIC));
- }
-
virtual InlineCacheState GetICState() const {
State state = this->state();
if (state.Contains(GENERIC)) {
explicit RegExpConstructResultStub(Isolate* isolate)
: HydrogenCodeStub(isolate) { }
- static void InstallDescriptors(Isolate* isolate);
-
// Parameters accessed via CodeStubGraphBuilder::GetParameter()
static const int kLength = 0;
static const int kIndex = 1;
public:
explicit KeyedLoadGenericStub(Isolate* isolate) : HydrogenCodeStub(isolate) {}
- static void InstallDescriptors(Isolate* isolate);
-
virtual Code::Kind GetCodeKind() const { return Code::KEYED_LOAD_IC; }
virtual InlineCacheState GetICState() const { return GENERIC; }
set_sub_minor_key(state.GetExtraICState());
}
- static void InstallDescriptors(Isolate* isolate);
-
virtual Code::Kind GetCodeKind() const OVERRIDE { return Code::LOAD_IC; }
virtual InlineCacheState GetICState() const FINAL OVERRIDE {
explicit VectorKeyedLoadStub(Isolate* isolate)
: VectorLoadStub(isolate, LoadIC::State(0)) {}
- static void InstallDescriptors(Isolate* isolate);
-
virtual Code::Kind GetCodeKind() const OVERRIDE {
return Code::KEYED_LOAD_IC;
}
return ElementsKindBits::decode(sub_minor_key());
}
- static void InstallDescriptors(Isolate* isolate);
-
private:
class ElementsKindBits: public BitField<ElementsKind, 0, 8> {};
class IsJSArrayBits: public BitField<bool, 8, 1> {};
}
static void GenerateStubsAheadOfTime(Isolate* isolate);
- static void InstallDescriptors(Isolate* isolate);
// Parameters accessed via CodeStubGraphBuilder::GetParameter()
static const int kConstructor = 0;
}
static void GenerateStubsAheadOfTime(Isolate* isolate);
- static void InstallDescriptors(Isolate* isolate);
// Parameters accessed via CodeStubGraphBuilder::GetParameter()
static const int kConstructor = 0;
virtual bool SometimesSetsUpAFrame() { return false; }
- static void InstallDescriptors(Isolate* isolate) {
- ToBooleanStub stub(isolate, RESULT_AS_SMI);
- stub.InitializeInterfaceDescriptor(
- isolate->code_stub_interface_descriptor(CodeStub::ToBoolean));
- }
-
static Handle<Code> GetUninitialized(Isolate* isolate) {
return ToBooleanStub(isolate, UNINITIALIZED).GetCode();
}
namespace compiler {
-// TODO(mstarzinger): This is a temporary workaround for non-hydrogen stubs for
-// which we don't have an interface descriptor yet. Use ReplaceWithStubCall
-// once these stub have been made into a HydrogenCodeStub.
-template <typename T>
-static CodeStubInterfaceDescriptor* GetInterfaceDescriptor(Isolate* isolate,
- T* stub) {
- CodeStub::Major key = static_cast<CodeStub*>(stub)->MajorKey();
- CodeStubInterfaceDescriptor* d = isolate->code_stub_interface_descriptor(key);
- stub->InitializeInterfaceDescriptor(d);
- return d;
-}
-
-
// TODO(mstarzinger): This is a temporary shim to be able to call an IC stub
// which doesn't have an interface descriptor yet. It mimics a hydrogen code
// stub for the underlying IC stub code.
class LoadICStubShim : public HydrogenCodeStub {
public:
LoadICStubShim(Isolate* isolate, ContextualMode contextual_mode)
- : HydrogenCodeStub(isolate), contextual_mode_(contextual_mode) {
- i::compiler::GetInterfaceDescriptor(isolate, this);
- }
+ : HydrogenCodeStub(isolate), contextual_mode_(contextual_mode) {}
virtual Handle<Code> GenerateCode() OVERRIDE {
ExtraICState extra_state = LoadIC::ComputeExtraICState(contextual_mode_);
// stub for the underlying IC stub code.
class KeyedLoadICStubShim : public HydrogenCodeStub {
public:
- explicit KeyedLoadICStubShim(Isolate* isolate) : HydrogenCodeStub(isolate) {
- i::compiler::GetInterfaceDescriptor(isolate, this);
- }
+ explicit KeyedLoadICStubShim(Isolate* isolate) : HydrogenCodeStub(isolate) {}
virtual Handle<Code> GenerateCode() OVERRIDE {
return isolate()->builtins()->KeyedLoadIC_Initialize();
class StoreICStubShim : public HydrogenCodeStub {
public:
StoreICStubShim(Isolate* isolate, StrictMode strict_mode)
- : HydrogenCodeStub(isolate), strict_mode_(strict_mode) {
- i::compiler::GetInterfaceDescriptor(isolate, this);
- }
+ : HydrogenCodeStub(isolate), strict_mode_(strict_mode) {}
virtual Handle<Code> GenerateCode() OVERRIDE {
return StoreIC::initialize_stub(isolate(), strict_mode_);
class KeyedStoreICStubShim : public HydrogenCodeStub {
public:
KeyedStoreICStubShim(Isolate* isolate, StrictMode strict_mode)
- : HydrogenCodeStub(isolate), strict_mode_(strict_mode) {
- i::compiler::GetInterfaceDescriptor(isolate, this);
- }
+ : HydrogenCodeStub(isolate), strict_mode_(strict_mode) {}
virtual Handle<Code> GenerateCode() OVERRIDE {
return strict_mode_ == SLOPPY
void JSGenericLowering::ReplaceWithCompareIC(Node* node, Token::Value token,
bool pure) {
BinaryOpICStub stub(isolate(), Token::ADD); // TODO(mstarzinger): Hack.
- CodeStubInterfaceDescriptor* d = stub.GetInterfaceDescriptor();
+ CodeStubInterfaceDescriptor d;
+ stub.InitializeInterfaceDescriptor(&d);
bool has_frame_state = OperatorProperties::HasFrameStateInput(node->op());
CallDescriptor* desc_compare = linkage()->GetStubCallDescriptor(
- d, 0, CallDescriptor::kPatchableCallSiteWithNop | FlagsForNode(node));
+ &d, 0, CallDescriptor::kPatchableCallSiteWithNop | FlagsForNode(node));
Handle<Code> ic = CompareIC::GetUninitialized(isolate(), token);
NodeVector inputs(zone());
inputs.reserve(node->InputCount() + 1);
void JSGenericLowering::ReplaceWithStubCall(Node* node, HydrogenCodeStub* stub,
CallDescriptor::Flags flags) {
- CodeStubInterfaceDescriptor* d = stub->GetInterfaceDescriptor();
+ CodeStubInterfaceDescriptor d;
+ stub->InitializeInterfaceDescriptor(&d);
CallDescriptor* desc =
- linkage()->GetStubCallDescriptor(d, 0, flags | FlagsForNode(node));
+ linkage()->GetStubCallDescriptor(&d, 0, flags | FlagsForNode(node));
Node* stub_code = CodeConstant(stub->GetCode());
PatchInsertInput(node, 0, stub_code);
PatchOperator(node, common()->Call(desc));
Builtins::JavaScript id,
int nargs) {
CallFunctionStub stub(isolate(), nargs - 1, NO_CALL_FUNCTION_FLAGS);
- CodeStubInterfaceDescriptor* d = GetInterfaceDescriptor(isolate(), &stub);
- CallDescriptor* desc = linkage()->GetStubCallDescriptor(d, nargs);
+ CodeStubInterfaceDescriptor d;
+ stub.InitializeInterfaceDescriptor(&d);
+ CallDescriptor* desc = linkage()->GetStubCallDescriptor(&d, nargs);
// TODO(mstarzinger): Accessing the builtins object this way prevents sharing
// of code across native contexts. Fix this by loading from given context.
Handle<JSFunction> function(
InstanceofStub::kReturnTrueFalseObject |
InstanceofStub::kArgsInRegisters);
InstanceofStub stub(isolate(), flags);
- CodeStubInterfaceDescriptor* d = GetInterfaceDescriptor(isolate(), &stub);
- CallDescriptor* desc = linkage()->GetStubCallDescriptor(d, 0);
+ CodeStubInterfaceDescriptor d;
+ stub.InitializeInterfaceDescriptor(&d);
+ CallDescriptor* desc = linkage()->GetStubCallDescriptor(&d, 0);
Node* stub_code = CodeConstant(stub.GetCode());
PatchInsertInput(node, 0, stub_code);
PatchOperator(node, common()->Call(desc));
Node* JSGenericLowering::LowerJSCallConstruct(Node* node) {
int arity = OpParameter<int>(node);
CallConstructStub stub(isolate(), NO_CALL_CONSTRUCTOR_FLAGS);
- CodeStubInterfaceDescriptor* d = GetInterfaceDescriptor(isolate(), &stub);
+ CodeStubInterfaceDescriptor d;
+ stub.InitializeInterfaceDescriptor(&d);
CallDescriptor* desc =
- linkage()->GetStubCallDescriptor(d, arity, FlagsForNode(node));
+ linkage()->GetStubCallDescriptor(&d, arity, FlagsForNode(node));
Node* stub_code = CodeConstant(stub.GetCode());
Node* construct = NodeProperties::GetValueInput(node, 0);
PatchInsertInput(node, 0, stub_code);
Node* JSGenericLowering::LowerJSCallFunction(Node* node) {
CallParameters p = OpParameter<CallParameters>(node);
CallFunctionStub stub(isolate(), p.arity - 2, p.flags);
- CodeStubInterfaceDescriptor* d = GetInterfaceDescriptor(isolate(), &stub);
+ CodeStubInterfaceDescriptor d;
+ stub.InitializeInterfaceDescriptor(&d);
CallDescriptor* desc =
- linkage()->GetStubCallDescriptor(d, p.arity - 1, FlagsForNode(node));
+ linkage()->GetStubCallDescriptor(&d, p.arity - 1, FlagsForNode(node));
Node* stub_code = CodeConstant(stub.GetCode());
PatchInsertInput(node, 0, stub_code);
PatchOperator(node, common()->Call(desc));
} else if (info->code_stub() != NULL) {
// Use the code stub interface descriptor.
HydrogenCodeStub* stub = info->code_stub();
- CodeStubInterfaceDescriptor* descriptor =
- info_->isolate()->code_stub_interface_descriptor(stub->MajorKey());
- incoming_ = GetStubCallDescriptor(descriptor);
+ CodeStubInterfaceDescriptor descriptor;
+ stub->InitializeInterfaceDescriptor(&descriptor);
+ incoming_ = GetStubCallDescriptor(&descriptor);
} else {
incoming_ = NULL; // TODO(titzer): ?
}
Node* context, Node* frame_state,
CallFunctionFlags flags) {
CallFunctionStub stub(isolate(), 0, flags);
- CodeStubInterfaceDescriptor* d = isolate()->code_stub_interface_descriptor(
- reinterpret_cast<CodeStub*>(&stub)->MajorKey());
- stub.InitializeInterfaceDescriptor(d);
+ CodeStubInterfaceDescriptor d;
+ stub.InitializeInterfaceDescriptor(&d);
CallDescriptor* desc = Linkage::GetStubCallDescriptor(
- d, 1, CallDescriptor::kNeedsFrameState, zone());
+ &d, 1, CallDescriptor::kNeedsFrameState, zone());
Node* stub_code = HeapConstant(stub.GetCode());
Node* call = graph()->NewNode(common()->Call(desc), stub_code, function,
receiver, context, frame_state);
void SimplifiedLowering::DoStringAdd(Node* node) {
StringAddStub stub(zone()->isolate(), STRING_ADD_CHECK_NONE, NOT_TENURED);
- CodeStubInterfaceDescriptor* d = stub.GetInterfaceDescriptor();
+ CodeStubInterfaceDescriptor d;
+ stub.InitializeInterfaceDescriptor(&d);
CallDescriptor::Flags flags = CallDescriptor::kNoFlags;
- CallDescriptor* desc = Linkage::GetStubCallDescriptor(d, 0, flags, zone());
+ CallDescriptor* desc = Linkage::GetStubCallDescriptor(&d, 0, flags, zone());
node->set_op(common()->Call(desc));
node->InsertInput(zone(), 0, jsgraph()->HeapConstant(stub.GetCode()));
node->AppendInput(zone(), jsgraph()->UndefinedConstant());
CHECK(compiled_code_->is_hydrogen_stub());
int major_key = CodeStub::GetMajorKey(compiled_code_);
- CodeStubInterfaceDescriptor* descriptor =
- isolate_->code_stub_interface_descriptor(major_key);
+ CodeStubInterfaceDescriptor descriptor;
+ CodeStub::InitializeInterfaceDescriptor(isolate_, compiled_code_->stub_key(),
+ &descriptor);
// Check that there is a matching descriptor to the major key.
// This will fail if there has not been one installed to the isolate.
- DCHECK_EQ(descriptor->MajorKey(), major_key);
+ DCHECK_EQ(descriptor.MajorKey(), major_key);
// The output frame must have room for all pushed register parameters
// and the standard stack frame slots. Include space for an argument
// object to the callee and optionally the space to pass the argument
// object to the stub failure handler.
- int param_count = descriptor->GetEnvironmentParameterCount();
+ int param_count = descriptor.GetEnvironmentParameterCount();
CHECK_GE(param_count, 0);
int height_in_bytes = kPointerSize * param_count + sizeof(Arguments) +
}
intptr_t caller_arg_count = 0;
- bool arg_count_known = !descriptor->stack_parameter_count().is_valid();
+ bool arg_count_known = !descriptor.stack_parameter_count().is_valid();
// Build the Arguments object for the caller's parameters and a pointer to it.
output_frame_offset -= kPointerSize;
output_frame_offset -= kPointerSize;
DoTranslateCommand(iterator, 0, output_frame_offset);
- if (!arg_count_known &&
- descriptor->IsEnvironmentParameterCountRegister(i)) {
+ if (!arg_count_known && descriptor.IsEnvironmentParameterCountRegister(i)) {
arguments_length_offset = output_frame_offset;
}
}
CopyDoubleRegisters(output_frame);
// Fill registers containing handler and number of parameters.
- SetPlatformCompiledStubRegisters(output_frame, descriptor);
+ SetPlatformCompiledStubRegisters(output_frame, &descriptor);
// Compute this frame's PC, state, and continuation.
Code* trampoline = NULL;
- StubFunctionMode function_mode = descriptor->function_mode();
+ StubFunctionMode function_mode = descriptor.function_mode();
StubFailureTrampolineStub(isolate_,
function_mode).FindCodeInCache(&trampoline);
DCHECK(trampoline != NULL);
inlined_functions_(5, info->zone()) {
if (info->IsStub()) {
HydrogenCodeStub* stub = info->code_stub();
- CodeStubInterfaceDescriptor* descriptor = stub->GetInterfaceDescriptor();
- start_environment_ = new(zone_) HEnvironment(
- zone_, descriptor->GetEnvironmentParameterCount());
+ CodeStubInterfaceDescriptor descriptor;
+ stub->InitializeInterfaceDescriptor(&descriptor);
+ start_environment_ = new (zone_)
+ HEnvironment(zone_, descriptor.GetEnvironmentParameterCount());
} else {
TraceInlinedFunction(info->shared_info(), HSourcePosition::Unknown());
start_environment_ =
// Update the static counter each time a new code stub is generated.
isolate()->counters()->code_stubs()->Increment();
- CodeStubInterfaceDescriptor* descriptor = GetInterfaceDescriptor();
- int param_count = descriptor->GetEnvironmentParameterCount();
+ CodeStubInterfaceDescriptor descriptor;
+ InitializeInterfaceDescriptor(&descriptor);
+ int param_count = descriptor.GetEnvironmentParameterCount();
{
// Call the runtime system in a fresh internal frame.
FrameScope scope(masm, StackFrame::INTERNAL);
DCHECK(param_count == 0 ||
- eax.is(descriptor->GetEnvironmentParameterRegister(
- param_count - 1)));
+ eax.is(descriptor.GetEnvironmentParameterRegister(param_count - 1)));
// Push arguments
for (int i = 0; i < param_count; ++i) {
- __ push(descriptor->GetEnvironmentParameterRegister(i));
+ __ push(descriptor.GetEnvironmentParameterRegister(i));
}
- ExternalReference miss = descriptor->miss_handler();
+ ExternalReference miss = descriptor.miss_handler();
__ CallExternalReference(miss, param_count);
}
return DefineAsSpilled(result, spill_index);
} else {
DCHECK(info()->IsStub());
- CodeStubInterfaceDescriptor* descriptor =
- info()->code_stub()->GetInterfaceDescriptor();
+ CodeStubInterfaceDescriptor descriptor;
+ info()->code_stub()->InitializeInterfaceDescriptor(&descriptor);
int index = static_cast<int>(instr->index());
- Register reg = descriptor->GetEnvironmentParameterRegister(index);
+ Register reg = descriptor.GetEnvironmentParameterRegister(index);
return DefineFixed(result, reg);
}
}
string_tracker_(NULL),
regexp_stack_(NULL),
date_cache_(NULL),
- code_stub_interface_descriptors_(NULL),
call_descriptor_data_(NULL),
// TODO(bmeurer) Initialized lazily because it depends on flags; can
// be fixed once the default isolate cleanup is done.
delete date_cache_;
date_cache_ = NULL;
- delete[] code_stub_interface_descriptors_;
- code_stub_interface_descriptors_ = NULL;
-
delete[] call_descriptor_data_;
call_descriptor_data_ = NULL;
regexp_stack_ = new RegExpStack();
regexp_stack_->isolate_ = this;
date_cache_ = new DateCache();
- code_stub_interface_descriptors_ =
- new CodeStubInterfaceDescriptor[CodeStub::NUMBER_OF_IDS];
call_descriptor_data_ =
new CallInterfaceDescriptorData[CallDescriptors::NUMBER_OF_DESCRIPTORS];
cpu_profiler_ = new CpuProfiler(this);
CodeStub::GenerateFPStubs(this);
StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime(this);
StubFailureTrampolineStub::GenerateAheadOfTime(this);
- // Ensure interface descriptors are initialized even when stubs have been
- // deserialized out of the snapshot without using the graph builder.
- FastCloneShallowArrayStub::InstallDescriptors(this);
- BinaryOpICStub::InstallDescriptors(this);
- BinaryOpWithAllocationSiteStub::InstallDescriptors(this);
- CompareNilICStub::InstallDescriptors(this);
- ToBooleanStub::InstallDescriptors(this);
- ToNumberStub::InstallDescriptors(this);
- ArrayConstructorStubBase::InstallDescriptors(this);
- InternalArrayConstructorStubBase::InstallDescriptors(this);
- FastNewClosureStub::InstallDescriptors(this);
- FastNewContextStub::InstallDescriptors(this);
- NumberToStringStub::InstallDescriptors(this);
- StringAddStub::InstallDescriptors(this);
- RegExpConstructResultStub::InstallDescriptors(this);
- KeyedLoadGenericStub::InstallDescriptors(this);
- StoreFieldStub::InstallDescriptors(this);
- LoadFastElementStub::InstallDescriptors(this);
}
initialized_from_snapshot_ = (des != NULL);
}
-CodeStubInterfaceDescriptor*
- Isolate::code_stub_interface_descriptor(int index) {
- return code_stub_interface_descriptors_ + index;
-}
-
-
CallInterfaceDescriptorData* Isolate::call_descriptor_data(int index) {
DCHECK(0 <= index && index < CallDescriptors::NUMBER_OF_DESCRIPTORS);
return &call_descriptor_data_[index];
bool IsFastArrayConstructorPrototypeChainIntact();
- CodeStubInterfaceDescriptor*
- code_stub_interface_descriptor(int index);
-
CallInterfaceDescriptorData* call_descriptor_data(int index);
void IterateDeferredHandles(ObjectVisitor* visitor);
// Update the static counter each time a new code stub is generated.
isolate()->counters()->code_stubs()->Increment();
- CodeStubInterfaceDescriptor* descriptor = GetInterfaceDescriptor();
+ CodeStubInterfaceDescriptor descriptor = GetInterfaceDescriptor();
int param_count = descriptor->GetEnvironmentParameterCount();
{
// Call the runtime system in a fresh internal frame.
// Update the static counter each time a new code stub is generated.
isolate()->counters()->code_stubs()->Increment();
- CodeStubInterfaceDescriptor* descriptor = GetInterfaceDescriptor();
- int param_count = descriptor->GetEnvironmentParameterCount();
+ CodeStubInterfaceDescriptor descriptor;
+ InitializeInterfaceDescriptor(&descriptor);
+ int param_count = descriptor.GetEnvironmentParameterCount();
{
// Call the runtime system in a fresh internal frame.
FrameScope scope(masm, StackFrame::INTERNAL);
DCHECK(param_count == 0 ||
- rax.is(descriptor->GetEnvironmentParameterRegister(
- param_count - 1)));
+ rax.is(descriptor.GetEnvironmentParameterRegister(param_count - 1)));
// Push arguments
for (int i = 0; i < param_count; ++i) {
- __ Push(descriptor->GetEnvironmentParameterRegister(i));
+ __ Push(descriptor.GetEnvironmentParameterRegister(i));
}
- ExternalReference miss = descriptor->miss_handler();
+ ExternalReference miss = descriptor.miss_handler();
__ CallExternalReference(miss, param_count);
}
return DefineAsSpilled(result, spill_index);
} else {
DCHECK(info()->IsStub());
- CodeStubInterfaceDescriptor* descriptor =
- info()->code_stub()->GetInterfaceDescriptor();
+ CodeStubInterfaceDescriptor descriptor;
+ info()->code_stub()->InitializeInterfaceDescriptor(&descriptor);
int index = static_cast<int>(instr->index());
- Register reg = descriptor->GetEnvironmentParameterRegister(index);
+ Register reg = descriptor.GetEnvironmentParameterRegister(index);
return DefineFixed(result, reg);
}
}