Commit fa8a71df authored by ulan@chromium.org's avatar ulan@chromium.org

Handlify CompileConstructStub. Based on 8391045.

R=kmillikin@chromium.org
BUG=
TEST=

Review URL: http://codereview.chromium.org/8399032

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9837 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 00bafbbc
...@@ -3097,7 +3097,8 @@ Handle<Code> KeyedStoreStubCompiler::CompileStorePolymorphic( ...@@ -3097,7 +3097,8 @@ Handle<Code> KeyedStoreStubCompiler::CompileStorePolymorphic(
} }
MaybeObject* ConstructStubCompiler::CompileConstructStub(JSFunction* function) { Handle<Code> ConstructStubCompiler::CompileConstructStub(
Handle<JSFunction> function) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- r0 : argc // -- r0 : argc
// -- r1 : constructor // -- r1 : constructor
...@@ -3143,12 +3144,7 @@ MaybeObject* ConstructStubCompiler::CompileConstructStub(JSFunction* function) { ...@@ -3143,12 +3144,7 @@ MaybeObject* ConstructStubCompiler::CompileConstructStub(JSFunction* function) {
// r2: initial map // r2: initial map
// r7: undefined // r7: undefined
__ ldrb(r3, FieldMemOperand(r2, Map::kInstanceSizeOffset)); __ ldrb(r3, FieldMemOperand(r2, Map::kInstanceSizeOffset));
__ AllocateInNewSpace(r3, __ AllocateInNewSpace(r3, r4, r5, r6, &generic_stub_call, SIZE_IN_WORDS);
r4,
r5,
r6,
&generic_stub_call,
SIZE_IN_WORDS);
// Allocated the JSObject, now initialize the fields. Map is set to initial // Allocated the JSObject, now initialize the fields. Map is set to initial
// map and properties and elements are set to empty fixed array. // map and properties and elements are set to empty fixed array.
...@@ -3180,7 +3176,7 @@ MaybeObject* ConstructStubCompiler::CompileConstructStub(JSFunction* function) { ...@@ -3180,7 +3176,7 @@ MaybeObject* ConstructStubCompiler::CompileConstructStub(JSFunction* function) {
// r7: undefined // r7: undefined
// Fill the initialized properties with a constant value or a passed argument // Fill the initialized properties with a constant value or a passed argument
// depending on the this.x = ...; assignment in the function. // depending on the this.x = ...; assignment in the function.
SharedFunctionInfo* shared = function->shared(); Handle<SharedFunctionInfo> shared(function->shared());
for (int i = 0; i < shared->this_property_assignments_count(); i++) { for (int i = 0; i < shared->this_property_assignments_count(); i++) {
if (shared->IsThisPropertyAssignmentArgument(i)) { if (shared->IsThisPropertyAssignmentArgument(i)) {
Label not_passed, next; Label not_passed, next;
......
...@@ -3079,7 +3079,8 @@ Handle<Code> KeyedLoadStubCompiler::CompileLoadPolymorphic( ...@@ -3079,7 +3079,8 @@ Handle<Code> KeyedLoadStubCompiler::CompileLoadPolymorphic(
// Specialized stub for constructing objects from functions which only have only // Specialized stub for constructing objects from functions which only have only
// simple assignments of the form this.x = ...; in their body. // simple assignments of the form this.x = ...; in their body.
MaybeObject* ConstructStubCompiler::CompileConstructStub(JSFunction* function) { Handle<Code> ConstructStubCompiler::CompileConstructStub(
Handle<JSFunction> function) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- eax : argc // -- eax : argc
// -- edi : constructor // -- edi : constructor
...@@ -3118,12 +3119,8 @@ MaybeObject* ConstructStubCompiler::CompileConstructStub(JSFunction* function) { ...@@ -3118,12 +3119,8 @@ MaybeObject* ConstructStubCompiler::CompileConstructStub(JSFunction* function) {
// ebx: initial map // ebx: initial map
__ movzx_b(ecx, FieldOperand(ebx, Map::kInstanceSizeOffset)); __ movzx_b(ecx, FieldOperand(ebx, Map::kInstanceSizeOffset));
__ shl(ecx, kPointerSizeLog2); __ shl(ecx, kPointerSizeLog2);
__ AllocateInNewSpace(ecx, __ AllocateInNewSpace(ecx, edx, ecx, no_reg,
edx, &generic_stub_call, NO_ALLOCATION_FLAGS);
ecx,
no_reg,
&generic_stub_call,
NO_ALLOCATION_FLAGS);
// Allocated the JSObject, now initialize the fields and add the heap tag. // Allocated the JSObject, now initialize the fields and add the heap tag.
// ebx: initial map // ebx: initial map
...@@ -3154,7 +3151,7 @@ MaybeObject* ConstructStubCompiler::CompileConstructStub(JSFunction* function) { ...@@ -3154,7 +3151,7 @@ MaybeObject* ConstructStubCompiler::CompileConstructStub(JSFunction* function) {
// edi: undefined // edi: undefined
// Fill the initialized properties with a constant value or a passed argument // Fill the initialized properties with a constant value or a passed argument
// depending on the this.x = ...; assignment in the function. // depending on the this.x = ...; assignment in the function.
SharedFunctionInfo* shared = function->shared(); Handle<SharedFunctionInfo> shared(function->shared());
for (int i = 0; i < shared->this_property_assignments_count(); i++) { for (int i = 0; i < shared->this_property_assignments_count(); i++) {
if (shared->IsThisPropertyAssignmentArgument(i)) { if (shared->IsThisPropertyAssignmentArgument(i)) {
// Check if the argument assigned to the property is actually passed. // Check if the argument assigned to the property is actually passed.
...@@ -3206,9 +3203,8 @@ MaybeObject* ConstructStubCompiler::CompileConstructStub(JSFunction* function) { ...@@ -3206,9 +3203,8 @@ MaybeObject* ConstructStubCompiler::CompileConstructStub(JSFunction* function) {
// Jump to the generic stub in case the specialized code cannot handle the // Jump to the generic stub in case the specialized code cannot handle the
// construction. // construction.
__ bind(&generic_stub_call); __ bind(&generic_stub_call);
Handle<Code> generic_construct_stub = Handle<Code> code = isolate()->builtins()->JSConstructStubGeneric();
isolate()->builtins()->JSConstructStubGeneric(); __ jmp(code, RelocInfo::CODE_TARGET);
__ jmp(generic_construct_stub, RelocInfo::CODE_TARGET);
// Return the generated code. // Return the generated code.
return GetCode(); return GetCode();
......
...@@ -8214,13 +8214,9 @@ static void TrySettingInlineConstructStub(Isolate* isolate, ...@@ -8214,13 +8214,9 @@ static void TrySettingInlineConstructStub(Isolate* isolate,
prototype = Handle<Object>(function->instance_prototype(), isolate); prototype = Handle<Object>(function->instance_prototype(), isolate);
} }
if (function->shared()->CanGenerateInlineConstructor(*prototype)) { if (function->shared()->CanGenerateInlineConstructor(*prototype)) {
HandleScope scope(isolate);
ConstructStubCompiler compiler(isolate); ConstructStubCompiler compiler(isolate);
MaybeObject* code = compiler.CompileConstructStub(*function); Handle<Code> code = compiler.CompileConstructStub(function);
if (!code->IsFailure()) { function->shared()->set_construct_stub(*code);
function->shared()->set_construct_stub(
Code::cast(code->ToObjectUnchecked()));
}
} }
} }
......
...@@ -1291,33 +1291,6 @@ Handle<Code> StubCompiler::GetCodeWithFlags(Code::Flags flags, ...@@ -1291,33 +1291,6 @@ Handle<Code> StubCompiler::GetCodeWithFlags(Code::Flags flags,
} }
MaybeObject* StubCompiler::TryGetCodeWithFlags(Code::Flags flags,
const char* name) {
// Check for allocation failures during stub compilation.
if (failure_->IsFailure()) return failure_;
// Create code object in the heap.
CodeDesc desc;
masm_.GetCode(&desc);
MaybeObject* result = heap()->CreateCode(desc, flags, masm_.CodeObject());
#ifdef ENABLE_DISASSEMBLER
if (FLAG_print_code_stubs && !result->IsFailure()) {
Code::cast(result->ToObjectUnchecked())->Disassemble(name);
}
#endif
return result;
}
MaybeObject* StubCompiler::TryGetCodeWithFlags(Code::Flags flags,
String* name) {
if (FLAG_print_code_stubs && name != NULL) {
return TryGetCodeWithFlags(flags, *name->ToCString());
}
return TryGetCodeWithFlags(flags, reinterpret_cast<char*>(NULL));
}
void StubCompiler::LookupPostInterceptor(Handle<JSObject> holder, void StubCompiler::LookupPostInterceptor(Handle<JSObject> holder,
Handle<String> name, Handle<String> name,
LookupResult* lookup) { LookupResult* lookup) {
...@@ -1459,17 +1432,12 @@ Handle<Code> CallStubCompiler::GetCode(Handle<JSFunction> function) { ...@@ -1459,17 +1432,12 @@ Handle<Code> CallStubCompiler::GetCode(Handle<JSFunction> function) {
} }
MaybeObject* ConstructStubCompiler::GetCode() { Handle<Code> ConstructStubCompiler::GetCode() {
Code::Flags flags = Code::ComputeFlags(Code::STUB); Code::Flags flags = Code::ComputeFlags(Code::STUB);
Object* result; Handle<Code> code = GetCodeWithFlags(flags, "ConstructStub");
{ MaybeObject* maybe_result = TryGetCodeWithFlags(flags, "ConstructStub"); PROFILE(isolate(), CodeCreateEvent(Logger::STUB_TAG, *code, "ConstructStub"));
if (!maybe_result->ToObject(&result)) return maybe_result; GDBJIT(AddCode(GDBJITInterface::STUB, "ConstructStub", *code));
} return code;
Code* code = Code::cast(result);
USE(code);
PROFILE(isolate(), CodeCreateEvent(Logger::STUB_TAG, code, "ConstructStub"));
GDBJIT(AddCode(GDBJITInterface::STUB, "ConstructStub", Code::cast(code)));
return result;
} }
......
...@@ -488,13 +488,6 @@ class StubCompiler BASE_EMBEDDED { ...@@ -488,13 +488,6 @@ class StubCompiler BASE_EMBEDDED {
Handle<Code> GetCodeWithFlags(Code::Flags flags, const char* name); Handle<Code> GetCodeWithFlags(Code::Flags flags, const char* name);
Handle<Code> GetCodeWithFlags(Code::Flags flags, Handle<String> name); Handle<Code> GetCodeWithFlags(Code::Flags flags, Handle<String> name);
// TODO(kmillikin): Remove these functions once the ConstructStubCompiler
// is handlified.
MUST_USE_RESULT MaybeObject* TryGetCodeWithFlags(Code::Flags flags,
const char* name);
MUST_USE_RESULT MaybeObject* TryGetCodeWithFlags(Code::Flags flags,
String* name);
MacroAssembler* masm() { return &masm_; } MacroAssembler* masm() { return &masm_; }
void set_failure(Failure* failure) { failure_ = failure; } void set_failure(Failure* failure) { failure_ = failure; }
...@@ -812,10 +805,10 @@ class ConstructStubCompiler: public StubCompiler { ...@@ -812,10 +805,10 @@ class ConstructStubCompiler: public StubCompiler {
public: public:
explicit ConstructStubCompiler(Isolate* isolate) : StubCompiler(isolate) { } explicit ConstructStubCompiler(Isolate* isolate) : StubCompiler(isolate) { }
MUST_USE_RESULT MaybeObject* CompileConstructStub(JSFunction* function); Handle<Code> CompileConstructStub(Handle<JSFunction> function);
private: private:
MaybeObject* GetCode(); Handle<Code> GetCode();
}; };
......
...@@ -2920,7 +2920,8 @@ Handle<Code> KeyedLoadStubCompiler::CompileLoadPolymorphic( ...@@ -2920,7 +2920,8 @@ Handle<Code> KeyedLoadStubCompiler::CompileLoadPolymorphic(
// Specialized stub for constructing objects from functions which only have only // Specialized stub for constructing objects from functions which only have only
// simple assignments of the form this.x = ...; in their body. // simple assignments of the form this.x = ...; in their body.
MaybeObject* ConstructStubCompiler::CompileConstructStub(JSFunction* function) { Handle<Code> ConstructStubCompiler::CompileConstructStub(
Handle<JSFunction> function) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- rax : argc // -- rax : argc
// -- rdi : constructor // -- rdi : constructor
...@@ -2963,12 +2964,8 @@ MaybeObject* ConstructStubCompiler::CompileConstructStub(JSFunction* function) { ...@@ -2963,12 +2964,8 @@ MaybeObject* ConstructStubCompiler::CompileConstructStub(JSFunction* function) {
// rbx: initial map // rbx: initial map
__ movzxbq(rcx, FieldOperand(rbx, Map::kInstanceSizeOffset)); __ movzxbq(rcx, FieldOperand(rbx, Map::kInstanceSizeOffset));
__ shl(rcx, Immediate(kPointerSizeLog2)); __ shl(rcx, Immediate(kPointerSizeLog2));
__ AllocateInNewSpace(rcx, __ AllocateInNewSpace(rcx, rdx, rcx, no_reg,
rdx, &generic_stub_call, NO_ALLOCATION_FLAGS);
rcx,
no_reg,
&generic_stub_call,
NO_ALLOCATION_FLAGS);
// Allocated the JSObject, now initialize the fields and add the heap tag. // Allocated the JSObject, now initialize the fields and add the heap tag.
// rbx: initial map // rbx: initial map
...@@ -2993,7 +2990,7 @@ MaybeObject* ConstructStubCompiler::CompileConstructStub(JSFunction* function) { ...@@ -2993,7 +2990,7 @@ MaybeObject* ConstructStubCompiler::CompileConstructStub(JSFunction* function) {
// r9: first in-object property of the JSObject // r9: first in-object property of the JSObject
// Fill the initialized properties with a constant value or a passed argument // Fill the initialized properties with a constant value or a passed argument
// depending on the this.x = ...; assignment in the function. // depending on the this.x = ...; assignment in the function.
SharedFunctionInfo* shared = function->shared(); Handle<SharedFunctionInfo> shared(function->shared());
for (int i = 0; i < shared->this_property_assignments_count(); i++) { for (int i = 0; i < shared->this_property_assignments_count(); i++) {
if (shared->IsThisPropertyAssignmentArgument(i)) { if (shared->IsThisPropertyAssignmentArgument(i)) {
// Check if the argument assigned to the property is actually passed. // Check if the argument assigned to the property is actually passed.
...@@ -3041,10 +3038,8 @@ MaybeObject* ConstructStubCompiler::CompileConstructStub(JSFunction* function) { ...@@ -3041,10 +3038,8 @@ MaybeObject* ConstructStubCompiler::CompileConstructStub(JSFunction* function) {
// Jump to the generic stub in case the specialized code cannot handle the // Jump to the generic stub in case the specialized code cannot handle the
// construction. // construction.
__ bind(&generic_stub_call); __ bind(&generic_stub_call);
Code* code = Handle<Code> code = isolate()->builtins()->JSConstructStubGeneric();
isolate()->builtins()->builtin(Builtins::kJSConstructStubGeneric); __ Jump(code, RelocInfo::CODE_TARGET);
Handle<Code> generic_construct_stub(code);
__ Jump(generic_construct_stub, RelocInfo::CODE_TARGET);
// Return the generated code. // Return the generated code.
return GetCode(); return GetCode();
......
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