Merge bleeding_edge revision 3501 to trunk. This change contains a
fix for a crash triggered by GC during generation of a callback inline
cache stub.
Review URL: http://codereview.chromium.org/508002
git-svn-id: http://v8.googlecode.com/svn/trunk@3502 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/src/ia32/macro-assembler-ia32.cc b/src/ia32/macro-assembler-ia32.cc
index ac2895e..fb34925 100644
--- a/src/ia32/macro-assembler-ia32.cc
+++ b/src/ia32/macro-assembler-ia32.cc
@@ -1072,6 +1072,12 @@
}
+Object* MacroAssembler::TryCallRuntime(Runtime::FunctionId id,
+ int num_arguments) {
+ return TryCallRuntime(Runtime::FunctionForId(id), num_arguments);
+}
+
+
void MacroAssembler::CallRuntime(Runtime::Function* f, int num_arguments) {
// If the expected number of arguments of the runtime function is
// constant, we check that the actual number of arguments match the
@@ -1088,6 +1094,22 @@
}
+Object* 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.
+ // Return some non-failure object.
+ return Heap::undefined_value();
+ }
+
+ Runtime::FunctionId function_id =
+ static_cast<Runtime::FunctionId>(f->stub_id);
+ RuntimeStub stub(function_id, num_arguments);
+ return TryCallStub(&stub);
+}
+
+
void MacroAssembler::TailCallRuntime(const ExternalReference& ext,
int num_arguments,
int result_size) {
@@ -1120,7 +1142,10 @@
}
-void MacroAssembler::PopHandleScope(Register saved, Register scratch) {
+Object* MacroAssembler::PopHandleScopeHelper(Register saved,
+ Register scratch,
+ bool gc_allowed) {
+ Object* result = NULL;
ExternalReference extensions_address =
ExternalReference::handle_scope_extensions_address();
Label write_back;
@@ -1130,7 +1155,12 @@
// Calling a runtime function messes with registers so we save and
// restore any one we're asked not to change
if (saved.is_valid()) push(saved);
- CallRuntime(Runtime::kDeleteHandleScopeExtensions, 0);
+ if (gc_allowed) {
+ CallRuntime(Runtime::kDeleteHandleScopeExtensions, 0);
+ } else {
+ result = TryCallRuntime(Runtime::kDeleteHandleScopeExtensions, 0);
+ if (result->IsFailure()) return result;
+ }
if (saved.is_valid()) pop(saved);
bind(&write_back);
@@ -1143,6 +1173,18 @@
pop(scratch);
shr(scratch, kSmiTagSize);
mov(Operand::StaticVariable(extensions_address), scratch);
+
+ return result;
+}
+
+
+void MacroAssembler::PopHandleScope(Register saved, Register scratch) {
+ PopHandleScopeHelper(saved, scratch, true);
+}
+
+
+Object* MacroAssembler::TryPopHandleScope(Register saved, Register scratch) {
+ return PopHandleScopeHelper(saved, scratch, false);
}