Commit 3ee07836 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Correctly OOM in the CEntryStub after retries.

This fixes a bug introduced in r20179.

R=jkummerow@chromium.org
BUG=356211
LOG=N

Review URL: https://codereview.chromium.org/213193011

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20292 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 75e4fa30
...@@ -1685,6 +1685,12 @@ void CEntryStub::Generate(MacroAssembler* masm) { ...@@ -1685,6 +1685,12 @@ void CEntryStub::Generate(MacroAssembler* masm) {
true, true,
true); true);
{ FrameScope scope(masm, StackFrame::MANUAL);
__ PrepareCallCFunction(0, r0);
__ CallCFunction(
ExternalReference::out_of_memory_function(masm->isolate()), 0, 0);
}
__ bind(&throw_termination_exception); __ bind(&throw_termination_exception);
__ ThrowUncatchable(r0); __ ThrowUncatchable(r0);
......
...@@ -1764,6 +1764,11 @@ void CEntryStub::Generate(MacroAssembler* masm) { ...@@ -1764,6 +1764,11 @@ void CEntryStub::Generate(MacroAssembler* masm) {
} }
__ SetStackPointer(jssp); __ SetStackPointer(jssp);
{ FrameScope scope(masm, StackFrame::MANUAL);
__ CallCFunction(
ExternalReference::out_of_memory_function(masm->isolate()), 0, 0);
}
// Throw exceptions. // Throw exceptions.
// If we throw an exception, we can end up re-entering CEntryStub before we // If we throw an exception, we can end up re-entering CEntryStub before we
// pop the exit frame, so need to ensure that x21-x23 contain GC-safe values // pop the exit frame, so need to ensure that x21-x23 contain GC-safe values
......
...@@ -1059,6 +1059,12 @@ ExternalReference ExternalReference::perform_gc_function(Isolate* isolate) { ...@@ -1059,6 +1059,12 @@ ExternalReference ExternalReference::perform_gc_function(Isolate* isolate) {
} }
ExternalReference ExternalReference::out_of_memory_function(Isolate* isolate) {
return
ExternalReference(Redirect(isolate, FUNCTION_ADDR(Runtime::OutOfMemory)));
}
ExternalReference ExternalReference::delete_handle_scope_extensions( ExternalReference ExternalReference::delete_handle_scope_extensions(
Isolate* isolate) { Isolate* isolate) {
return ExternalReference(Redirect( return ExternalReference(Redirect(
......
...@@ -748,6 +748,7 @@ class ExternalReference BASE_EMBEDDED { ...@@ -748,6 +748,7 @@ class ExternalReference BASE_EMBEDDED {
Isolate* isolate); Isolate* isolate);
static ExternalReference flush_icache_function(Isolate* isolate); static ExternalReference flush_icache_function(Isolate* isolate);
static ExternalReference perform_gc_function(Isolate* isolate); static ExternalReference perform_gc_function(Isolate* isolate);
static ExternalReference out_of_memory_function(Isolate* isolate);
static ExternalReference delete_handle_scope_extensions(Isolate* isolate); static ExternalReference delete_handle_scope_extensions(Isolate* isolate);
static ExternalReference get_date_field_function(Isolate* isolate); static ExternalReference get_date_field_function(Isolate* isolate);
......
...@@ -2751,6 +2751,12 @@ void CEntryStub::Generate(MacroAssembler* masm) { ...@@ -2751,6 +2751,12 @@ void CEntryStub::Generate(MacroAssembler* masm) {
true, true,
true); true);
{ FrameScope scope(masm, StackFrame::MANUAL);
__ PrepareCallCFunction(0, eax);
__ CallCFunction(
ExternalReference::out_of_memory_function(masm->isolate()), 0);
}
__ bind(&throw_termination_exception); __ bind(&throw_termination_exception);
__ ThrowUncatchable(eax); __ ThrowUncatchable(eax);
......
...@@ -1794,6 +1794,12 @@ void CEntryStub::Generate(MacroAssembler* masm) { ...@@ -1794,6 +1794,12 @@ void CEntryStub::Generate(MacroAssembler* masm) {
true, true,
true); true);
{ FrameScope scope(masm, StackFrame::MANUAL);
__ PrepareCallCFunction(0, v0);
__ CallCFunction(
ExternalReference::out_of_memory_function(masm->isolate()), 0);
}
__ bind(&throw_termination_exception); __ bind(&throw_termination_exception);
__ ThrowUncatchable(v0); __ ThrowUncatchable(v0);
......
...@@ -15175,4 +15175,9 @@ void Runtime::PerformGC(Object* result, Isolate* isolate) { ...@@ -15175,4 +15175,9 @@ void Runtime::PerformGC(Object* result, Isolate* isolate) {
} }
void Runtime::OutOfMemory() {
Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true);
UNREACHABLE();
}
} } // namespace v8::internal } } // namespace v8::internal
...@@ -895,6 +895,7 @@ class Runtime : public AllStatic { ...@@ -895,6 +895,7 @@ class Runtime : public AllStatic {
// Helper functions used stubs. // Helper functions used stubs.
static void PerformGC(Object* result, Isolate* isolate); static void PerformGC(Object* result, Isolate* isolate);
static void OutOfMemory();
// Used in runtime.cc and hydrogen's VisitArrayLiteral. // Used in runtime.cc and hydrogen's VisitArrayLiteral.
static Handle<Object> CreateArrayLiteralBoilerplate( static Handle<Object> CreateArrayLiteralBoilerplate(
......
...@@ -313,6 +313,11 @@ void ExternalReferenceTable::PopulateTable(Isolate* isolate) { ...@@ -313,6 +313,11 @@ void ExternalReferenceTable::PopulateTable(Isolate* isolate) {
RUNTIME_ENTRY, RUNTIME_ENTRY,
1, 1,
"Runtime::PerformGC"); "Runtime::PerformGC");
// Runtime entries
Add(ExternalReference::out_of_memory_function(isolate).address(),
RUNTIME_ENTRY,
2,
"Runtime::OutOfMemory");
Add(ExternalReference::delete_handle_scope_extensions(isolate).address(), Add(ExternalReference::delete_handle_scope_extensions(isolate).address(),
RUNTIME_ENTRY, RUNTIME_ENTRY,
4, 4,
......
...@@ -2603,6 +2603,12 @@ void CEntryStub::Generate(MacroAssembler* masm) { ...@@ -2603,6 +2603,12 @@ void CEntryStub::Generate(MacroAssembler* masm) {
true, true,
true); true);
{ FrameScope scope(masm, StackFrame::MANUAL);
__ PrepareCallCFunction(0);
__ CallCFunction(
ExternalReference::out_of_memory_function(masm->isolate()), 0);
}
__ bind(&throw_termination_exception); __ bind(&throw_termination_exception);
__ ThrowUncatchable(rax); __ ThrowUncatchable(rax);
......
...@@ -3889,4 +3889,28 @@ TEST(AddInstructionChangesNewSpacePromotion) { ...@@ -3889,4 +3889,28 @@ TEST(AddInstructionChangesNewSpacePromotion) {
g->Call(global, 1, args1); g->Call(global, 1, args1);
heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
} }
#endif
void OnFatalErrorExpectOOM(const char* location, const char* message) {
// Exit with 0 if the location matches our expectation.
exit(strcmp(location, "CALL_AND_RETRY_LAST"));
}
TEST(CEntryStubOOM) {
i::FLAG_allow_natives_syntax = true;
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::V8::SetFatalErrorHandler(OnFatalErrorExpectOOM);
CompileRun(
"%SetFlags('--gc-interval=1');"
"var a = [];"
"a.__proto__ = [];"
"a.unshift(1)");
// We should have run into an out of memory.
UNREACHABLE();
}
#endif // DEBUG
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