Revision: 9837
Author: [email protected]
Date: Fri Oct 28 07:08:43 2011
Log: Handlify CompileConstructStub. Based on 8391045.
[email protected]
BUG=
TEST=
Review URL: http://codereview.chromium.org/8399032
http://code.google.com/p/v8/source/detail?r=9837
Modified:
/branches/bleeding_edge/src/arm/stub-cache-arm.cc
/branches/bleeding_edge/src/ia32/stub-cache-ia32.cc
/branches/bleeding_edge/src/runtime.cc
/branches/bleeding_edge/src/stub-cache.cc
/branches/bleeding_edge/src/stub-cache.h
/branches/bleeding_edge/src/x64/stub-cache-x64.cc
=======================================
--- /branches/bleeding_edge/src/arm/stub-cache-arm.cc Fri Oct 28 05:37:29
2011
+++ /branches/bleeding_edge/src/arm/stub-cache-arm.cc Fri Oct 28 07:08:43
2011
@@ -3097,7 +3097,8 @@
}
-MaybeObject* ConstructStubCompiler::CompileConstructStub(JSFunction*
function) {
+Handle<Code> ConstructStubCompiler::CompileConstructStub(
+ Handle<JSFunction> function) {
// ----------- S t a t e -------------
// -- r0 : argc
// -- r1 : constructor
@@ -3143,12 +3144,7 @@
// r2: initial map
// r7: undefined
__ ldrb(r3, FieldMemOperand(r2, Map::kInstanceSizeOffset));
- __ AllocateInNewSpace(r3,
- r4,
- r5,
- r6,
- &generic_stub_call,
- SIZE_IN_WORDS);
+ __ AllocateInNewSpace(r3, r4, r5, r6, &generic_stub_call, SIZE_IN_WORDS);
// Allocated the JSObject, now initialize the fields. Map is set to
initial
// map and properties and elements are set to empty fixed array.
@@ -3180,7 +3176,7 @@
// r7: undefined
// Fill the initialized properties with a constant value or a passed
argument
// 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++) {
if (shared->IsThisPropertyAssignmentArgument(i)) {
Label not_passed, next;
=======================================
--- /branches/bleeding_edge/src/ia32/stub-cache-ia32.cc Fri Oct 28 05:37:29
2011
+++ /branches/bleeding_edge/src/ia32/stub-cache-ia32.cc Fri Oct 28 07:08:43
2011
@@ -3079,7 +3079,8 @@
// Specialized stub for constructing objects from functions which only
have only
// 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 -------------
// -- eax : argc
// -- edi : constructor
@@ -3118,12 +3119,8 @@
// ebx: initial map
__ movzx_b(ecx, FieldOperand(ebx, Map::kInstanceSizeOffset));
__ shl(ecx, kPointerSizeLog2);
- __ AllocateInNewSpace(ecx,
- edx,
- ecx,
- no_reg,
- &generic_stub_call,
- NO_ALLOCATION_FLAGS);
+ __ AllocateInNewSpace(ecx, edx, ecx, no_reg,
+ &generic_stub_call, NO_ALLOCATION_FLAGS);
// Allocated the JSObject, now initialize the fields and add the heap
tag.
// ebx: initial map
@@ -3154,7 +3151,7 @@
// edi: undefined
// Fill the initialized properties with a constant value or a passed
argument
// 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++) {
if (shared->IsThisPropertyAssignmentArgument(i)) {
// Check if the argument assigned to the property is actually passed.
@@ -3206,9 +3203,8 @@
// Jump to the generic stub in case the specialized code cannot handle
the
// construction.
__ bind(&generic_stub_call);
- Handle<Code> generic_construct_stub =
- isolate()->builtins()->JSConstructStubGeneric();
- __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET);
+ Handle<Code> code = isolate()->builtins()->JSConstructStubGeneric();
+ __ jmp(code, RelocInfo::CODE_TARGET);
// Return the generated code.
return GetCode();
=======================================
--- /branches/bleeding_edge/src/runtime.cc Fri Oct 28 05:49:09 2011
+++ /branches/bleeding_edge/src/runtime.cc Fri Oct 28 07:08:43 2011
@@ -8214,13 +8214,9 @@
prototype = Handle<Object>(function->instance_prototype(), isolate);
}
if (function->shared()->CanGenerateInlineConstructor(*prototype)) {
- HandleScope scope(isolate);
ConstructStubCompiler compiler(isolate);
- MaybeObject* code = compiler.CompileConstructStub(*function);
- if (!code->IsFailure()) {
- function->shared()->set_construct_stub(
- Code::cast(code->ToObjectUnchecked()));
- }
+ Handle<Code> code = compiler.CompileConstructStub(function);
+ function->shared()->set_construct_stub(*code);
}
}
=======================================
--- /branches/bleeding_edge/src/stub-cache.cc Fri Oct 28 05:37:29 2011
+++ /branches/bleeding_edge/src/stub-cache.cc Fri Oct 28 07:08:43 2011
@@ -1289,33 +1289,6 @@
? GetCodeWithFlags(flags, *name->ToCString())
: GetCodeWithFlags(flags, reinterpret_cast<char*>(NULL));
}
-
-
-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,
@@ -1459,17 +1432,12 @@
}
-MaybeObject* ConstructStubCompiler::GetCode() {
+Handle<Code> ConstructStubCompiler::GetCode() {
Code::Flags flags = Code::ComputeFlags(Code::STUB);
- Object* result;
- { MaybeObject* maybe_result =
TryGetCodeWithFlags(flags, "ConstructStub");
- if (!maybe_result->ToObject(&result)) return maybe_result;
- }
- 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;
+ Handle<Code> code = GetCodeWithFlags(flags, "ConstructStub");
+ PROFILE(isolate(), CodeCreateEvent(Logger::STUB_TAG,
*code, "ConstructStub"));
+ GDBJIT(AddCode(GDBJITInterface::STUB, "ConstructStub", *code));
+ return code;
}
=======================================
--- /branches/bleeding_edge/src/stub-cache.h Fri Oct 28 05:37:29 2011
+++ /branches/bleeding_edge/src/stub-cache.h Fri Oct 28 07:08:43 2011
@@ -488,13 +488,6 @@
Handle<Code> GetCodeWithFlags(Code::Flags flags, const char* 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_; }
void set_failure(Failure* failure) { failure_ = failure; }
@@ -812,10 +805,10 @@
public:
explicit ConstructStubCompiler(Isolate* isolate) : StubCompiler(isolate)
{ }
- MUST_USE_RESULT MaybeObject* CompileConstructStub(JSFunction* function);
+ Handle<Code> CompileConstructStub(Handle<JSFunction> function);
private:
- MaybeObject* GetCode();
+ Handle<Code> GetCode();
};
=======================================
--- /branches/bleeding_edge/src/x64/stub-cache-x64.cc Fri Oct 28 05:37:29
2011
+++ /branches/bleeding_edge/src/x64/stub-cache-x64.cc Fri Oct 28 07:08:43
2011
@@ -2920,7 +2920,8 @@
// Specialized stub for constructing objects from functions which only
have only
// 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 -------------
// -- rax : argc
// -- rdi : constructor
@@ -2963,12 +2964,8 @@
// rbx: initial map
__ movzxbq(rcx, FieldOperand(rbx, Map::kInstanceSizeOffset));
__ shl(rcx, Immediate(kPointerSizeLog2));
- __ AllocateInNewSpace(rcx,
- rdx,
- rcx,
- no_reg,
- &generic_stub_call,
- NO_ALLOCATION_FLAGS);
+ __ AllocateInNewSpace(rcx, rdx, rcx, no_reg,
+ &generic_stub_call, NO_ALLOCATION_FLAGS);
// Allocated the JSObject, now initialize the fields and add the heap
tag.
// rbx: initial map
@@ -2993,7 +2990,7 @@
// r9: first in-object property of the JSObject
// Fill the initialized properties with a constant value or a passed
argument
// 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++) {
if (shared->IsThisPropertyAssignmentArgument(i)) {
// Check if the argument assigned to the property is actually passed.
@@ -3041,10 +3038,8 @@
// Jump to the generic stub in case the specialized code cannot handle
the
// construction.
__ bind(&generic_stub_call);
- Code* code =
- isolate()->builtins()->builtin(Builtins::kJSConstructStubGeneric);
- Handle<Code> generic_construct_stub(code);
- __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET);
+ Handle<Code> code = isolate()->builtins()->JSConstructStubGeneric();
+ __ Jump(code, RelocInfo::CODE_TARGET);
// Return the generated code.
return GetCode();
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev