Roll V8 back to 3.6
Roll back to V8 3.6 to fix x86 build, we don't have ucontext.h.
This reverts commits:
5d4cdbf7a67d3662fa0bee4efdb7edd8daec9b0b
c7cc028aaeedbbfa11c11d0b7b243b3d9e837ed9
592a9fc1d8ea420377a2e7efd0600e20b058be2b
Bug: 5688872
Change-Id: Ic961bb5e65b778e98bbfb71cce71d99fa949e995
diff --git a/src/execution.cc b/src/execution.cc
index 5618975..f36d4e4 100644
--- a/src/execution.cc
+++ b/src/execution.cc
@@ -1,4 +1,4 @@
-// Copyright 2012 the V8 project authors. All rights reserved.
+// Copyright 2011 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -33,7 +33,6 @@
#include "bootstrapper.h"
#include "codegen.h"
#include "debug.h"
-#include "isolate-inl.h"
#include "runtime-profiler.h"
#include "simulator.h"
#include "v8threads.h"
@@ -66,13 +65,13 @@
}
-static Handle<Object> Invoke(bool is_construct,
- Handle<JSFunction> function,
+static Handle<Object> Invoke(bool construct,
+ Handle<JSFunction> func,
Handle<Object> receiver,
int argc,
- Handle<Object> args[],
+ Object*** args,
bool* has_pending_exception) {
- Isolate* isolate = function->GetIsolate();
+ Isolate* isolate = func->GetIsolate();
// Entering JavaScript.
VMState state(isolate, JS);
@@ -80,15 +79,21 @@
// Placeholder for return value.
MaybeObject* value = reinterpret_cast<Object*>(kZapValue);
- typedef Object* (*JSEntryFunction)(byte* entry,
- Object* function,
- Object* receiver,
- int argc,
- Object*** args);
+ typedef Object* (*JSEntryFunction)(
+ byte* entry,
+ Object* function,
+ Object* receiver,
+ int argc,
+ Object*** args);
- Handle<Code> code = is_construct
- ? isolate->factory()->js_construct_entry_code()
- : isolate->factory()->js_entry_code();
+ Handle<Code> code;
+ if (construct) {
+ JSConstructEntryStub stub;
+ code = stub.GetCode();
+ } else {
+ JSEntryStub stub;
+ code = stub.GetCode();
+ }
// Convert calls on global objects to be calls on the global
// receiver instead to avoid having a 'this' pointer which refers
@@ -100,22 +105,21 @@
// Make sure that the global object of the context we're about to
// make the current one is indeed a global object.
- ASSERT(function->context()->global()->IsGlobalObject());
+ ASSERT(func->context()->global()->IsGlobalObject());
{
// Save and restore context around invocation and block the
// allocation of handles without explicit handle scopes.
SaveContext save(isolate);
NoHandleAllocation na;
- JSEntryFunction stub_entry = FUNCTION_CAST<JSEntryFunction>(code->entry());
+ JSEntryFunction entry = FUNCTION_CAST<JSEntryFunction>(code->entry());
// Call the function through the right JS entry stub.
- byte* function_entry = function->code()->entry();
- JSFunction* func = *function;
- Object* recv = *receiver;
- Object*** argv = reinterpret_cast<Object***>(args);
- value =
- CALL_GENERATED_CODE(stub_entry, function_entry, func, recv, argc, argv);
+ byte* entry_address = func->code()->entry();
+ JSFunction* function = *func;
+ Object* receiver_pointer = *receiver;
+ value = CALL_GENERATED_CODE(entry, entry_address, function,
+ receiver_pointer, argc, args);
}
#ifdef DEBUG
@@ -144,11 +148,9 @@
Handle<Object> Execution::Call(Handle<Object> callable,
Handle<Object> receiver,
int argc,
- Handle<Object> argv[],
+ Object*** args,
bool* pending_exception,
bool convert_receiver) {
- *pending_exception = false;
-
if (!callable->IsJSFunction()) {
callable = TryGetFunctionDelegate(callable, pending_exception);
if (*pending_exception) return callable;
@@ -157,7 +159,7 @@
// In non-strict mode, convert receiver.
if (convert_receiver && !receiver->IsJSReceiver() &&
- !func->shared()->native() && func->shared()->is_classic_mode()) {
+ !func->shared()->native() && !func->shared()->strict_mode()) {
if (receiver->IsUndefined() || receiver->IsNull()) {
Object* global = func->context()->global()->global_receiver();
// Under some circumstances, 'global' can be the JSBuiltinsObject
@@ -170,15 +172,13 @@
if (*pending_exception) return callable;
}
- return Invoke(false, func, receiver, argc, argv, pending_exception);
+ return Invoke(false, func, receiver, argc, args, pending_exception);
}
-Handle<Object> Execution::New(Handle<JSFunction> func,
- int argc,
- Handle<Object> argv[],
- bool* pending_exception) {
- return Invoke(true, func, Isolate::Current()->global(), argc, argv,
+Handle<Object> Execution::New(Handle<JSFunction> func, int argc,
+ Object*** args, bool* pending_exception) {
+ return Invoke(true, func, Isolate::Current()->global(), argc, args,
pending_exception);
}
@@ -186,7 +186,7 @@
Handle<Object> Execution::TryCall(Handle<JSFunction> func,
Handle<Object> receiver,
int argc,
- Handle<Object> args[],
+ Object*** args,
bool* caught_exception) {
// Enter a try-block while executing the JavaScript code. To avoid
// duplicate error printing it must be non-verbose. Also, to avoid
@@ -195,7 +195,6 @@
v8::TryCatch catcher;
catcher.SetVerbose(false);
catcher.SetCaptureMessage(false);
- *caught_exception = false;
Handle<Object> result = Invoke(false, func, receiver, argc, args,
caught_exception);
@@ -356,7 +355,7 @@
void StackGuard::SetStackLimit(uintptr_t limit) {
ExecutionAccess access(isolate_);
- // If the current limits are special (e.g. due to a pending interrupt) then
+ // If the current limits are special (eg due to a pending interrupt) then
// leave them alone.
uintptr_t jslimit = SimulatorStack::JsLimitFromCLimit(isolate_, limit);
if (thread_local_.jslimit_ == thread_local_.real_jslimit_) {
@@ -376,15 +375,9 @@
}
-bool StackGuard::ShouldPostponeInterrupts() {
- ExecutionAccess access(isolate_);
- return should_postpone_interrupts(access);
-}
-
-
bool StackGuard::IsInterrupted() {
ExecutionAccess access(isolate_);
- return (thread_local_.interrupt_flags_ & INTERRUPT) != 0;
+ return thread_local_.interrupt_flags_ & INTERRUPT;
}
@@ -410,7 +403,7 @@
bool StackGuard::IsTerminateExecution() {
ExecutionAccess access(isolate_);
- return (thread_local_.interrupt_flags_ & TERMINATE) != 0;
+ return thread_local_.interrupt_flags_ & TERMINATE;
}
@@ -423,7 +416,7 @@
bool StackGuard::IsRuntimeProfilerTick() {
ExecutionAccess access(isolate_);
- return (thread_local_.interrupt_flags_ & RUNTIME_PROFILER_TICK) != 0;
+ return thread_local_.interrupt_flags_ & RUNTIME_PROFILER_TICK;
}
@@ -440,22 +433,6 @@
}
-bool StackGuard::IsGCRequest() {
- ExecutionAccess access(isolate_);
- return (thread_local_.interrupt_flags_ & GC_REQUEST) != 0;
-}
-
-
-void StackGuard::RequestGC() {
- ExecutionAccess access(isolate_);
- thread_local_.interrupt_flags_ |= GC_REQUEST;
- if (thread_local_.postpone_interrupts_nesting_ == 0) {
- thread_local_.jslimit_ = thread_local_.climit_ = kInterruptLimit;
- isolate_->heap()->SetStackLimits();
- }
-}
-
-
#ifdef ENABLE_DEBUGGER_SUPPORT
bool StackGuard::IsDebugBreak() {
ExecutionAccess access(isolate_);
@@ -578,15 +555,14 @@
// --- C a l l s t o n a t i v e s ---
-#define RETURN_NATIVE_CALL(name, args, has_pending_exception) \
- do { \
- Isolate* isolate = Isolate::Current(); \
- Handle<Object> argv[] = args; \
- ASSERT(has_pending_exception != NULL); \
- return Call(isolate->name##_fun(), \
- isolate->js_builtins_object(), \
- ARRAY_SIZE(argv), argv, \
- has_pending_exception); \
+#define RETURN_NATIVE_CALL(name, argc, argv, has_pending_exception) \
+ do { \
+ Isolate* isolate = Isolate::Current(); \
+ Object** args[argc] = argv; \
+ ASSERT(has_pending_exception != NULL); \
+ return Call(isolate->name##_fun(), \
+ isolate->js_builtins_object(), argc, args, \
+ has_pending_exception); \
} while (false)
@@ -607,44 +583,44 @@
Handle<Object> Execution::ToNumber(Handle<Object> obj, bool* exc) {
- RETURN_NATIVE_CALL(to_number, { obj }, exc);
+ RETURN_NATIVE_CALL(to_number, 1, { obj.location() }, exc);
}
Handle<Object> Execution::ToString(Handle<Object> obj, bool* exc) {
- RETURN_NATIVE_CALL(to_string, { obj }, exc);
+ RETURN_NATIVE_CALL(to_string, 1, { obj.location() }, exc);
}
Handle<Object> Execution::ToDetailString(Handle<Object> obj, bool* exc) {
- RETURN_NATIVE_CALL(to_detail_string, { obj }, exc);
+ RETURN_NATIVE_CALL(to_detail_string, 1, { obj.location() }, exc);
}
Handle<Object> Execution::ToObject(Handle<Object> obj, bool* exc) {
if (obj->IsSpecObject()) return obj;
- RETURN_NATIVE_CALL(to_object, { obj }, exc);
+ RETURN_NATIVE_CALL(to_object, 1, { obj.location() }, exc);
}
Handle<Object> Execution::ToInteger(Handle<Object> obj, bool* exc) {
- RETURN_NATIVE_CALL(to_integer, { obj }, exc);
+ RETURN_NATIVE_CALL(to_integer, 1, { obj.location() }, exc);
}
Handle<Object> Execution::ToUint32(Handle<Object> obj, bool* exc) {
- RETURN_NATIVE_CALL(to_uint32, { obj }, exc);
+ RETURN_NATIVE_CALL(to_uint32, 1, { obj.location() }, exc);
}
Handle<Object> Execution::ToInt32(Handle<Object> obj, bool* exc) {
- RETURN_NATIVE_CALL(to_int32, { obj }, exc);
+ RETURN_NATIVE_CALL(to_int32, 1, { obj.location() }, exc);
}
Handle<Object> Execution::NewDate(double time, bool* exc) {
Handle<Object> time_obj = FACTORY->NewNumber(time);
- RETURN_NATIVE_CALL(create_date, { time_obj }, exc);
+ RETURN_NATIVE_CALL(create_date, 1, { time_obj.location() }, exc);
}
@@ -681,7 +657,7 @@
bool caught_exception;
Handle<Object> index_object = factory->NewNumberFromInt(int_index);
- Handle<Object> index_arg[] = { index_object };
+ Object** index_arg[] = { index_object.location() };
Handle<Object> result = TryCall(Handle<JSFunction>::cast(char_at),
string,
ARRAY_SIZE(index_arg),
@@ -695,8 +671,7 @@
Handle<JSFunction> Execution::InstantiateFunction(
- Handle<FunctionTemplateInfo> data,
- bool* exc) {
+ Handle<FunctionTemplateInfo> data, bool* exc) {
Isolate* isolate = data->GetIsolate();
// Fast case: see if the function has already been instantiated
int serial_number = Smi::cast(data->serial_number())->value();
@@ -705,12 +680,10 @@
GetElementNoExceptionThrown(serial_number);
if (elm->IsJSFunction()) return Handle<JSFunction>(JSFunction::cast(elm));
// The function has not yet been instantiated in this context; do it.
- Handle<Object> args[] = { data };
- Handle<Object> result = Call(isolate->instantiate_fun(),
- isolate->js_builtins_object(),
- ARRAY_SIZE(args),
- args,
- exc);
+ Object** args[1] = { Handle<Object>::cast(data).location() };
+ Handle<Object> result =
+ Call(isolate->instantiate_fun(),
+ isolate->js_builtins_object(), 1, args, exc);
if (*exc) return Handle<JSFunction>::null();
return Handle<JSFunction>::cast(result);
}
@@ -737,12 +710,10 @@
ASSERT(!*exc);
return Handle<JSObject>(JSObject::cast(result));
} else {
- Handle<Object> args[] = { data };
- Handle<Object> result = Call(isolate->instantiate_fun(),
- isolate->js_builtins_object(),
- ARRAY_SIZE(args),
- args,
- exc);
+ Object** args[1] = { Handle<Object>::cast(data).location() };
+ Handle<Object> result =
+ Call(isolate->instantiate_fun(),
+ isolate->js_builtins_object(), 1, args, exc);
if (*exc) return Handle<JSObject>::null();
return Handle<JSObject>::cast(result);
}
@@ -753,12 +724,9 @@
Handle<Object> instance_template,
bool* exc) {
Isolate* isolate = Isolate::Current();
- Handle<Object> args[] = { instance, instance_template };
+ Object** args[2] = { instance.location(), instance_template.location() };
Execution::Call(isolate->configure_instance_fun(),
- isolate->js_builtins_object(),
- ARRAY_SIZE(args),
- args,
- exc);
+ isolate->js_builtins_object(), 2, args, exc);
}
@@ -767,13 +735,16 @@
Handle<Object> pos,
Handle<Object> is_global) {
Isolate* isolate = fun->GetIsolate();
- Handle<Object> args[] = { recv, fun, pos, is_global };
- bool caught_exception;
- Handle<Object> result = TryCall(isolate->get_stack_trace_line_fun(),
- isolate->js_builtins_object(),
- ARRAY_SIZE(args),
- args,
- &caught_exception);
+ const int argc = 4;
+ Object** args[argc] = { recv.location(),
+ Handle<Object>::cast(fun).location(),
+ pos.location(),
+ is_global.location() };
+ bool caught_exception = false;
+ Handle<Object> result =
+ TryCall(isolate->get_stack_trace_line_fun(),
+ isolate->js_builtins_object(), argc, args,
+ &caught_exception);
if (caught_exception || !result->IsString()) {
return isolate->factory()->empty_symbol();
}
@@ -826,11 +797,6 @@
return isolate->heap()->undefined_value();
}
- StackLimitCheck check(isolate);
- if (check.HasOverflowed()) {
- return isolate->heap()->undefined_value();
- }
-
{
JavaScriptFrameIterator it(isolate);
ASSERT(!it.done());
@@ -856,22 +822,17 @@
// Clear the debug break request flag.
isolate->stack_guard()->Continue(DEBUGBREAK);
- ProcessDebugMessages(debug_command_only);
+ ProcessDebugMesssages(debug_command_only);
// Return to continue execution.
return isolate->heap()->undefined_value();
}
-void Execution::ProcessDebugMessages(bool debug_command_only) {
+void Execution::ProcessDebugMesssages(bool debug_command_only) {
Isolate* isolate = Isolate::Current();
// Clear the debug command request flag.
isolate->stack_guard()->Continue(DEBUGCOMMAND);
- StackLimitCheck check(isolate);
- if (check.HasOverflowed()) {
- return;
- }
-
HandleScope scope(isolate);
// Enter the debugger. Just continue if we fail to enter the debugger.
EnterDebugger debugger;
@@ -888,22 +849,11 @@
#endif
-MaybeObject* Execution::HandleStackGuardInterrupt(Isolate* isolate) {
+MaybeObject* Execution::HandleStackGuardInterrupt() {
+ Isolate* isolate = Isolate::Current();
StackGuard* stack_guard = isolate->stack_guard();
- if (stack_guard->ShouldPostponeInterrupts()) {
- return isolate->heap()->undefined_value();
- }
-
- if (stack_guard->IsGCRequest()) {
- isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
- "StackGuard GC request");
- stack_guard->Continue(GC_REQUEST);
- }
-
isolate->counters()->stack_interrupts()->Increment();
- // If FLAG_count_based_interrupts, every interrupt is a profiler interrupt.
- if (FLAG_count_based_interrupts ||
- stack_guard->IsRuntimeProfilerTick()) {
+ if (stack_guard->IsRuntimeProfilerTick()) {
isolate->counters()->runtime_profiler_ticks()->Increment();
stack_guard->Continue(RUNTIME_PROFILER_TICK);
isolate->runtime_profiler()->OptimizeNow();
@@ -925,5 +875,4 @@
return isolate->heap()->undefined_value();
}
-
} } // namespace v8::internal