Update V8 to r5716 as required by WebKit r70949
Change-Id: I0d5cd05bb0427af33e5c9f6efdc209366a32bde3
diff --git a/src/x64/assembler-x64.cc b/src/x64/assembler-x64.cc
index 6e29b7a..bf5ee5b 100644
--- a/src/x64/assembler-x64.cc
+++ b/src/x64/assembler-x64.cc
@@ -118,9 +118,11 @@
CodeDesc desc;
assm.GetCode(&desc);
- Object* code = Heap::CreateCode(desc,
- Code::ComputeFlags(Code::STUB),
- Handle<Object>());
+ MaybeObject* maybe_code = Heap::CreateCode(desc,
+ Code::ComputeFlags(Code::STUB),
+ Handle<Object>());
+ Object* code;
+ if (!maybe_code->ToObject(&code)) return;
if (!code->IsCode()) return;
PROFILE(CodeCreateEvent(Logger::BUILTIN_TAG,
Code::cast(code), "CpuFeatures::Probe"));
diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc
index 2d87667..c179769 100644
--- a/src/x64/code-stubs-x64.cc
+++ b/src/x64/code-stubs-x64.cc
@@ -2484,11 +2484,7 @@
void ApiGetterEntryStub::Generate(MacroAssembler* masm) {
- Label empty_result;
- Label prologue;
- Label promote_scheduled_exception;
- __ EnterApiExitFrame(kStackSpace, 0);
- ASSERT_EQ(kArgc, 4);
+ __ PrepareCallApiFunction(kStackSpace);
#ifdef _WIN64
// All the parameters should be set up by a caller.
#else
@@ -2497,35 +2493,7 @@
// Second parameter register rdi should be set with pointer to AccessorInfo
// by a caller.
#endif
- // Call the api function!
- __ movq(rax,
- reinterpret_cast<int64_t>(fun()->address()),
- RelocInfo::RUNTIME_ENTRY);
- __ call(rax);
- // Check if the function scheduled an exception.
- ExternalReference scheduled_exception_address =
- ExternalReference::scheduled_exception_address();
- __ movq(rsi, scheduled_exception_address);
- __ Cmp(Operand(rsi, 0), Factory::the_hole_value());
- __ j(not_equal, &promote_scheduled_exception);
-#ifdef _WIN64
- // rax keeps a pointer to v8::Handle, unpack it.
- __ movq(rax, Operand(rax, 0));
-#endif
- // Check if the result handle holds 0.
- __ testq(rax, rax);
- __ j(zero, &empty_result);
- // It was non-zero. Dereference to get the result value.
- __ movq(rax, Operand(rax, 0));
- __ bind(&prologue);
- __ LeaveExitFrame();
- __ ret(0);
- __ bind(&promote_scheduled_exception);
- __ TailCallRuntime(Runtime::kPromoteScheduledException, 0, 1);
- __ bind(&empty_result);
- // It was zero; the result is undefined.
- __ Move(rax, Factory::undefined_value());
- __ jmp(&prologue);
+ __ CallApiFunctionAndReturn(fun());
}
diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc
index 2c946f5..293d8a5 100644
--- a/src/x64/macro-assembler-x64.cc
+++ b/src/x64/macro-assembler-x64.cc
@@ -315,11 +315,12 @@
}
-Object* MacroAssembler::TryCallStub(CodeStub* stub) {
+MaybeObject* MacroAssembler::TryCallStub(CodeStub* stub) {
ASSERT(allow_stub_calls()); // Calls are not allowed in some stubs.
- Object* result = stub->TryGetCode();
+ MaybeObject* result = stub->TryGetCode();
if (!result->IsFailure()) {
- call(Handle<Code>(Code::cast(result)), RelocInfo::CODE_TARGET);
+ call(Handle<Code>(Code::cast(result->ToObjectUnchecked())),
+ RelocInfo::CODE_TARGET);
}
return result;
}
@@ -331,11 +332,12 @@
}
-Object* MacroAssembler::TryTailCallStub(CodeStub* stub) {
+MaybeObject* MacroAssembler::TryTailCallStub(CodeStub* stub) {
ASSERT(allow_stub_calls()); // Calls are not allowed in some stubs.
- Object* result = stub->TryGetCode();
+ MaybeObject* result = stub->TryGetCode();
if (!result->IsFailure()) {
- jmp(Handle<Code>(Code::cast(result)), RelocInfo::CODE_TARGET);
+ jmp(Handle<Code>(Code::cast(result->ToObjectUnchecked())),
+ RelocInfo::CODE_TARGET);
}
return result;
}
@@ -379,8 +381,8 @@
}
-Object* MacroAssembler::TryCallRuntime(Runtime::FunctionId id,
- int num_arguments) {
+MaybeObject* MacroAssembler::TryCallRuntime(Runtime::FunctionId id,
+ int num_arguments) {
return TryCallRuntime(Runtime::FunctionForId(id), num_arguments);
}
@@ -405,8 +407,8 @@
}
-Object* MacroAssembler::TryCallRuntime(Runtime::Function* f,
- int num_arguments) {
+MaybeObject* MacroAssembler::TryCallRuntime(Runtime::Function* f,
+ int num_arguments) {
if (f->nargs >= 0 && f->nargs != num_arguments) {
IllegalOperation(num_arguments);
// Since we did not call the stub, there was no allocation failure.
@@ -469,76 +471,89 @@
}
-void MacroAssembler::PushHandleScope(Register scratch) {
- ExternalReference extensions_address =
- ExternalReference::handle_scope_extensions_address();
- const int kExtensionsOffset = 0;
- const int kNextOffset = Offset(
- ExternalReference::handle_scope_next_address(),
- extensions_address);
- const int kLimitOffset = Offset(
- ExternalReference::handle_scope_limit_address(),
- extensions_address);
-
- // Push the number of extensions, smi-tagged so the gc will ignore it.
- movq(kScratchRegister, extensions_address);
- movq(scratch, Operand(kScratchRegister, kExtensionsOffset));
- movq(Operand(kScratchRegister, kExtensionsOffset), Immediate(0));
- Integer32ToSmi(scratch, scratch);
- push(scratch);
- // Push next and limit pointers which will be wordsize aligned and
- // hence automatically smi tagged.
- push(Operand(kScratchRegister, kNextOffset));
- push(Operand(kScratchRegister, kLimitOffset));
+void MacroAssembler::PrepareCallApiFunction(int stack_space) {
+ EnterApiExitFrame(stack_space, 0);
}
-Object* MacroAssembler::PopHandleScopeHelper(Register saved,
- Register scratch,
- bool gc_allowed) {
- ExternalReference extensions_address =
- ExternalReference::handle_scope_extensions_address();
- const int kExtensionsOffset = 0;
- const int kNextOffset = Offset(
- ExternalReference::handle_scope_next_address(),
- extensions_address);
- const int kLimitOffset = Offset(
- ExternalReference::handle_scope_limit_address(),
- extensions_address);
-
- Object* result = NULL;
+void MacroAssembler::CallApiFunctionAndReturn(ApiFunction* function) {
+ Label empty_result;
+ Label prologue;
+ Label promote_scheduled_exception;
+ Label delete_allocated_handles;
+ Label leave_exit_frame;
Label write_back;
- movq(kScratchRegister, extensions_address);
- cmpq(Operand(kScratchRegister, kExtensionsOffset), Immediate(0));
- j(equal, &write_back);
- push(saved);
- if (gc_allowed) {
- CallRuntime(Runtime::kDeleteHandleScopeExtensions, 0);
- } else {
- result = TryCallRuntime(Runtime::kDeleteHandleScopeExtensions, 0);
- if (result->IsFailure()) return result;
- }
- pop(saved);
- movq(kScratchRegister, extensions_address);
- bind(&write_back);
- pop(Operand(kScratchRegister, kLimitOffset));
- pop(Operand(kScratchRegister, kNextOffset));
- pop(scratch);
- SmiToInteger32(scratch, scratch);
- movq(Operand(kScratchRegister, kExtensionsOffset), scratch);
+ ExternalReference next_address =
+ ExternalReference::handle_scope_next_address();
+ const int kNextOffset = 0;
+ const int kLimitOffset = Offset(
+ ExternalReference::handle_scope_limit_address(),
+ next_address);
+ const int kLevelOffset = Offset(
+ ExternalReference::handle_scope_level_address(),
+ next_address);
+ ExternalReference scheduled_exception_address =
+ ExternalReference::scheduled_exception_address();
- return result;
-}
+ // Allocate HandleScope in callee-save registers.
+ Register prev_next_address_reg = r14;
+ Register prev_limit_reg = rbx;
+ Register base_reg = kSmiConstantRegister;
+ movq(base_reg, next_address);
+ movq(prev_next_address_reg, Operand(base_reg, kNextOffset));
+ movq(prev_limit_reg, Operand(base_reg, kLimitOffset));
+ addl(Operand(base_reg, kLevelOffset), Immediate(1));
+ // Call the api function!
+ movq(rax,
+ reinterpret_cast<int64_t>(function->address()),
+ RelocInfo::RUNTIME_ENTRY);
+ call(rax);
+#ifdef _WIN64
+ // rax keeps a pointer to v8::Handle, unpack it.
+ movq(rax, Operand(rax, 0));
+#endif
+ // Check if the result handle holds 0.
+ testq(rax, rax);
+ j(zero, &empty_result);
+ // It was non-zero. Dereference to get the result value.
+ movq(rax, Operand(rax, 0));
+ bind(&prologue);
-void MacroAssembler::PopHandleScope(Register saved, Register scratch) {
- PopHandleScopeHelper(saved, scratch, true);
-}
+ // No more valid handles (the result handle was the last one). Restore
+ // previous handle scope.
+ subl(Operand(base_reg, kLevelOffset), Immediate(1));
+ movq(Operand(base_reg, kNextOffset), prev_next_address_reg);
+ cmpq(prev_limit_reg, Operand(base_reg, kLimitOffset));
+ j(not_equal, &delete_allocated_handles);
+ bind(&leave_exit_frame);
+ InitializeSmiConstantRegister();
+ // Check if the function scheduled an exception.
+ movq(rsi, scheduled_exception_address);
+ Cmp(Operand(rsi, 0), Factory::the_hole_value());
+ j(not_equal, &promote_scheduled_exception);
-Object* MacroAssembler::TryPopHandleScope(Register saved, Register scratch) {
- return PopHandleScopeHelper(saved, scratch, false);
+ LeaveExitFrame();
+ ret(0);
+
+ bind(&promote_scheduled_exception);
+ TailCallRuntime(Runtime::kPromoteScheduledException, 0, 1);
+
+ bind(&empty_result);
+ // It was zero; the result is undefined.
+ Move(rax, Factory::undefined_value());
+ jmp(&prologue);
+
+ // HandleScope limit has changed. Delete allocated extensions.
+ bind(&delete_allocated_handles);
+ movq(Operand(base_reg, kLimitOffset), prev_limit_reg);
+ movq(prev_limit_reg, rax);
+ movq(rax, ExternalReference::delete_handle_scope_extensions());
+ call(rax);
+ movq(rax, prev_limit_reg);
+ jmp(&leave_exit_frame);
}
@@ -1891,6 +1906,20 @@
Register scratch,
Label* gc_required,
AllocationFlags flags) {
+ if (!FLAG_inline_new) {
+ if (FLAG_debug_code) {
+ // Trash the registers to simulate an allocation failure.
+ movl(result, Immediate(0x7091));
+ if (result_end.is_valid()) {
+ movl(result_end, Immediate(0x7191));
+ }
+ if (scratch.is_valid()) {
+ movl(scratch, Immediate(0x7291));
+ }
+ }
+ jmp(gc_required);
+ return;
+ }
ASSERT(!result.is(result_end));
// Load address of new object into result.
@@ -1935,6 +1964,19 @@
Register scratch,
Label* gc_required,
AllocationFlags flags) {
+ if (!FLAG_inline_new) {
+ if (FLAG_debug_code) {
+ // Trash the registers to simulate an allocation failure.
+ movl(result, Immediate(0x7091));
+ movl(result_end, Immediate(0x7191));
+ if (scratch.is_valid()) {
+ movl(scratch, Immediate(0x7291));
+ }
+ // Register element_count is not modified by the function.
+ }
+ jmp(gc_required);
+ return;
+ }
ASSERT(!result.is(result_end));
// Load address of new object into result.
@@ -1964,6 +2006,21 @@
Register scratch,
Label* gc_required,
AllocationFlags flags) {
+ if (!FLAG_inline_new) {
+ if (FLAG_debug_code) {
+ // Trash the registers to simulate an allocation failure.
+ movl(result, Immediate(0x7091));
+ movl(result_end, Immediate(0x7191));
+ if (scratch.is_valid()) {
+ movl(scratch, Immediate(0x7291));
+ }
+ // object_size is left unchanged by this function.
+ }
+ jmp(gc_required);
+ return;
+ }
+ ASSERT(!result.is(result_end));
+
// Load address of new object into result.
LoadAllocationTopHelper(result, result_end, scratch, flags);
diff --git a/src/x64/macro-assembler-x64.h b/src/x64/macro-assembler-x64.h
index cb91067..2f6e956 100644
--- a/src/x64/macro-assembler-x64.h
+++ b/src/x64/macro-assembler-x64.h
@@ -773,7 +773,7 @@
// Call a code stub and return the code object called. Try to generate
// the code if necessary. Do not perform a GC but instead return a retry
// after GC failure.
- Object* TryCallStub(CodeStub* stub);
+ MUST_USE_RESULT MaybeObject* TryCallStub(CodeStub* stub);
// Tail call a code stub (jump).
void TailCallStub(CodeStub* stub);
@@ -781,7 +781,7 @@
// Tail call a code stub (jump) and return the code object called. Try to
// generate the code if necessary. Do not perform a GC but instead return
// a retry after GC failure.
- Object* TryTailCallStub(CodeStub* stub);
+ MUST_USE_RESULT MaybeObject* TryTailCallStub(CodeStub* stub);
// Return from a code stub after popping its arguments.
void StubReturn(int argc);
@@ -792,13 +792,15 @@
// Call a runtime function, returning the CodeStub object called.
// Try to generate the stub code if necessary. Do not perform a GC
// but instead return a retry after GC failure.
- Object* TryCallRuntime(Runtime::Function* f, int num_arguments);
+ MUST_USE_RESULT MaybeObject* TryCallRuntime(Runtime::Function* f,
+ int num_arguments);
// Convenience function: Same as above, but takes the fid instead.
void CallRuntime(Runtime::FunctionId id, int num_arguments);
// Convenience function: Same as above, but takes the fid instead.
- Object* TryCallRuntime(Runtime::FunctionId id, int num_arguments);
+ MUST_USE_RESULT MaybeObject* TryCallRuntime(Runtime::FunctionId id,
+ int num_arguments);
// Convenience function: call an external reference.
void CallExternalReference(const ExternalReference& ext,
@@ -816,19 +818,18 @@
int num_arguments,
int result_size);
- void PushHandleScope(Register scratch);
-
- // Pops a handle scope using the specified scratch register and
- // ensuring that saved register is left unchanged.
- void PopHandleScope(Register saved, Register scratch);
-
- // As PopHandleScope, but does not perform a GC. Instead, returns a
- // retry after GC failure object if GC is necessary.
- Object* TryPopHandleScope(Register saved, Register scratch);
-
// Jump to a runtime routine.
void JumpToExternalReference(const ExternalReference& ext, int result_size);
+ // Prepares stack to put arguments (aligns and so on).
+ // Uses calle-saved esi to restore stack state after call.
+ void PrepareCallApiFunction(int stack_space);
+
+ // Tail call an API function (jump). Allocates HandleScope, extracts
+ // returned value from handle and propogates exceptions.
+ // Clobbers ebx, edi and caller-save registers.
+ void CallApiFunctionAndReturn(ApiFunction* function);
+
// Before calling a C-function from generated code, align arguments on stack.
// After aligning the frame, arguments must be stored in esp[0], esp[4],
// etc., not pushed. The argument count assumes all arguments are word sized.
diff --git a/src/x64/regexp-macro-assembler-x64.cc b/src/x64/regexp-macro-assembler-x64.cc
index 47c19c7..2cf85f1 100644
--- a/src/x64/regexp-macro-assembler-x64.cc
+++ b/src/x64/regexp-macro-assembler-x64.cc
@@ -1169,7 +1169,7 @@
ASSERT(*return_address <=
re_code->instruction_start() + re_code->instruction_size());
- Object* result = Execution::HandleStackGuardInterrupt();
+ MaybeObject* result = Execution::HandleStackGuardInterrupt();
if (*code_handle != re_code) { // Return address no longer valid
intptr_t delta = *code_handle - re_code;
diff --git a/src/x64/simulator-x64.h b/src/x64/simulator-x64.h
index a0fc3cb..e607c8b 100644
--- a/src/x64/simulator-x64.h
+++ b/src/x64/simulator-x64.h
@@ -30,11 +30,22 @@
#include "allocation.h"
-// Since there is no simulator for the ia32 architecture the only thing we can
+namespace v8 {
+namespace internal {
+
+// Since there is no simulator for the x64 architecture the only thing we can
// do is to call the entry directly.
// TODO(X64): Don't pass p0, since it isn't used?
#define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \
- entry(p0, p1, p2, p3, p4);
+ (entry(p0, p1, p2, p3, p4))
+
+// Call the generated regexp code directly. The entry function pointer should
+// expect seven int/pointer sized arguments and return an int.
+#define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6) \
+ (entry(p0, p1, p2, p3, p4, p5, p6))
+
+#define TRY_CATCH_FROM_ADDRESS(try_catch_address) \
+ (reinterpret_cast<TryCatch*>(try_catch_address))
// The stack limit beyond which we will throw stack overflow errors in
// generated code. Because generated code on x64 uses the C stack, we
@@ -52,12 +63,6 @@
static inline void UnregisterCTryCatch() { }
};
-// Call the generated regexp code directly. The entry function pointer should
-// expect eight int/pointer sized arguments and return an int.
-#define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6) \
- entry(p0, p1, p2, p3, p4, p5, p6)
-
-#define TRY_CATCH_FROM_ADDRESS(try_catch_address) \
- reinterpret_cast<TryCatch*>(try_catch_address)
+} } // namespace v8::internal
#endif // V8_X64_SIMULATOR_X64_H_
diff --git a/src/x64/stub-cache-x64.cc b/src/x64/stub-cache-x64.cc
index eb48da9..3891e1d 100644
--- a/src/x64/stub-cache-x64.cc
+++ b/src/x64/stub-cache-x64.cc
@@ -796,13 +796,16 @@
// Generate code to check that a global property cell is empty. Create
// the property cell at compilation time if no cell exists for the
// property.
-static Object* GenerateCheckPropertyCell(MacroAssembler* masm,
- GlobalObject* global,
- String* name,
- Register scratch,
- Label* miss) {
- Object* probe = global->EnsurePropertyCell(name);
- if (probe->IsFailure()) return probe;
+MUST_USE_RESULT static MaybeObject* GenerateCheckPropertyCell(
+ MacroAssembler* masm,
+ GlobalObject* global,
+ String* name,
+ Register scratch,
+ Label* miss) {
+ Object* probe;
+ { MaybeObject* maybe_probe = global->EnsurePropertyCell(name);
+ if (!maybe_probe->ToObject(&probe)) return maybe_probe;
+ }
JSGlobalPropertyCell* cell = JSGlobalPropertyCell::cast(probe);
ASSERT(cell->value()->IsTheHole());
__ Move(scratch, Handle<Object>(cell));
@@ -879,19 +882,23 @@
}
-Object* CallStubCompiler::GenerateMissBranch() {
- Object* obj = StubCache::ComputeCallMiss(arguments().immediate(), kind_);
- if (obj->IsFailure()) return obj;
+MaybeObject* CallStubCompiler::GenerateMissBranch() {
+ Object* obj;
+ { MaybeObject* maybe_obj =
+ StubCache::ComputeCallMiss(arguments().immediate(), kind_);
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj;
+ }
__ Jump(Handle<Code>(Code::cast(obj)), RelocInfo::CODE_TARGET);
return obj;
}
-Object* CallStubCompiler::CompileCallConstant(Object* object,
- JSObject* holder,
- JSFunction* function,
- String* name,
- StubCompiler::CheckType check) {
+MaybeObject* CallStubCompiler::CompileCallConstant(
+ Object* object,
+ JSObject* holder,
+ JSFunction* function,
+ String* name,
+ StubCompiler::CheckType check) {
// ----------- S t a t e -------------
// rcx : function name
// rsp[0] : return address
@@ -905,8 +912,10 @@
SharedFunctionInfo* function_info = function->shared();
if (function_info->HasCustomCallGenerator()) {
const int id = function_info->custom_call_generator_id();
- Object* result = CompileCustomCall(
+ MaybeObject* maybe_result = CompileCustomCall(
id, object, holder, NULL, function, name);
+ Object* result;
+ if (!maybe_result->ToObject(&result)) return maybe_result;
// undefined means bail out to regular compiler.
if (!result->IsUndefined()) return result;
}
@@ -1034,18 +1043,20 @@
// Handle call cache miss.
__ bind(&miss_in_smi_check);
- Object* obj = GenerateMissBranch();
- if (obj->IsFailure()) return obj;
+ Object* obj;
+ { MaybeObject* maybe_obj = GenerateMissBranch();
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj;
+ }
// Return the generated code.
return GetCode(function);
}
-Object* CallStubCompiler::CompileCallField(JSObject* object,
- JSObject* holder,
- int index,
- String* name) {
+MaybeObject* CallStubCompiler::CompileCallField(JSObject* object,
+ JSObject* holder,
+ int index,
+ String* name) {
// ----------- S t a t e -------------
// rcx : function name
// rsp[0] : return address
@@ -1089,19 +1100,21 @@
// Handle call cache miss.
__ bind(&miss);
- Object* obj = GenerateMissBranch();
- if (obj->IsFailure()) return obj;
+ Object* obj;
+ { MaybeObject* maybe_obj = GenerateMissBranch();
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj;
+ }
// Return the generated code.
return GetCode(FIELD, name);
}
-Object* CallStubCompiler::CompileArrayPushCall(Object* object,
- JSObject* holder,
- JSGlobalPropertyCell* cell,
- JSFunction* function,
- String* name) {
+MaybeObject* CallStubCompiler::CompileArrayPushCall(Object* object,
+ JSObject* holder,
+ JSGlobalPropertyCell* cell,
+ JSFunction* function,
+ String* name) {
// ----------- S t a t e -------------
// -- rcx : name
// -- rsp[0] : return address
@@ -1191,6 +1204,10 @@
__ ret((argc + 1) * kPointerSize);
__ bind(&attempt_to_grow_elements);
+ if (!FLAG_inline_new) {
+ __ jmp(&call_builtin);
+ }
+
ExternalReference new_space_allocation_top =
ExternalReference::new_space_allocation_top_address();
ExternalReference new_space_allocation_limit =
@@ -1247,19 +1264,21 @@
}
__ bind(&miss);
- Object* obj = GenerateMissBranch();
- if (obj->IsFailure()) return obj;
+ Object* obj;
+ { MaybeObject* maybe_obj = GenerateMissBranch();
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj;
+ }
// Return the generated code.
return GetCode(function);
}
-Object* CallStubCompiler::CompileArrayPopCall(Object* object,
- JSObject* holder,
- JSGlobalPropertyCell* cell,
- JSFunction* function,
- String* name) {
+MaybeObject* CallStubCompiler::CompileArrayPopCall(Object* object,
+ JSObject* holder,
+ JSGlobalPropertyCell* cell,
+ JSFunction* function,
+ String* name) {
// ----------- S t a t e -------------
// -- rcx : name
// -- rsp[0] : return address
@@ -1329,19 +1348,22 @@
1);
__ bind(&miss);
- Object* obj = GenerateMissBranch();
- if (obj->IsFailure()) return obj;
+ Object* obj;
+ { MaybeObject* maybe_obj = GenerateMissBranch();
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj;
+ }
// Return the generated code.
return GetCode(function);
}
-Object* CallStubCompiler::CompileStringCharAtCall(Object* object,
- JSObject* holder,
- JSGlobalPropertyCell* cell,
- JSFunction* function,
- String* name) {
+MaybeObject* CallStubCompiler::CompileStringCharAtCall(
+ Object* object,
+ JSObject* holder,
+ JSGlobalPropertyCell* cell,
+ JSFunction* function,
+ String* name) {
// ----------- S t a t e -------------
// -- rcx : function name
// -- rsp[0] : return address
@@ -1401,15 +1423,17 @@
__ ret((argc + 1) * kPointerSize);
__ bind(&miss);
- Object* obj = GenerateMissBranch();
- if (obj->IsFailure()) return obj;
+ Object* obj;
+ { MaybeObject* maybe_obj = GenerateMissBranch();
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj;
+ }
// Return the generated code.
return GetCode(function);
}
-Object* CallStubCompiler::CompileStringCharCodeAtCall(
+MaybeObject* CallStubCompiler::CompileStringCharCodeAtCall(
Object* object,
JSObject* holder,
JSGlobalPropertyCell* cell,
@@ -1471,15 +1495,17 @@
__ ret((argc + 1) * kPointerSize);
__ bind(&miss);
- Object* obj = GenerateMissBranch();
- if (obj->IsFailure()) return obj;
+ Object* obj;
+ { MaybeObject* maybe_obj = GenerateMissBranch();
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj;
+ }
// Return the generated code.
return GetCode(function);
}
-Object* CallStubCompiler::CompileStringFromCharCodeCall(
+MaybeObject* CallStubCompiler::CompileStringFromCharCodeCall(
Object* object,
JSObject* holder,
JSGlobalPropertyCell* cell,
@@ -1540,29 +1566,31 @@
__ bind(&miss);
// rcx: function name.
- Object* obj = GenerateMissBranch();
- if (obj->IsFailure()) return obj;
+ Object* obj;
+ { MaybeObject* maybe_obj = GenerateMissBranch();
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj;
+ }
// Return the generated code.
return (cell == NULL) ? GetCode(function) : GetCode(NORMAL, name);
}
-Object* CallStubCompiler::CompileMathFloorCall(Object* object,
- JSObject* holder,
- JSGlobalPropertyCell* cell,
- JSFunction* function,
- String* name) {
+MaybeObject* CallStubCompiler::CompileMathFloorCall(Object* object,
+ JSObject* holder,
+ JSGlobalPropertyCell* cell,
+ JSFunction* function,
+ String* name) {
// TODO(872): implement this.
return Heap::undefined_value();
}
-Object* CallStubCompiler::CompileMathAbsCall(Object* object,
- JSObject* holder,
- JSGlobalPropertyCell* cell,
- JSFunction* function,
- String* name) {
+MaybeObject* CallStubCompiler::CompileMathAbsCall(Object* object,
+ JSObject* holder,
+ JSGlobalPropertyCell* cell,
+ JSFunction* function,
+ String* name) {
// ----------- S t a t e -------------
// -- rcx : function name
// -- rsp[0] : return address
@@ -1653,17 +1681,19 @@
__ bind(&miss);
// rcx: function name.
- Object* obj = GenerateMissBranch();
- if (obj->IsFailure()) return obj;
+ Object* obj;
+ { MaybeObject* maybe_obj = GenerateMissBranch();
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj;
+ }
// Return the generated code.
return (cell == NULL) ? GetCode(function) : GetCode(NORMAL, name);
}
-Object* CallStubCompiler::CompileCallInterceptor(JSObject* object,
- JSObject* holder,
- String* name) {
+MaybeObject* CallStubCompiler::CompileCallInterceptor(JSObject* object,
+ JSObject* holder,
+ String* name) {
// ----------- S t a t e -------------
// rcx : function name
// rsp[0] : return address
@@ -1719,19 +1749,21 @@
// Handle load cache miss.
__ bind(&miss);
- Object* obj = GenerateMissBranch();
- if (obj->IsFailure()) return obj;
+ Object* obj;
+ { MaybeObject* maybe_obj = GenerateMissBranch();
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj;
+ }
// Return the generated code.
return GetCode(INTERCEPTOR, name);
}
-Object* CallStubCompiler::CompileCallGlobal(JSObject* object,
- GlobalObject* holder,
- JSGlobalPropertyCell* cell,
- JSFunction* function,
- String* name) {
+MaybeObject* CallStubCompiler::CompileCallGlobal(JSObject* object,
+ GlobalObject* holder,
+ JSGlobalPropertyCell* cell,
+ JSFunction* function,
+ String* name) {
// ----------- S t a t e -------------
// rcx : function name
// rsp[0] : return address
@@ -1745,8 +1777,10 @@
SharedFunctionInfo* function_info = function->shared();
if (function_info->HasCustomCallGenerator()) {
const int id = function_info->custom_call_generator_id();
- Object* result = CompileCustomCall(
+ MaybeObject* maybe_result = CompileCustomCall(
id, object, holder, cell, function, name);
+ Object* result;
+ if (!maybe_result->ToObject(&result)) return maybe_result;
// undefined means bail out to regular compiler.
if (!result->IsUndefined()) return result;
}
@@ -1782,18 +1816,20 @@
// Handle call cache miss.
__ bind(&miss);
__ IncrementCounter(&Counters::call_global_inline_miss, 1);
- Object* obj = GenerateMissBranch();
- if (obj->IsFailure()) return obj;
+ Object* obj;
+ { MaybeObject* maybe_obj = GenerateMissBranch();
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj;
+ }
// Return the generated code.
return GetCode(NORMAL, name);
}
-Object* LoadStubCompiler::CompileLoadCallback(String* name,
- JSObject* object,
- JSObject* holder,
- AccessorInfo* callback) {
+MaybeObject* LoadStubCompiler::CompileLoadCallback(String* name,
+ JSObject* object,
+ JSObject* holder,
+ AccessorInfo* callback) {
// ----------- S t a t e -------------
// -- rax : receiver
// -- rcx : name
@@ -1817,10 +1853,10 @@
}
-Object* LoadStubCompiler::CompileLoadConstant(JSObject* object,
- JSObject* holder,
- Object* value,
- String* name) {
+MaybeObject* LoadStubCompiler::CompileLoadConstant(JSObject* object,
+ JSObject* holder,
+ Object* value,
+ String* name) {
// ----------- S t a t e -------------
// -- rax : receiver
// -- rcx : name
@@ -1837,9 +1873,9 @@
}
-Object* LoadStubCompiler::CompileLoadNonexistent(String* name,
- JSObject* object,
- JSObject* last) {
+MaybeObject* LoadStubCompiler::CompileLoadNonexistent(String* name,
+ JSObject* object,
+ JSObject* last) {
// ----------- S t a t e -------------
// -- rax : receiver
// -- rcx : name
@@ -1858,11 +1894,11 @@
// If the last object in the prototype chain is a global object,
// check that the global property cell is empty.
if (last->IsGlobalObject()) {
- Object* cell = GenerateCheckPropertyCell(masm(),
- GlobalObject::cast(last),
- name,
- rdx,
- &miss);
+ MaybeObject* cell = GenerateCheckPropertyCell(masm(),
+ GlobalObject::cast(last),
+ name,
+ rdx,
+ &miss);
if (cell->IsFailure()) {
miss.Unuse();
return cell;
@@ -1882,10 +1918,10 @@
}
-Object* LoadStubCompiler::CompileLoadField(JSObject* object,
- JSObject* holder,
- int index,
- String* name) {
+MaybeObject* LoadStubCompiler::CompileLoadField(JSObject* object,
+ JSObject* holder,
+ int index,
+ String* name) {
// ----------- S t a t e -------------
// -- rax : receiver
// -- rcx : name
@@ -1902,9 +1938,9 @@
}
-Object* LoadStubCompiler::CompileLoadInterceptor(JSObject* receiver,
- JSObject* holder,
- String* name) {
+MaybeObject* LoadStubCompiler::CompileLoadInterceptor(JSObject* receiver,
+ JSObject* holder,
+ String* name) {
// ----------- S t a t e -------------
// -- rax : receiver
// -- rcx : name
@@ -1936,11 +1972,11 @@
}
-Object* LoadStubCompiler::CompileLoadGlobal(JSObject* object,
- GlobalObject* holder,
- JSGlobalPropertyCell* cell,
- String* name,
- bool is_dont_delete) {
+MaybeObject* LoadStubCompiler::CompileLoadGlobal(JSObject* object,
+ GlobalObject* holder,
+ JSGlobalPropertyCell* cell,
+ String* name,
+ bool is_dont_delete) {
// ----------- S t a t e -------------
// -- rax : receiver
// -- rcx : name
@@ -1984,10 +2020,11 @@
}
-Object* KeyedLoadStubCompiler::CompileLoadCallback(String* name,
- JSObject* receiver,
- JSObject* holder,
- AccessorInfo* callback) {
+MaybeObject* KeyedLoadStubCompiler::CompileLoadCallback(
+ String* name,
+ JSObject* receiver,
+ JSObject* holder,
+ AccessorInfo* callback) {
// ----------- S t a t e -------------
// -- rax : key
// -- rdx : receiver
@@ -2018,7 +2055,7 @@
}
-Object* KeyedLoadStubCompiler::CompileLoadArrayLength(String* name) {
+MaybeObject* KeyedLoadStubCompiler::CompileLoadArrayLength(String* name) {
// ----------- S t a t e -------------
// -- rax : key
// -- rdx : receiver
@@ -2042,10 +2079,10 @@
}
-Object* KeyedLoadStubCompiler::CompileLoadConstant(String* name,
- JSObject* receiver,
- JSObject* holder,
- Object* value) {
+MaybeObject* KeyedLoadStubCompiler::CompileLoadConstant(String* name,
+ JSObject* receiver,
+ JSObject* holder,
+ Object* value) {
// ----------- S t a t e -------------
// -- rax : key
// -- rdx : receiver
@@ -2070,7 +2107,7 @@
}
-Object* KeyedLoadStubCompiler::CompileLoadFunctionPrototype(String* name) {
+MaybeObject* KeyedLoadStubCompiler::CompileLoadFunctionPrototype(String* name) {
// ----------- S t a t e -------------
// -- rax : key
// -- rdx : receiver
@@ -2094,9 +2131,9 @@
}
-Object* KeyedLoadStubCompiler::CompileLoadInterceptor(JSObject* receiver,
- JSObject* holder,
- String* name) {
+MaybeObject* KeyedLoadStubCompiler::CompileLoadInterceptor(JSObject* receiver,
+ JSObject* holder,
+ String* name) {
// ----------- S t a t e -------------
// -- rax : key
// -- rdx : receiver
@@ -2131,7 +2168,7 @@
}
-Object* KeyedLoadStubCompiler::CompileLoadStringLength(String* name) {
+MaybeObject* KeyedLoadStubCompiler::CompileLoadStringLength(String* name) {
// ----------- S t a t e -------------
// -- rax : key
// -- rdx : receiver
@@ -2155,9 +2192,9 @@
}
-Object* StoreStubCompiler::CompileStoreCallback(JSObject* object,
- AccessorInfo* callback,
- String* name) {
+MaybeObject* StoreStubCompiler::CompileStoreCallback(JSObject* object,
+ AccessorInfo* callback,
+ String* name) {
// ----------- S t a t e -------------
// -- rax : value
// -- rcx : name
@@ -2205,10 +2242,10 @@
}
-Object* StoreStubCompiler::CompileStoreField(JSObject* object,
- int index,
- Map* transition,
- String* name) {
+MaybeObject* StoreStubCompiler::CompileStoreField(JSObject* object,
+ int index,
+ Map* transition,
+ String* name) {
// ----------- S t a t e -------------
// -- rax : value
// -- rcx : name
@@ -2235,8 +2272,8 @@
}
-Object* StoreStubCompiler::CompileStoreInterceptor(JSObject* receiver,
- String* name) {
+MaybeObject* StoreStubCompiler::CompileStoreInterceptor(JSObject* receiver,
+ String* name) {
// ----------- S t a t e -------------
// -- rax : value
// -- rcx : name
@@ -2283,9 +2320,9 @@
}
-Object* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object,
- JSGlobalPropertyCell* cell,
- String* name) {
+MaybeObject* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object,
+ JSGlobalPropertyCell* cell,
+ String* name) {
// ----------- S t a t e -------------
// -- rax : value
// -- rcx : name
@@ -2318,10 +2355,10 @@
}
-Object* KeyedLoadStubCompiler::CompileLoadField(String* name,
- JSObject* receiver,
- JSObject* holder,
- int index) {
+MaybeObject* KeyedLoadStubCompiler::CompileLoadField(String* name,
+ JSObject* receiver,
+ JSObject* holder,
+ int index) {
// ----------- S t a t e -------------
// -- rax : key
// -- rdx : receiver
@@ -2346,10 +2383,10 @@
}
-Object* KeyedStoreStubCompiler::CompileStoreField(JSObject* object,
- int index,
- Map* transition,
- String* name) {
+MaybeObject* KeyedStoreStubCompiler::CompileStoreField(JSObject* object,
+ int index,
+ Map* transition,
+ String* name) {
// ----------- S t a t e -------------
// -- rax : value
// -- rcx : key
@@ -2543,7 +2580,6 @@
Handle<AccessorInfo> callback_handle(callback);
__ EnterInternalFrame();
- __ PushHandleScope(scratch2);
// Push the stack address where the list of arguments ends.
__ movq(scratch2, rsp);
__ subq(scratch2, Immediate(2 * kPointerSize));
@@ -2588,7 +2624,7 @@
// already generated). Do not allow the assembler to perform a
// garbage collection but instead return the allocation failure
// object.
- Object* result = masm()->TryCallStub(&stub);
+ MaybeObject* result = masm()->TryCallStub(&stub);
if (result->IsFailure()) {
*failure = Failure::cast(result);
return false;
@@ -2597,17 +2633,6 @@
// Discard allocated slot.
__ addq(rsp, Immediate(kPointerSize));
#endif
-
- // We need to avoid using rax since that now holds the result.
- Register tmp = scratch2.is(rax) ? reg : scratch2;
- // Emitting PopHandleScope may try to allocate. Do not allow the
- // assembler to perform a garbage collection but instead return a
- // failure object.
- result = masm()->TryPopHandleScope(rax, tmp);
- if (result->IsFailure()) {
- *failure = Failure::cast(result);
- return false;
- }
__ LeaveInternalFrame();
__ ret(0);
@@ -2655,12 +2680,12 @@
!current->IsJSGlobalObject() &&
!current->IsJSGlobalProxy()) {
if (!name->IsSymbol()) {
- Object* lookup_result = Heap::LookupSymbol(name);
+ MaybeObject* lookup_result = Heap::LookupSymbol(name);
if (lookup_result->IsFailure()) {
set_failure(Failure::cast(lookup_result));
return reg;
} else {
- name = String::cast(lookup_result);
+ name = String::cast(lookup_result->ToObjectUnchecked());
}
}
ASSERT(current->property_dictionary()->FindEntry(name) ==
@@ -2742,11 +2767,11 @@
current = object;
while (current != holder) {
if (current->IsGlobalObject()) {
- Object* cell = GenerateCheckPropertyCell(masm(),
- GlobalObject::cast(current),
- name,
- scratch1,
- miss);
+ MaybeObject* cell = GenerateCheckPropertyCell(masm(),
+ GlobalObject::cast(current),
+ name,
+ scratch1,
+ miss);
if (cell->IsFailure()) {
set_failure(Failure::cast(cell));
return reg;
@@ -2808,7 +2833,7 @@
// Specialized stub for constructing objects from functions which only have only
// simple assignments of the form this.x = ...; in their body.
-Object* ConstructStubCompiler::CompileConstructStub(
+MaybeObject* ConstructStubCompiler::CompileConstructStub(
SharedFunctionInfo* shared) {
// ----------- S t a t e -------------
// -- rax : argc