Commit 591eb3f4 authored by erik.corry@gmail.com's avatar erik.corry@gmail.com

Minor cleanup: Use MaybeObject instead of bool and Failure** in

stub cache generation.
Review URL: http://codereview.chromium.org/6392003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6480 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 1c4dfa30
......@@ -1198,7 +1198,7 @@ void StubCompiler::GenerateLoadConstant(JSObject* object,
}
bool StubCompiler::GenerateLoadCallback(JSObject* object,
MaybeObject* StubCompiler::GenerateLoadCallback(JSObject* object,
JSObject* holder,
Register receiver,
Register name_reg,
......@@ -1207,8 +1207,7 @@ bool StubCompiler::GenerateLoadCallback(JSObject* object,
Register scratch3,
AccessorInfo* callback,
String* name,
Label* miss,
Failure** failure) {
Label* miss) {
// Check that the receiver isn't a smi.
__ tst(receiver, Operand(kSmiTagMask));
__ b(eq, miss);
......@@ -1229,7 +1228,7 @@ bool StubCompiler::GenerateLoadCallback(JSObject* object,
ExternalReference(IC_Utility(IC::kLoadCallbackProperty));
__ TailCallExternalReference(load_callback_property, 5, 1);
return true;
return Heap::undefined_value(); // Success.
}
......@@ -2742,12 +2741,11 @@ MaybeObject* LoadStubCompiler::CompileLoadCallback(String* name,
// -----------------------------------
Label miss;
Failure* failure = Failure::InternalError();
bool success = GenerateLoadCallback(object, holder, r0, r2, r3, r1, r4,
callback, name, &miss, &failure);
if (!success) {
MaybeObject* result = GenerateLoadCallback(object, holder, r0, r2, r3, r1, r4,
callback, name, &miss);
if (result->IsFailure()) {
miss.Unuse();
return failure;
return result;
}
__ bind(&miss);
......@@ -2894,12 +2892,11 @@ MaybeObject* KeyedLoadStubCompiler::CompileLoadCallback(
__ cmp(r0, Operand(Handle<String>(name)));
__ b(ne, &miss);
Failure* failure = Failure::InternalError();
bool success = GenerateLoadCallback(receiver, holder, r1, r0, r2, r3, r4,
callback, name, &miss, &failure);
if (!success) {
MaybeObject* result = GenerateLoadCallback(receiver, holder, r1, r0, r2, r3,
r4, callback, name, &miss);
if (result->IsFailure()) {
miss.Unuse();
return failure;
return result;
}
__ bind(&miss);
......
......@@ -455,10 +455,9 @@ static void FreeSpaceForFastApiCall(MacroAssembler* masm, Register scratch) {
// Generates call to API function.
static bool GenerateFastApiCall(MacroAssembler* masm,
static MaybeObject* GenerateFastApiCall(MacroAssembler* masm,
const CallOptimization& optimization,
int argc,
Failure** failure) {
int argc) {
// ----------- S t a t e -------------
// -- esp[0] : return address
// -- esp[4] : object passing the type check
......@@ -520,13 +519,8 @@ static bool GenerateFastApiCall(MacroAssembler* masm,
// already generated). Do not allow the assembler to perform a
// garbage collection but instead return the allocation failure
// object.
MaybeObject* result =
masm->TryCallApiFunctionAndReturn(&fun, argc + kFastApiCallArguments + 1);
if (result->IsFailure()) {
*failure = Failure::cast(result);
return false;
}
return true;
return masm->TryCallApiFunctionAndReturn(&fun,
argc + kFastApiCallArguments + 1);
}
......@@ -539,7 +533,7 @@ class CallInterceptorCompiler BASE_EMBEDDED {
arguments_(arguments),
name_(name) {}
bool Compile(MacroAssembler* masm,
MaybeObject* Compile(MacroAssembler* masm,
JSObject* object,
JSObject* holder,
String* name,
......@@ -548,8 +542,7 @@ class CallInterceptorCompiler BASE_EMBEDDED {
Register scratch1,
Register scratch2,
Register scratch3,
Label* miss,
Failure** failure) {
Label* miss) {
ASSERT(holder->HasNamedInterceptor());
ASSERT(!holder->GetNamedInterceptor()->getter()->IsUndefined());
......@@ -570,8 +563,7 @@ class CallInterceptorCompiler BASE_EMBEDDED {
lookup,
name,
optimization,
miss,
failure);
miss);
} else {
CompileRegular(masm,
object,
......@@ -582,12 +574,12 @@ class CallInterceptorCompiler BASE_EMBEDDED {
name,
holder,
miss);
return true;
return Heap::undefined_value(); // Success.
}
}
private:
bool CompileCacheable(MacroAssembler* masm,
MaybeObject* CompileCacheable(MacroAssembler* masm,
JSObject* object,
Register receiver,
Register scratch1,
......@@ -597,8 +589,7 @@ class CallInterceptorCompiler BASE_EMBEDDED {
LookupResult* lookup,
String* name,
const CallOptimization& optimization,
Label* miss_label,
Failure** failure) {
Label* miss_label) {
ASSERT(optimization.is_constant_call());
ASSERT(!lookup->holder()->IsGlobalObject());
......@@ -660,11 +651,9 @@ class CallInterceptorCompiler BASE_EMBEDDED {
// Invoke function.
if (can_do_fast_api_call) {
bool success = GenerateFastApiCall(masm, optimization,
arguments_.immediate(), failure);
if (!success) {
return false;
}
MaybeObject* result =
GenerateFastApiCall(masm, optimization, arguments_.immediate());
if (result->IsFailure()) return result;
} else {
__ InvokeFunction(optimization.constant_function(), arguments_,
JUMP_FUNCTION);
......@@ -683,7 +672,7 @@ class CallInterceptorCompiler BASE_EMBEDDED {
FreeSpaceForFastApiCall(masm, scratch1);
}
return true;
return Heap::undefined_value(); // Success.
}
void CompileRegular(MacroAssembler* masm,
......@@ -1061,7 +1050,7 @@ void StubCompiler::GenerateLoadField(JSObject* object,
}
bool StubCompiler::GenerateLoadCallback(JSObject* object,
MaybeObject* StubCompiler::GenerateLoadCallback(JSObject* object,
JSObject* holder,
Register receiver,
Register name_reg,
......@@ -1070,8 +1059,7 @@ bool StubCompiler::GenerateLoadCallback(JSObject* object,
Register scratch3,
AccessorInfo* callback,
String* name,
Label* miss,
Failure** failure) {
Label* miss) {
// Check that the receiver isn't a smi.
__ test(receiver, Immediate(kSmiTagMask));
__ j(zero, miss, not_taken);
......@@ -1126,13 +1114,7 @@ bool StubCompiler::GenerateLoadCallback(JSObject* object,
// already generated). Do not allow the assembler to perform a
// garbage collection but instead return the allocation failure
// object.
MaybeObject* result = masm()->TryCallApiFunctionAndReturn(&fun, kStackSpace);
if (result->IsFailure()) {
*failure = Failure::cast(result);
return false;
}
return true;
return masm()->TryCallApiFunctionAndReturn(&fun, kStackSpace);
}
......@@ -2284,17 +2266,14 @@ MaybeObject* CallStubCompiler::CompileCallConstant(Object* object,
}
if (depth != kInvalidProtoDepth) {
Failure* failure;
// Move the return address on top of the stack.
__ mov(eax, Operand(esp, 3 * kPointerSize));
__ mov(Operand(esp, 0 * kPointerSize), eax);
// esp[2 * kPointerSize] is uninitialized, esp[3 * kPointerSize] contains
// duplicate of return address and will be overwritten.
bool success = GenerateFastApiCall(masm(), optimization, argc, &failure);
if (!success) {
return failure;
}
MaybeObject* result = GenerateFastApiCall(masm(), optimization, argc);
if (result->IsFailure()) return result;
} else {
__ InvokeFunction(function, arguments(), JUMP_FUNCTION);
}
......@@ -2339,8 +2318,7 @@ MaybeObject* CallStubCompiler::CompileCallInterceptor(JSObject* object,
__ mov(edx, Operand(esp, (argc + 1) * kPointerSize));
CallInterceptorCompiler compiler(this, arguments(), ecx);
Failure* failure;
bool success = compiler.Compile(masm(),
MaybeObject* result = compiler.Compile(masm(),
object,
holder,
name,
......@@ -2349,11 +2327,8 @@ MaybeObject* CallStubCompiler::CompileCallInterceptor(JSObject* object,
ebx,
edi,
eax,
&miss,
&failure);
if (!success) {
return failure;
}
&miss);
if (result->IsFailure()) return result;
// Restore receiver.
__ mov(edx, Operand(esp, (argc + 1) * kPointerSize));
......@@ -2803,12 +2778,11 @@ MaybeObject* LoadStubCompiler::CompileLoadCallback(String* name,
// -----------------------------------
Label miss;
Failure* failure = Failure::InternalError();
bool success = GenerateLoadCallback(object, holder, eax, ecx, ebx, edx, edi,
callback, name, &miss, &failure);
if (!success) {
MaybeObject* result = GenerateLoadCallback(object, holder, eax, ecx, ebx, edx,
edi, callback, name, &miss);
if (result->IsFailure()) {
miss.Unuse();
return failure;
return result;
}
__ bind(&miss);
......@@ -2972,12 +2946,11 @@ MaybeObject* KeyedLoadStubCompiler::CompileLoadCallback(
__ cmp(Operand(eax), Immediate(Handle<String>(name)));
__ j(not_equal, &miss, not_taken);
Failure* failure = Failure::InternalError();
bool success = GenerateLoadCallback(receiver, holder, edx, eax, ebx, ecx, edi,
callback, name, &miss, &failure);
if (!success) {
MaybeObject* result = GenerateLoadCallback(receiver, holder, edx, eax, ebx,
ecx, edi, callback, name, &miss);
if (result->IsFailure()) {
miss.Unuse();
return failure;
return result;
}
__ bind(&miss);
......
......@@ -502,7 +502,7 @@ class StubCompiler BASE_EMBEDDED {
String* name,
Label* miss);
bool GenerateLoadCallback(JSObject* object,
MaybeObject* GenerateLoadCallback(JSObject* object,
JSObject* holder,
Register receiver,
Register name_reg,
......@@ -511,8 +511,7 @@ class StubCompiler BASE_EMBEDDED {
Register scratch3,
AccessorInfo* callback,
String* name,
Label* miss,
Failure** failure);
Label* miss);
void GenerateLoadConstant(JSObject* object,
JSObject* holder,
......
......@@ -441,10 +441,9 @@ static void FreeSpaceForFastApiCall(MacroAssembler* masm, Register scratch) {
// Generates call to API function.
static bool GenerateFastApiCall(MacroAssembler* masm,
static MaybeObject* GenerateFastApiCall(MacroAssembler* masm,
const CallOptimization& optimization,
int argc,
Failure** failure) {
int argc) {
// ----------- S t a t e -------------
// -- rsp[0] : return address
// -- rsp[8] : object passing the type check
......@@ -508,13 +507,8 @@ static bool GenerateFastApiCall(MacroAssembler* masm,
// already generated). Do not allow the assembler to perform a
// garbage collection but instead return the allocation failure
// object.
MaybeObject* result =
masm->TryCallApiFunctionAndReturn(&fun, argc + kFastApiCallArguments + 1);
if (result->IsFailure()) {
*failure = Failure::cast(result);
return false;
}
return true;
return masm->TryCallApiFunctionAndReturn(&fun,
argc + kFastApiCallArguments + 1);
}
......@@ -527,7 +521,7 @@ class CallInterceptorCompiler BASE_EMBEDDED {
arguments_(arguments),
name_(name) {}
bool Compile(MacroAssembler* masm,
MaybeObject* Compile(MacroAssembler* masm,
JSObject* object,
JSObject* holder,
String* name,
......@@ -536,8 +530,7 @@ class CallInterceptorCompiler BASE_EMBEDDED {
Register scratch1,
Register scratch2,
Register scratch3,
Label* miss,
Failure** failure) {
Label* miss) {
ASSERT(holder->HasNamedInterceptor());
ASSERT(!holder->GetNamedInterceptor()->getter()->IsUndefined());
......@@ -557,8 +550,7 @@ class CallInterceptorCompiler BASE_EMBEDDED {
lookup,
name,
optimization,
miss,
failure);
miss);
} else {
CompileRegular(masm,
object,
......@@ -569,12 +561,12 @@ class CallInterceptorCompiler BASE_EMBEDDED {
name,
holder,
miss);
return true;
return Heap::undefined_value(); // Success.
}
}
private:
bool CompileCacheable(MacroAssembler* masm,
MaybeObject* CompileCacheable(MacroAssembler* masm,
JSObject* object,
Register receiver,
Register scratch1,
......@@ -584,8 +576,7 @@ class CallInterceptorCompiler BASE_EMBEDDED {
LookupResult* lookup,
String* name,
const CallOptimization& optimization,
Label* miss_label,
Failure** failure) {
Label* miss_label) {
ASSERT(optimization.is_constant_call());
ASSERT(!lookup->holder()->IsGlobalObject());
......@@ -647,13 +638,10 @@ class CallInterceptorCompiler BASE_EMBEDDED {
// Invoke function.
if (can_do_fast_api_call) {
bool success = GenerateFastApiCall(masm,
MaybeObject* result = GenerateFastApiCall(masm,
optimization,
arguments_.immediate(),
failure);
if (!success) {
return false;
}
arguments_.immediate());
if (result->IsFailure()) return result;
} else {
__ InvokeFunction(optimization.constant_function(), arguments_,
JUMP_FUNCTION);
......@@ -672,7 +660,7 @@ class CallInterceptorCompiler BASE_EMBEDDED {
FreeSpaceForFastApiCall(masm, scratch1);
}
return true;
return Heap::undefined_value(); // Success.
}
void CompileRegular(MacroAssembler* masm,
......@@ -1025,7 +1013,7 @@ void StubCompiler::GenerateLoadField(JSObject* object,
}
bool StubCompiler::GenerateLoadCallback(JSObject* object,
MaybeObject* StubCompiler::GenerateLoadCallback(JSObject* object,
JSObject* holder,
Register receiver,
Register name_reg,
......@@ -1034,8 +1022,7 @@ bool StubCompiler::GenerateLoadCallback(JSObject* object,
Register scratch3,
AccessorInfo* callback,
String* name,
Label* miss,
Failure** failure) {
Label* miss) {
// Check that the receiver isn't a smi.
__ JumpIfSmi(receiver, miss);
......@@ -1099,12 +1086,7 @@ bool StubCompiler::GenerateLoadCallback(JSObject* object,
// already generated). Do not allow the assembler to perform a
// garbage collection but instead return the allocation failure
// object.
MaybeObject* result = masm()->TryCallApiFunctionAndReturn(&fun, kStackSpace);
if (result->IsFailure()) {
*failure = Failure::cast(result);
return false;
}
return true;
return masm()->TryCallApiFunctionAndReturn(&fun, kStackSpace);
}
......@@ -2139,17 +2121,14 @@ MaybeObject* CallStubCompiler::CompileCallConstant(Object* object,
}
if (depth != kInvalidProtoDepth) {
Failure* failure;
// Move the return address on top of the stack.
__ movq(rax, Operand(rsp, 3 * kPointerSize));
__ movq(Operand(rsp, 0 * kPointerSize), rax);
// rsp[2 * kPointerSize] is uninitialized, rsp[3 * kPointerSize] contains
// duplicate of return address and will be overwritten.
bool success = GenerateFastApiCall(masm(), optimization, argc, &failure);
if (!success) {
return failure;
}
MaybeObject* result = GenerateFastApiCall(masm(), optimization, argc);
if (result->IsFailure()) return result;
} else {
__ InvokeFunction(function, arguments(), JUMP_FUNCTION);
}
......@@ -2198,8 +2177,7 @@ MaybeObject* CallStubCompiler::CompileCallInterceptor(JSObject* object,
__ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize));
CallInterceptorCompiler compiler(this, arguments(), rcx);
Failure* failure;
bool success = compiler.Compile(masm(),
MaybeObject* result = compiler.Compile(masm(),
object,
holder,
name,
......@@ -2208,11 +2186,8 @@ MaybeObject* CallStubCompiler::CompileCallInterceptor(JSObject* object,
rbx,
rdi,
rax,
&miss,
&failure);
if (!success) {
return failure;
}
&miss);
if (result->IsFailure()) return result;
// Restore receiver.
__ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize));
......@@ -2652,12 +2627,11 @@ MaybeObject* LoadStubCompiler::CompileLoadCallback(String* name,
// -----------------------------------
Label miss;
Failure* failure = Failure::InternalError();
bool success = GenerateLoadCallback(object, holder, rax, rcx, rdx, rbx, rdi,
callback, name, &miss, &failure);
if (!success) {
MaybeObject* result = GenerateLoadCallback(object, holder, rax, rcx, rdx, rbx,
rdi, callback, name, &miss);
if (result->IsFailure()) {
miss.Unuse();
return failure;
return result;
}
__ bind(&miss);
......@@ -2816,12 +2790,11 @@ MaybeObject* KeyedLoadStubCompiler::CompileLoadCallback(
__ Cmp(rax, Handle<String>(name));
__ j(not_equal, &miss);
Failure* failure = Failure::InternalError();
bool success = GenerateLoadCallback(receiver, holder, rdx, rax, rbx, rcx, rdi,
callback, name, &miss, &failure);
if (!success) {
MaybeObject* result = GenerateLoadCallback(receiver, holder, rdx, rax, rbx,
rcx, rdi, callback, name, &miss);
if (result->IsFailure()) {
miss.Unuse();
return failure;
return result;
}
__ bind(&miss);
......
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