/**
- * Isolate represents an isolated instance of the V8 engine. V8 isolates have
- * completely separate states. Objects from one isolate must not be used in
- * other isolates. The embedder can create multiple isolates and use them in
- * parallel in multiple threads. An isolate can be entered by at most one
- * thread at any given time. The Locker/Unlocker API must be used to
- * synchronize.
+ * Isolate represents an isolated instance of the V8 engine. V8
+ * isolates have completely separate states. Objects from one isolate
+ * must not be used in other isolates. When V8 is initialized a
+ * default isolate is implicitly created and entered. The embedder
+ * can create additional isolates and use them in parallel in multiple
+ * threads. An isolate can be entered by at most one thread at any
+ * given time. The Locker/Unlocker API must be used to synchronize.
*/
class V8_EXPORT Isolate {
public:
* Initial configuration parameters for a new Isolate.
*/
struct CreateParams {
- CreateParams()
- : entry_hook(NULL),
- code_event_handler(NULL),
- enable_serializer(false) {}
+ CreateParams() : entry_hook(NULL), code_event_handler(NULL) {}
/**
* The optional entry_hook allows the host application to provide the
* ResourceConstraints to use for the new Isolate.
*/
ResourceConstraints constraints;
-
- /**
- * This flag currently renders the Isolate unusable.
- */
- bool enable_serializer;
};
*
* When an isolate is no longer used its resources should be freed
* by calling Dispose(). Using the delete operator is not allowed.
- *
- * V8::Initialize() must have run prior to this.
*/
static Isolate* New(const CreateParams& params = CreateParams());
static void RemoveMemoryAllocationCallback(MemoryAllocationCallback callback);
/**
- * Initializes V8. This function needs to be called before the first Isolate
- * is created. It always returns true.
+ * Initializes from snapshot if possible. Otherwise, attempts to
+ * initialize from scratch. This function is called implicitly if
+ * you use the API without calling it first.
*/
static bool Initialize();
v8::V8::InitializeICU();
v8::Platform* platform = v8::platform::CreateDefaultPlatform();
v8::V8::InitializePlatform(platform);
- v8::V8::Initialize();
int result = RunMain(argc, argv);
v8::V8::Dispose();
v8::V8::ShutdownPlatform();
v8::V8::InitializeICU();
v8::Platform* platform = v8::platform::CreateDefaultPlatform();
v8::V8::InitializePlatform(platform);
- v8::V8::Initialize();
map<string, string> options;
string file;
ParseOptions(argc, argv, &options, &file);
v8::V8::InitializeICU();
v8::Platform* platform = v8::platform::CreateDefaultPlatform();
v8::V8::InitializePlatform(platform);
- v8::V8::Initialize();
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
ShellArrayBufferAllocator array_buffer_allocator;
v8::V8::SetArrayBufferAllocator(&array_buffer_allocator);
}
+// --- S t a t i c s ---
+
+
+static bool InitializeHelper(i::Isolate* isolate) {
+ // If the isolate has a function entry hook, it needs to re-build all its
+ // code stubs with entry hooks embedded, so let's deserialize a snapshot.
+ if (isolate == NULL || isolate->function_entry_hook() == NULL) {
+ if (i::Snapshot::Initialize())
+ return true;
+ }
+ return i::V8::Initialize(NULL);
+}
+
+
+static inline bool EnsureInitializedForIsolate(i::Isolate* isolate,
+ const char* location) {
+ return (isolate != NULL && isolate->IsInitialized()) ||
+ Utils::ApiCheck(InitializeHelper(isolate),
+ location,
+ "Error initializing V8");
+}
+
+
StartupDataDecompressor::StartupDataDecompressor()
: raw_data(i::NewArray<char*>(V8::GetCompressedStartupDataCount())) {
for (int i = 0; i < V8::GetCompressedStartupDataCount(); ++i) {
// NeanderObject constructor. When you add one to the site calling the
// constructor you should check that you ensured the VM was not dead first.
NeanderObject::NeanderObject(v8::internal::Isolate* isolate, int size) {
+ EnsureInitializedForIsolate(isolate, "v8::Nowhere");
ENTER_V8(isolate);
value_ = isolate->factory()->NewNeanderObject();
i::Handle<i::FixedArray> elements = isolate->factory()->NewFixedArray(size);
v8::Handle<Signature> signature,
int length) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ EnsureInitializedForIsolate(i_isolate, "v8::FunctionTemplate::New()");
LOG_API(i_isolate, "FunctionTemplate::New");
ENTER_V8(i_isolate);
return FunctionTemplateNew(
Handle<FunctionTemplate> receiver, int argc,
Handle<FunctionTemplate> argv[]) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ EnsureInitializedForIsolate(i_isolate, "v8::Signature::New()");
LOG_API(i_isolate, "Signature::New");
ENTER_V8(i_isolate);
i::Handle<i::Struct> struct_obj =
Local<TypeSwitch> TypeSwitch::New(int argc, Handle<FunctionTemplate> types[]) {
i::Isolate* isolate = i::Isolate::Current();
+ EnsureInitializedForIsolate(isolate, "v8::TypeSwitch::New()");
LOG_API(isolate, "TypeSwitch::New");
ENTER_V8(isolate);
i::Handle<i::FixedArray> vector = isolate->factory()->NewFixedArray(argc);
Local<ObjectTemplate> ObjectTemplate::New(
i::Isolate* isolate,
v8::Handle<FunctionTemplate> constructor) {
+ EnsureInitializedForIsolate(isolate, "v8::ObjectTemplate::New()");
LOG_API(isolate, "ObjectTemplate::New");
ENTER_V8(isolate);
i::Handle<i::Struct> struct_obj =
Local<Value> JSON::Parse(Local<String> json_string) {
i::Handle<i::String> string = Utils::OpenHandle(*json_string);
i::Isolate* isolate = string->GetIsolate();
+ EnsureInitializedForIsolate(isolate, "v8::JSON::Parse");
ENTER_V8(isolate);
i::HandleScope scope(isolate);
i::Handle<i::String> source = i::String::Flatten(string);
bool v8::String::IsExternal() const {
i::Handle<i::String> str = Utils::OpenHandle(this);
+ EnsureInitializedForIsolate(str->GetIsolate(), "v8::String::IsExternal()");
return i::StringShape(*str).IsExternalTwoByte();
}
bool v8::V8::Initialize() {
- i::V8::Initialize();
- return true;
+ i::Isolate* isolate = i::Isolate::UncheckedCurrent();
+ if (isolate != NULL && isolate->IsInitialized()) {
+ return true;
+ }
+ return InitializeHelper(isolate);
}
v8::Handle<ObjectTemplate> global_template,
v8::Handle<Value> global_object) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate);
+ EnsureInitializedForIsolate(isolate, "v8::Context::New()");
LOG_API(isolate, "Context::New");
ON_BAILOUT(isolate, "v8::Context::New()", return Local<Context>());
i::HandleScope scope(isolate);
Local<External> v8::External::New(Isolate* isolate, void* value) {
STATIC_ASSERT(sizeof(value) == sizeof(i::Address));
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ EnsureInitializedForIsolate(i_isolate, "v8::External::New()");
LOG_API(i_isolate, "External::New");
ENTER_V8(i_isolate);
i::Handle<i::JSObject> external = i_isolate->factory()->NewExternal(value);
String::NewStringType type,
int length) {
i::Isolate* isolate = reinterpret_cast<internal::Isolate*>(v8_isolate);
+ EnsureInitializedForIsolate(isolate, location);
LOG_API(isolate, env);
if (length == 0 && type != String::kUndetectableString) {
return String::Empty(v8_isolate);
Local<String> v8::String::Concat(Handle<String> left, Handle<String> right) {
i::Handle<i::String> left_string = Utils::OpenHandle(*left);
i::Isolate* isolate = left_string->GetIsolate();
+ EnsureInitializedForIsolate(isolate, "v8::String::New()");
LOG_API(isolate, "String::New(char)");
ENTER_V8(isolate);
i::Handle<i::String> right_string = Utils::OpenHandle(*right);
Isolate* isolate,
v8::String::ExternalStringResource* resource) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()");
LOG_API(i_isolate, "String::NewExternal");
ENTER_V8(i_isolate);
CHECK(resource && resource->data());
Local<String> v8::String::NewExternal(
Isolate* isolate, v8::String::ExternalOneByteStringResource* resource) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()");
LOG_API(i_isolate, "String::NewExternal");
ENTER_V8(i_isolate);
CHECK(resource && resource->data());
Local<v8::Object> v8::Object::New(Isolate* isolate) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ EnsureInitializedForIsolate(i_isolate, "v8::Object::New()");
LOG_API(i_isolate, "Object::New");
ENTER_V8(i_isolate);
i::Handle<i::JSObject> obj =
Local<v8::Value> v8::NumberObject::New(Isolate* isolate, double value) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ EnsureInitializedForIsolate(i_isolate, "v8::NumberObject::New()");
LOG_API(i_isolate, "NumberObject::New");
ENTER_V8(i_isolate);
i::Handle<i::Object> number = i_isolate->factory()->NewNumber(value);
Local<v8::Value> v8::BooleanObject::New(bool value) {
i::Isolate* isolate = i::Isolate::Current();
+ EnsureInitializedForIsolate(isolate, "v8::BooleanObject::New()");
LOG_API(isolate, "BooleanObject::New");
ENTER_V8(isolate);
i::Handle<i::Object> boolean(value
Local<v8::Value> v8::StringObject::New(Handle<String> value) {
i::Handle<i::String> string = Utils::OpenHandle(*value);
i::Isolate* isolate = string->GetIsolate();
+ EnsureInitializedForIsolate(isolate, "v8::StringObject::New()");
LOG_API(isolate, "StringObject::New");
ENTER_V8(isolate);
i::Handle<i::Object> obj =
Local<v8::Value> v8::SymbolObject::New(Isolate* isolate, Handle<Symbol> value) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ EnsureInitializedForIsolate(i_isolate, "v8::SymbolObject::New()");
LOG_API(i_isolate, "SymbolObject::New");
ENTER_V8(i_isolate);
i::Handle<i::Object> obj = i::Object::ToObject(
Local<v8::Value> v8::Date::New(Isolate* isolate, double time) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ EnsureInitializedForIsolate(i_isolate, "v8::Date::New()");
LOG_API(i_isolate, "Date::New");
if (std::isnan(time)) {
// Introduce only canonical NaN value into the VM, to avoid signaling NaNs.
Local<v8::RegExp> v8::RegExp::New(Handle<String> pattern,
Flags flags) {
i::Isolate* isolate = Utils::OpenHandle(*pattern)->GetIsolate();
+ EnsureInitializedForIsolate(isolate, "v8::RegExp::New()");
LOG_API(isolate, "RegExp::New");
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
Local<v8::Array> v8::Array::New(Isolate* isolate, int length) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ EnsureInitializedForIsolate(i_isolate, "v8::Array::New()");
LOG_API(i_isolate, "Array::New");
ENTER_V8(i_isolate);
int real_length = length > 0 ? length : 0;
Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, size_t byte_length) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ EnsureInitializedForIsolate(i_isolate, "v8::ArrayBuffer::New(size_t)");
LOG_API(i_isolate, "v8::ArrayBuffer::New(size_t)");
ENTER_V8(i_isolate);
i::Handle<i::JSArrayBuffer> obj =
Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data,
size_t byte_length) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ EnsureInitializedForIsolate(i_isolate, "v8::ArrayBuffer::New(void*, size_t)");
LOG_API(i_isolate, "v8::ArrayBuffer::New(void*, size_t)");
ENTER_V8(i_isolate);
i::Handle<i::JSArrayBuffer> obj =
Local<Type##Array> Type##Array::New(Handle<ArrayBuffer> array_buffer, \
size_t byte_offset, size_t length) { \
i::Isolate* isolate = Utils::OpenHandle(*array_buffer)->GetIsolate(); \
+ EnsureInitializedForIsolate(isolate, \
+ "v8::" #Type "Array::New(Handle<ArrayBuffer>, size_t, size_t)"); \
LOG_API(isolate, \
"v8::" #Type "Array::New(Handle<ArrayBuffer>, size_t, size_t)"); \
ENTER_V8(isolate); \
size_t byte_offset, size_t byte_length) {
i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer);
i::Isolate* isolate = buffer->GetIsolate();
+ EnsureInitializedForIsolate(
+ isolate, "v8::DataView::New(void*, size_t, size_t)");
LOG_API(isolate, "v8::DataView::New(void*, size_t, size_t)");
ENTER_V8(isolate);
i::Handle<i::JSDataView> obj = isolate->factory()->NewJSDataView();
Local<Symbol> v8::Symbol::New(Isolate* isolate, Local<String> name) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ EnsureInitializedForIsolate(i_isolate, "v8::Symbol::New()");
LOG_API(i_isolate, "Symbol::New()");
ENTER_V8(i_isolate);
i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol();
Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ EnsureInitializedForIsolate(i_isolate, "v8::Private::New()");
LOG_API(i_isolate, "Private::New()");
ENTER_V8(i_isolate);
i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol();
bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) {
i::Isolate* isolate = i::Isolate::Current();
+ EnsureInitializedForIsolate(isolate, "v8::V8::AddMessageListener()");
ON_BAILOUT(isolate, "v8::V8::AddMessageListener()", return false);
ENTER_V8(isolate);
i::HandleScope scope(isolate);
void V8::RemoveMessageListeners(MessageCallback that) {
i::Isolate* isolate = i::Isolate::Current();
+ EnsureInitializedForIsolate(isolate, "v8::V8::RemoveMessageListener()");
ON_BAILOUT(isolate, "v8::V8::RemoveMessageListeners()", return);
ENTER_V8(isolate);
i::HandleScope scope(isolate);
}
SetResourceConstraints(v8_isolate,
const_cast<ResourceConstraints*>(¶ms.constraints));
- if (params.enable_serializer) {
- isolate->enable_serializer();
- }
- // TODO(jochen): Once we got rid of Isolate::Current(), we can remove this.
- Isolate::Scope isolate_scope(v8_isolate);
- if (params.entry_hook || !i::Snapshot::Initialize(isolate)) {
- // If the isolate has a function entry hook, it needs to re-build all its
- // code stubs with entry hooks embedded, so don't deserialize a snapshot.
- isolate->Init(NULL);
- }
return v8_isolate;
}
bool Debug::SetDebugEventListener(EventCallback that, Handle<Value> data) {
i::Isolate* isolate = i::Isolate::Current();
+ EnsureInitializedForIsolate(isolate, "v8::Debug::SetDebugEventListener()");
ON_BAILOUT(isolate, "v8::Debug::SetDebugEventListener()", return false);
ENTER_V8(isolate);
i::HandleScope scope(isolate);
void Debug::SetMessageHandler(v8::Debug::MessageHandler handler) {
i::Isolate* isolate = i::Isolate::Current();
+ EnsureInitializedForIsolate(isolate, "v8::Debug::SetMessageHandler");
ENTER_V8(isolate);
isolate->debug()->SetMessageHandler(handler);
}
Local<Context> Debug::GetDebugContext() {
i::Isolate* isolate = i::Isolate::Current();
+ EnsureInitializedForIsolate(isolate, "v8::Debug::GetDebugContext()");
ENTER_V8(isolate);
return Utils::ToLocal(i::Isolate::Current()->debug()->GetDebugContext());
}
void RandomNumberGenerator::SetSeed(int64_t seed) {
- initial_seed_ = seed;
seed_ = (seed ^ kMultiplier) & kMask;
}
// Override the current ssed.
void SetSeed(int64_t seed);
- int64_t initial_seed() const { return initial_seed_; }
-
private:
static const int64_t kMultiplier = V8_2PART_UINT64_C(0x5, deece66d);
static const int64_t kAddend = 0xb;
int Next(int bits) WARN_UNUSED_RESULT;
- int64_t initial_seed_;
int64_t seed_;
};
active_(isolate->bootstrapper()) {
NoTrackDoubleFieldsForSerializerScope disable_scope(isolate);
result_ = Handle<Context>::null();
+ // If V8 cannot be initialized, just return.
+ if (!V8::Initialize(NULL)) return;
+
// Before creating the roots we must save the context and restore it
// on all function exits.
SaveContext saved_context(isolate);
v8::V8::InitializeICU(options.icu_data_file);
v8::Platform* platform = v8::platform::CreateDefaultPlatform();
v8::V8::InitializePlatform(platform);
- v8::V8::Initialize();
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
StartupDataHandler startup_data(options.natives_blob, options.snapshot_blob);
#endif
int ThreadId::GetCurrentThreadId() {
+ Isolate::EnsureInitialized();
int thread_id = base::Thread::GetThreadLocalInt(Isolate::thread_id_key_);
if (thread_id == 0) {
thread_id = AllocateThreadId();
#ifdef DEBUG
base::Thread::LocalStorageKey PerThreadAssertScopeBase::thread_local_key;
#endif // DEBUG
-base::LazyMutex Isolate::thread_data_table_mutex_ = LAZY_MUTEX_INITIALIZER;
+base::LazyMutex Isolate::process_wide_mutex_ = LAZY_MUTEX_INITIALIZER;
Isolate::ThreadDataTable* Isolate::thread_data_table_ = NULL;
base::Atomic32 Isolate::isolate_counter_ = 0;
Isolate::PerIsolateThreadData*
Isolate::FindOrAllocatePerThreadDataForThisThread() {
+ EnsureInitialized();
ThreadId thread_id = ThreadId::Current();
PerIsolateThreadData* per_thread = NULL;
{
- base::LockGuard<base::Mutex> lock_guard(thread_data_table_mutex_.Pointer());
+ base::LockGuard<base::Mutex> lock_guard(process_wide_mutex_.Pointer());
per_thread = thread_data_table_->Lookup(this, thread_id);
if (per_thread == NULL) {
per_thread = new PerIsolateThreadData(this, thread_id);
Isolate::PerIsolateThreadData* Isolate::FindPerThreadDataForThread(
ThreadId thread_id) {
+ EnsureInitialized();
PerIsolateThreadData* per_thread = NULL;
{
- base::LockGuard<base::Mutex> lock_guard(thread_data_table_mutex_.Pointer());
+ base::LockGuard<base::Mutex> lock_guard(process_wide_mutex_.Pointer());
per_thread = thread_data_table_->Lookup(this, thread_id);
}
return per_thread;
}
-void Isolate::InitializeOncePerProcess() {
- base::LockGuard<base::Mutex> lock_guard(thread_data_table_mutex_.Pointer());
- CHECK(thread_data_table_ == NULL);
- isolate_key_ = base::Thread::CreateThreadLocalKey();
- thread_id_key_ = base::Thread::CreateThreadLocalKey();
- per_isolate_thread_data_key_ = base::Thread::CreateThreadLocalKey();
+void Isolate::EnsureInitialized() {
+ base::LockGuard<base::Mutex> lock_guard(process_wide_mutex_.Pointer());
+ if (thread_data_table_ == NULL) {
+ isolate_key_ = base::Thread::CreateThreadLocalKey();
+ thread_id_key_ = base::Thread::CreateThreadLocalKey();
+ per_isolate_thread_data_key_ = base::Thread::CreateThreadLocalKey();
#ifdef DEBUG
- PerThreadAssertScopeBase::thread_local_key =
- base::Thread::CreateThreadLocalKey();
+ PerThreadAssertScopeBase::thread_local_key =
+ base::Thread::CreateThreadLocalKey();
#endif // DEBUG
- thread_data_table_ = new Isolate::ThreadDataTable();
+ thread_data_table_ = new Isolate::ThreadDataTable();
+ }
}
stress_deopt_count_(0),
next_optimization_id_(0),
use_counter_callback_(NULL) {
- {
- base::LockGuard<base::Mutex> lock_guard(thread_data_table_mutex_.Pointer());
- CHECK(thread_data_table_);
- }
id_ = base::NoBarrier_AtomicIncrement(&isolate_counter_, 1);
TRACE_ISOLATE(constructor);
Deinit();
{
- base::LockGuard<base::Mutex> lock_guard(thread_data_table_mutex_.Pointer());
+ base::LockGuard<base::Mutex> lock_guard(process_wide_mutex_.Pointer());
thread_data_table_->RemoveAllThreads(this);
}
void Isolate::SetIsolateThreadLocals(Isolate* isolate,
PerIsolateThreadData* data) {
+ EnsureInitialized();
base::Thread::SetThreadLocal(isolate_key_, isolate);
base::Thread::SetThreadLocal(per_isolate_thread_data_key_, data);
}
kIsolateAddressCount
};
- static void InitializeOncePerProcess();
-
// Returns the PerIsolateThreadData for the current thread (or NULL if one is
// not currently set).
static PerIsolateThreadData* CurrentPerIsolateThreadData() {
+ EnsureInitialized();
return reinterpret_cast<PerIsolateThreadData*>(
base::Thread::GetThreadLocal(per_isolate_thread_data_key_));
}
// Returns the isolate inside which the current thread is running.
INLINE(static Isolate* Current()) {
+ EnsureInitialized();
Isolate* isolate = reinterpret_cast<Isolate*>(
base::Thread::GetExistingThreadLocal(isolate_key_));
DCHECK(isolate != NULL);
}
INLINE(static Isolate* UncheckedCurrent()) {
+ EnsureInitialized();
return reinterpret_cast<Isolate*>(
base::Thread::GetThreadLocal(isolate_key_));
}
// Used internally for V8 threads that do not execute JavaScript but still
// are part of the domain of an isolate (like the context switcher).
static base::Thread::LocalStorageKey isolate_key() {
+ EnsureInitialized();
return isolate_key_;
}
// Returns the key used to store process-wide thread IDs.
static base::Thread::LocalStorageKey thread_id_key() {
+ EnsureInitialized();
return thread_id_key_;
}
void SetUseCounterCallback(v8::Isolate::UseCounterCallback callback);
void CountUsage(v8::Isolate::UseCounterFeature feature);
- static Isolate* NewForTesting() { return new Isolate(); }
-
private:
+ static void EnsureInitialized();
+
Isolate();
friend struct GlobalState;
DISALLOW_COPY_AND_ASSIGN(EntryStackItem);
};
- static base::LazyMutex thread_data_table_mutex_;
+ // This mutex protects highest_thread_id_ and thread_data_table_.
+ static base::LazyMutex process_wide_mutex_;
static base::Thread::LocalStorageKey per_isolate_thread_data_key_;
static base::Thread::LocalStorageKey isolate_key_;
int main(int argc, char** argv) {
+ V8::InitializeICU();
+ v8::Platform* platform = v8::platform::CreateDefaultPlatform();
+ v8::V8::InitializePlatform(platform);
+ i::CpuFeatures::Probe(true);
+
// By default, log code create information in the snapshot.
i::FLAG_log_code = true;
i::FlagList::PrintHelp();
return !i::FLAG_help;
}
-
- V8::InitializeICU();
- v8::Platform* platform = v8::platform::CreateDefaultPlatform();
- v8::V8::InitializePlatform(platform);
- v8::V8::Initialize();
- i::CpuFeatures::Probe(true);
-
#ifdef COMPRESS_STARTUP_DATA_BZ2
BZip2Decompressor natives_decompressor;
int bz2_result = natives_decompressor.Decompress();
#endif
i::FLAG_logfile_per_isolate = false;
- Isolate::CreateParams params;
- params.enable_serializer = true;
- Isolate* isolate = v8::Isolate::New(params);
+ Isolate* isolate = v8::Isolate::New();
{ Isolate::Scope isolate_scope(isolate);
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ internal_isolate->enable_serializer();
Persistent<Context> context;
{
}
-bool Snapshot::Initialize(Isolate* isolate) {
+bool Snapshot::Initialize() {
if (size_ > 0) {
base::ElapsedTimer timer;
if (FLAG_profile_deserialization) {
SnapshotByteSource source(raw_data_, raw_size_);
Deserializer deserializer(&source);
ReserveSpaceForLinkedInSnapshot(&deserializer);
- bool success = isolate->Init(&deserializer);
+ bool success = V8::Initialize(&deserializer);
if (FLAG_profile_deserialization) {
double ms = timer.Elapsed().InMillisecondsF();
PrintF("[Snapshot loading and deserialization took %0.3f ms]\n", ms);
}
-bool Snapshot::Initialize(Isolate* isolate) {
+bool Snapshot::Initialize() {
if (!HaveASnapshotToStartFrom())
return false;
deserializer.set_reservation(CELL_SPACE, snapshot_impl_->cell_space_used);
deserializer.set_reservation(PROPERTY_CELL_SPACE,
snapshot_impl_->property_cell_space_used);
- bool success = isolate->Init(&deserializer);
+ bool success = V8::Initialize(&deserializer);
if (FLAG_profile_deserialization) {
double ms = timer.Elapsed().InMillisecondsF();
PrintF("[Snapshot loading and deserialization took %0.3f ms]\n", ms);
class Snapshot {
public:
- // Initialize the Isolate from the internal snapshot. Returns false if no
- // snapshot could be found.
- static bool Initialize(Isolate* isolate);
+ // Initialize the VM from the internal snapshot. Returns false if no snapshot
+ // could be found.
+ static bool Initialize();
static bool HaveASnapshotToStartFrom();
v8::Platform* V8::platform_ = NULL;
-bool V8::Initialize() {
+bool V8::Initialize(Deserializer* des) {
InitializeOncePerProcess();
- return true;
+ Isolate* isolate = Isolate::UncheckedCurrent();
+ if (isolate == NULL) return true;
+ if (isolate->IsDead()) return false;
+ if (isolate->IsInitialized()) return true;
+
+ return isolate->Init(des);
}
base::OS::Initialize(FLAG_random_seed, FLAG_hard_abort, FLAG_gc_fake_mmap);
- Isolate::InitializeOncePerProcess();
-
Sampler::SetUp();
CpuFeatures::Probe(false);
init_memcopy_functions();
namespace v8 {
namespace internal {
+class Deserializer;
+
class V8 : public AllStatic {
public:
// Global actions.
- static bool Initialize();
+ // If Initialize is called with des == NULL, the initial state is
+ // created from scratch. If a non-null Deserializer is given, the
+ // initial state is created by reading the deserialized data into an
+ // empty heap.
+ static bool Initialize(Deserializer* des);
static void TearDown();
// Report process out of memory. Implementation found in api.cc.
v8::V8::InitializeICU();
v8::Platform* platform = v8::platform::CreateDefaultPlatform();
v8::V8::InitializePlatform(platform);
+
v8::internal::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
- v8::V8::Initialize();
CcTestArrayBufferAllocator array_buffer_allocator;
v8::V8::SetArrayBufferAllocator(&array_buffer_allocator);
for (int i = 1; i < argc; i++) {
char* arg = argv[i];
if (strcmp(arg, "--list") == 0) {
+ // TODO(svenpanne) Serializer::enabled() and Serializer::code_address_map_
+ // are fundamentally broken, so we can't unconditionally initialize and
+ // dispose V8.
+ v8::V8::Initialize();
PrintTestList(CcTest::last());
print_run_count = false;
static void Test##Name()
#endif
-#ifndef UNINITIALIZED_DEPENDENT_TEST
-#define UNINITIALIZED_DEPENDENT_TEST(Name, Dep) \
- static void Test##Name(); \
- CcTest register_test_##Name(Test##Name, __FILE__, #Name, #Dep, true, false); \
- static void Test##Name()
-#endif
-
#ifndef DISABLED_TEST
#define DISABLED_TEST(Name) \
static void Test##Name(); \
class IsolateThread : public v8::base::Thread {
public:
- explicit IsolateThread(int fib_limit)
- : Thread(Options("IsolateThread")), fib_limit_(fib_limit), result_(0) {}
+ IsolateThread(v8::Isolate* isolate, int fib_limit)
+ : Thread(Options("IsolateThread")),
+ isolate_(isolate),
+ fib_limit_(fib_limit),
+ result_(0) {}
void Run() {
- v8::Isolate* isolate = v8::Isolate::New();
- result_ = CalcFibonacci(isolate, fib_limit_);
- isolate->Dispose();
+ result_ = CalcFibonacci(isolate_, fib_limit_);
}
int result() { return result_; }
private:
+ v8::Isolate* isolate_;
int fib_limit_;
int result_;
};
TEST(MultipleIsolatesOnIndividualThreads) {
- IsolateThread thread1(21);
- IsolateThread thread2(12);
+ v8::Isolate* isolate1 = v8::Isolate::New();
+ v8::Isolate* isolate2 = v8::Isolate::New();
+
+ IsolateThread thread1(isolate1, 21);
+ IsolateThread thread2(isolate2, 12);
// Compute some fibonacci numbers on 3 threads in 3 isolates.
thread1.Start();
CHECK_EQ(result2, 144);
CHECK_EQ(result1, thread1.result());
CHECK_EQ(result2, thread2.result());
+
+ isolate1->Dispose();
+ isolate2->Dispose();
}
using namespace v8::internal;
TEST(List) {
+ v8::internal::V8::Initialize(NULL);
List<AstNode*>* list = new List<AstNode*>(0);
CHECK_EQ(0, list->length());
using namespace v8::internal;
TEST(BitVector) {
+ v8::internal::V8::Initialize(NULL);
Zone zone(CcTest::i_isolate());
{
BitVector v(15, &zone);
class DebugLocalContext {
public:
inline DebugLocalContext(
- v8::Isolate* isolate, v8::ExtensionConfiguration* extensions = 0,
- v8::Handle<v8::ObjectTemplate> global_template =
- v8::Handle<v8::ObjectTemplate>(),
- v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>())
- : scope_(isolate),
- context_(v8::Context::New(isolate, extensions, global_template,
- global_object)) {
- context_->Enter();
- }
- inline DebugLocalContext(
v8::ExtensionConfiguration* extensions = 0,
v8::Handle<v8::ObjectTemplate> global_template =
v8::Handle<v8::ObjectTemplate>(),
v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>())
: scope_(CcTest::isolate()),
- context_(v8::Context::New(CcTest::isolate(), extensions,
- global_template, global_object)) {
+ context_(
+ v8::Context::New(CcTest::isolate(),
+ extensions,
+ global_template,
+ global_object)) {
context_->Enter();
}
inline ~DebugLocalContext() {
const char* source,
const char* function_name) {
v8::Script::Compile(v8::String::NewFromUtf8(isolate, source))->Run();
- v8::Local<v8::Object> global = isolate->GetCurrentContext()->Global();
+ v8::Local<v8::Object> global =
+ CcTest::isolate()->GetCurrentContext()->Global();
return v8::Local<v8::Function>::Cast(
global->Get(v8::String::NewFromUtf8(isolate, function_name)));
}
public:
V8Thread() : Thread(Options("V8Thread")) {}
void Run();
- v8::Isolate* isolate() { return isolate_; }
-
- private:
- v8::Isolate* isolate_;
};
class DebuggerThread : public v8::base::Thread {
public:
- explicit DebuggerThread(v8::Isolate* isolate)
- : Thread(Options("DebuggerThread")), isolate_(isolate) {}
+ DebuggerThread() : Thread(Options("DebuggerThread")) {}
void Run();
-
- private:
- v8::Isolate* isolate_;
};
"\n"
"foo();\n";
- isolate_ = v8::Isolate::New();
- threaded_debugging_barriers.barrier_3.Wait();
- {
- v8::Isolate::Scope isolate_scope(isolate_);
- DebugLocalContext env(isolate_);
- v8::HandleScope scope(isolate_);
- v8::Debug::SetMessageHandler(&ThreadedMessageHandler);
- v8::Handle<v8::ObjectTemplate> global_template =
- v8::ObjectTemplate::New(env->GetIsolate());
- global_template->Set(
- v8::String::NewFromUtf8(env->GetIsolate(), "ThreadedAtBarrier1"),
- v8::FunctionTemplate::New(isolate_, ThreadedAtBarrier1));
- v8::Handle<v8::Context> context =
- v8::Context::New(isolate_, NULL, global_template);
- v8::Context::Scope context_scope(context);
-
- CompileRun(source);
- }
- isolate_->Dispose();
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::Isolate::Scope isolate_scope(isolate);
+ DebugLocalContext env;
+ v8::HandleScope scope(env->GetIsolate());
+ v8::Debug::SetMessageHandler(&ThreadedMessageHandler);
+ v8::Handle<v8::ObjectTemplate> global_template =
+ v8::ObjectTemplate::New(env->GetIsolate());
+ global_template->Set(
+ v8::String::NewFromUtf8(env->GetIsolate(), "ThreadedAtBarrier1"),
+ v8::FunctionTemplate::New(isolate, ThreadedAtBarrier1));
+ v8::Handle<v8::Context> context = v8::Context::New(isolate,
+ NULL,
+ global_template);
+ v8::Context::Scope context_scope(context);
+
+ CompileRun(source);
}
"\"type\":\"request\","
"\"command\":\"continue\"}";
+ v8::Isolate* isolate = CcTest::isolate();
threaded_debugging_barriers.barrier_1.Wait();
- v8::Debug::DebugBreak(isolate_);
+ v8::Debug::DebugBreak(isolate);
threaded_debugging_barriers.barrier_2.Wait();
- v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_1, buffer));
- v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_2, buffer));
+ v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_1, buffer));
+ v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_2, buffer));
}
TEST(ThreadedDebugging) {
+ DebuggerThread debugger_thread;
V8Thread v8_thread;
// Create a V8 environment
v8_thread.Start();
- threaded_debugging_barriers.barrier_3.Wait();
- DebuggerThread debugger_thread(v8_thread.isolate());
debugger_thread.Start();
v8_thread.Join();
public:
BreakpointsV8Thread() : Thread(Options("BreakpointsV8Thread")) {}
void Run();
-
- v8::Isolate* isolate() { return isolate_; }
-
- private:
- v8::Isolate* isolate_;
};
class BreakpointsDebuggerThread : public v8::base::Thread {
public:
- BreakpointsDebuggerThread(bool global_evaluate, v8::Isolate* isolate)
+ explicit BreakpointsDebuggerThread(bool global_evaluate)
: Thread(Options("BreakpointsDebuggerThread")),
- global_evaluate_(global_evaluate),
- isolate_(isolate) {}
+ global_evaluate_(global_evaluate) {}
void Run();
private:
bool global_evaluate_;
- v8::Isolate* isolate_;
};
const char* source_2 = "cat(17);\n"
"cat(19);\n";
- isolate_ = v8::Isolate::New();
- breakpoints_barriers->barrier_3.Wait();
- {
- v8::Isolate::Scope isolate_scope(isolate_);
- DebugLocalContext env(isolate_);
- v8::HandleScope scope(isolate_);
- v8::Debug::SetMessageHandler(&BreakpointsMessageHandler);
-
- CompileRun(source_1);
- breakpoints_barriers->barrier_1.Wait();
- breakpoints_barriers->barrier_2.Wait();
- CompileRun(source_2);
- }
- isolate_->Dispose();
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::Isolate::Scope isolate_scope(isolate);
+ DebugLocalContext env;
+ v8::HandleScope scope(isolate);
+ v8::Debug::SetMessageHandler(&BreakpointsMessageHandler);
+
+ CompileRun(source_1);
+ breakpoints_barriers->barrier_1.Wait();
+ breakpoints_barriers->barrier_2.Wait();
+ CompileRun(source_2);
}
"\"command\":\"continue\"}";
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::Isolate::Scope isolate_scope(isolate);
// v8 thread initializes, runs source_1
breakpoints_barriers->barrier_1.Wait();
// 1:Set breakpoint in cat() (will get id 1).
- v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_1, buffer));
+ v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_1, buffer));
// 2:Set breakpoint in dog() (will get id 2).
- v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_2, buffer));
+ v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_2, buffer));
breakpoints_barriers->barrier_2.Wait();
// V8 thread starts compiling source_2.
// Automatic break happens, to run queued commands
// Must have hit breakpoint #1.
CHECK_EQ(1, break_event_breakpoint_id);
// 4:Evaluate dog() (which has a breakpoint).
- v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_3, buffer));
+ v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_3, buffer));
// V8 thread hits breakpoint in dog().
breakpoints_barriers->semaphore_1.Wait(); // wait for break event
// Must have hit breakpoint #2.
CHECK_EQ(2, break_event_breakpoint_id);
// 5:Evaluate (x + 1).
- v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_4, buffer));
+ v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_4, buffer));
// Evaluate (x + 1) finishes.
breakpoints_barriers->semaphore_1.Wait();
// Must have result 108.
CHECK_EQ(108, evaluate_int_result);
// 6:Continue evaluation of dog().
- v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_5, buffer));
+ v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_5, buffer));
// Evaluate dog() finishes.
breakpoints_barriers->semaphore_1.Wait();
// Must have result 107.
CHECK_EQ(107, evaluate_int_result);
// 7:Continue evaluation of source_2, finish cat(17), hit breakpoint
// in cat(19).
- v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_6, buffer));
+ v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_6, buffer));
// Message callback gets break event.
breakpoints_barriers->semaphore_1.Wait(); // wait for break event
// Must have hit breakpoint #1.
CHECK_EQ(1, break_event_breakpoint_id);
// 8: Evaluate dog() with breaks disabled.
- v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_7, buffer));
+ v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_7, buffer));
// Evaluate dog() finishes.
breakpoints_barriers->semaphore_1.Wait();
// Must have result 116.
CHECK_EQ(116, evaluate_int_result);
// 9: Continue evaluation of source2, reach end.
- v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_8, buffer));
+ v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_8, buffer));
}
void TestRecursiveBreakpointsGeneric(bool global_evaluate) {
+ BreakpointsDebuggerThread breakpoints_debugger_thread(global_evaluate);
BreakpointsV8Thread breakpoints_v8_thread;
// Create a V8 environment
breakpoints_barriers = &stack_allocated_breakpoints_barriers;
breakpoints_v8_thread.Start();
- breakpoints_barriers->barrier_3.Wait();
- BreakpointsDebuggerThread breakpoints_debugger_thread(
- global_evaluate, breakpoints_v8_thread.isolate());
breakpoints_debugger_thread.Start();
breakpoints_v8_thread.Join();
// Abort any ongoing incremental marking to make sure that all weak global
// handle callbacks are processed.
-static void NonIncrementalGC(i::Isolate* isolate) {
- isolate->heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
+static void NonIncrementalGC() {
+ CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
}
"function f() { g(); };"
"f();");
}
- NonIncrementalGC(CcTest::i_isolate());
+ NonIncrementalGC();
CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized());
"function f(x) { if (x) { g(); } else { return } };"
"f(true);");
}
- NonIncrementalGC(CcTest::i_isolate());
+ NonIncrementalGC();
CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized());
"function f(x, y, z) { g(1,x); y+z; };"
"f(1, \"2\", false);");
}
- NonIncrementalGC(CcTest::i_isolate());
+ NonIncrementalGC();
CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized());
"function f(x, y, z) { if (x) { g(x, y); } else { return y + z; } };"
"f(true, 1, \"2\");");
}
- NonIncrementalGC(CcTest::i_isolate());
+ NonIncrementalGC();
CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized());
"function g(z) { count++; %DeoptimizeFunction(f); return z;}"
"function f(x,y,z) { return h(x, y, g(z)); };"
"result = f(1, 2, 3);");
- NonIncrementalGC(CcTest::i_isolate());
+ NonIncrementalGC();
CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
CHECK_EQ(6, env->Global()->Get(v8_str("result"))->Int32Value());
"function f(x) { calls++; if (x > 0) { f(x - 1); } else { g(); } };"
"f(10);");
}
- NonIncrementalGC(CcTest::i_isolate());
+ NonIncrementalGC();
CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
CHECK_EQ(11, env->Global()->Get(v8_str("calls"))->Int32Value());
"function f1(x) { return f2(x + 1, x + 1) + x; };"
"result = f1(1);");
}
- NonIncrementalGC(CcTest::i_isolate());
+ NonIncrementalGC();
CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
CHECK_EQ(14, env->Global()->Get(v8_str("result"))->Int32Value());
"function f() { g(); };"
"result = new f() instanceof f;");
}
- NonIncrementalGC(CcTest::i_isolate());
+ NonIncrementalGC();
CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
CHECK(env->Global()->Get(v8_str("result"))->IsTrue());
"result = new f(1, 2);"
"result = result.x + result.y;");
}
- NonIncrementalGC(CcTest::i_isolate());
+ NonIncrementalGC();
CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
CHECK_EQ(3, env->Global()->Get(v8_str("result"))->Int32Value());
"function f1(x) { this.result = new f2(x + 1, x + 1).result + x; };"
"result = new f1(1).result;");
}
- NonIncrementalGC(CcTest::i_isolate());
+ NonIncrementalGC();
CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
CHECK_EQ(14, env->Global()->Get(v8_str("result"))->Int32Value());
}
-UNINITIALIZED_TEST(DeoptimizeBinaryOperationADDString) {
+TEST(DeoptimizeBinaryOperationADDString) {
i::FLAG_turbo_deoptimization = true;
i::FLAG_concurrent_recompilation = false;
AllowNativesSyntaxNoInlining options;
- v8::Isolate* isolate = v8::Isolate::New();
- i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
- isolate->Enter();
- {
- LocalContext env(isolate);
- v8::HandleScope scope(env->GetIsolate());
-
- const char* f_source = "function f(x, y) { return x + y; };";
-
- {
- // Compile function f and collect to type feedback to insert binary op
- // stub call in the optimized code.
- i::FLAG_prepare_always_opt = true;
- CompileRun(
- "var count = 0;"
- "var result = 0;"
- "var deopt = false;"
- "function X() { };"
- "X.prototype.toString = function () {"
- " if (deopt) { count++; %DeoptimizeFunction(f); } return 'an X'"
- "};");
- CompileRun(f_source);
- CompileRun(
- "for (var i = 0; i < 5; i++) {"
- " f('a+', new X());"
- "};");
-
- // Compile an optimized version of f.
- i::FLAG_always_opt = true;
- CompileRun(f_source);
- CompileRun("f('a+', new X());");
- CHECK(!i_isolate->use_crankshaft() ||
- GetJSFunction(env->Global(), "f")->IsOptimized());
-
- // Call f and force deoptimization while processing the binary operation.
- CompileRun(
- "deopt = true;"
- "var result = f('a+', new X());");
- }
- NonIncrementalGC(i_isolate);
+ LocalContext env;
+ v8::HandleScope scope(env->GetIsolate());
- CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized());
- CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
- v8::Handle<v8::Value> result = env->Global()->Get(v8_str("result"));
- CHECK(result->IsString());
- v8::String::Utf8Value utf8(result);
- CHECK_EQ("a+an X", *utf8);
- CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(i_isolate));
+ const char* f_source = "function f(x, y) { return x + y; };";
+
+ {
+ // Compile function f and collect to type feedback to insert binary op stub
+ // call in the optimized code.
+ i::FLAG_prepare_always_opt = true;
+ CompileRun("var count = 0;"
+ "var result = 0;"
+ "var deopt = false;"
+ "function X() { };"
+ "X.prototype.toString = function () {"
+ " if (deopt) { count++; %DeoptimizeFunction(f); } return 'an X'"
+ "};");
+ CompileRun(f_source);
+ CompileRun("for (var i = 0; i < 5; i++) {"
+ " f('a+', new X());"
+ "};");
+
+ // Compile an optimized version of f.
+ i::FLAG_always_opt = true;
+ CompileRun(f_source);
+ CompileRun("f('a+', new X());");
+ CHECK(!CcTest::i_isolate()->use_crankshaft() ||
+ GetJSFunction(env->Global(), "f")->IsOptimized());
+
+ // Call f and force deoptimization while processing the binary operation.
+ CompileRun("deopt = true;"
+ "var result = f('a+', new X());");
}
- isolate->Exit();
- isolate->Dispose();
+ NonIncrementalGC();
+
+ CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized());
+ CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
+ v8::Handle<v8::Value> result = env->Global()->Get(v8_str("result"));
+ CHECK(result->IsString());
+ v8::String::Utf8Value utf8(result);
+ CHECK_EQ("a+an X", *utf8);
+ CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate()));
}
static void TestDeoptimizeBinaryOpHelper(LocalContext* env,
const char* binary_op) {
- i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>((*env)->GetIsolate());
EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> f_source_buffer;
SNPrintF(f_source_buffer,
"function f(x, y) { return x %s y; };",
i::FLAG_always_opt = true;
CompileRun(f_source);
CompileRun("f(7, new X());");
- CHECK(!i_isolate->use_crankshaft() ||
+ CHECK(!CcTest::i_isolate()->use_crankshaft() ||
GetJSFunction((*env)->Global(), "f")->IsOptimized());
// Call f and force deoptimization while processing the binary operation.
CompileRun("deopt = true;"
"var result = f(7, new X());");
- NonIncrementalGC(i_isolate);
+ NonIncrementalGC();
CHECK(!GetJSFunction((*env)->Global(), "f")->IsOptimized());
}
-UNINITIALIZED_TEST(DeoptimizeBinaryOperationADD) {
+TEST(DeoptimizeBinaryOperationADD) {
i::FLAG_turbo_deoptimization = true;
i::FLAG_concurrent_recompilation = false;
- v8::Isolate* isolate = v8::Isolate::New();
- i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
- isolate->Enter();
- {
- LocalContext env(isolate);
- v8::HandleScope scope(env->GetIsolate());
+ LocalContext env;
+ v8::HandleScope scope(env->GetIsolate());
- TestDeoptimizeBinaryOpHelper(&env, "+");
+ TestDeoptimizeBinaryOpHelper(&env, "+");
- CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
- CHECK_EQ(15, env->Global()->Get(v8_str("result"))->Int32Value());
- CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(i_isolate));
- }
- isolate->Exit();
- isolate->Dispose();
+ CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
+ CHECK_EQ(15, env->Global()->Get(v8_str("result"))->Int32Value());
+ CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate()));
}
-UNINITIALIZED_TEST(DeoptimizeBinaryOperationSUB) {
+TEST(DeoptimizeBinaryOperationSUB) {
i::FLAG_turbo_deoptimization = true;
i::FLAG_concurrent_recompilation = false;
- v8::Isolate* isolate = v8::Isolate::New();
- i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
- isolate->Enter();
- {
- LocalContext env(isolate);
- v8::HandleScope scope(env->GetIsolate());
+ LocalContext env;
+ v8::HandleScope scope(env->GetIsolate());
- TestDeoptimizeBinaryOpHelper(&env, "-");
+ TestDeoptimizeBinaryOpHelper(&env, "-");
- CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
- CHECK_EQ(-1, env->Global()->Get(v8_str("result"))->Int32Value());
- CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(i_isolate));
- }
- isolate->Exit();
- isolate->Dispose();
+ CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
+ CHECK_EQ(-1, env->Global()->Get(v8_str("result"))->Int32Value());
+ CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate()));
}
-UNINITIALIZED_TEST(DeoptimizeBinaryOperationMUL) {
+TEST(DeoptimizeBinaryOperationMUL) {
i::FLAG_turbo_deoptimization = true;
i::FLAG_concurrent_recompilation = false;
- v8::Isolate* isolate = v8::Isolate::New();
- i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
- isolate->Enter();
- {
- LocalContext env(isolate);
- v8::HandleScope scope(env->GetIsolate());
+ LocalContext env;
+ v8::HandleScope scope(env->GetIsolate());
- TestDeoptimizeBinaryOpHelper(&env, "*");
+ TestDeoptimizeBinaryOpHelper(&env, "*");
- CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
- CHECK_EQ(56, env->Global()->Get(v8_str("result"))->Int32Value());
- CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(i_isolate));
- }
- isolate->Exit();
- isolate->Dispose();
+ CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
+ CHECK_EQ(56, env->Global()->Get(v8_str("result"))->Int32Value());
+ CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate()));
}
-UNINITIALIZED_TEST(DeoptimizeBinaryOperationDIV) {
+TEST(DeoptimizeBinaryOperationDIV) {
i::FLAG_turbo_deoptimization = true;
i::FLAG_concurrent_recompilation = false;
- v8::Isolate* isolate = v8::Isolate::New();
- i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
- isolate->Enter();
- {
- LocalContext env(isolate);
- v8::HandleScope scope(env->GetIsolate());
+ LocalContext env;
+ v8::HandleScope scope(env->GetIsolate());
- TestDeoptimizeBinaryOpHelper(&env, "/");
+ TestDeoptimizeBinaryOpHelper(&env, "/");
- CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
- CHECK_EQ(0, env->Global()->Get(v8_str("result"))->Int32Value());
- CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(i_isolate));
- }
- isolate->Exit();
- isolate->Dispose();
+ CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
+ CHECK_EQ(0, env->Global()->Get(v8_str("result"))->Int32Value());
+ CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate()));
}
-UNINITIALIZED_TEST(DeoptimizeBinaryOperationMOD) {
+TEST(DeoptimizeBinaryOperationMOD) {
i::FLAG_turbo_deoptimization = true;
i::FLAG_concurrent_recompilation = false;
- v8::Isolate* isolate = v8::Isolate::New();
- i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
- isolate->Enter();
- {
- LocalContext env(isolate);
- v8::HandleScope scope(env->GetIsolate());
+ LocalContext env;
+ v8::HandleScope scope(env->GetIsolate());
- TestDeoptimizeBinaryOpHelper(&env, "%");
+ TestDeoptimizeBinaryOpHelper(&env, "%");
- CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
- CHECK_EQ(7, env->Global()->Get(v8_str("result"))->Int32Value());
- CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(i_isolate));
- }
- isolate->Exit();
- isolate->Dispose();
+ CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
+ CHECK_EQ(7, env->Global()->Get(v8_str("result"))->Int32Value());
+ CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate()));
}
-UNINITIALIZED_TEST(DeoptimizeCompare) {
+TEST(DeoptimizeCompare) {
i::FLAG_turbo_deoptimization = true;
i::FLAG_concurrent_recompilation = false;
- v8::Isolate* isolate = v8::Isolate::New();
- i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
- isolate->Enter();
- {
- LocalContext env(isolate);
- v8::HandleScope scope(env->GetIsolate());
-
- const char* f_source = "function f(x, y) { return x < y; };";
-
- {
- AllowNativesSyntaxNoInlining options;
- // Compile function f and collect to type feedback to insert compare ic
- // call in the optimized code.
- i::FLAG_prepare_always_opt = true;
- CompileRun(
- "var count = 0;"
- "var result = 0;"
- "var deopt = false;"
- "function X() { };"
- "X.prototype.toString = function () {"
- " if (deopt) { count++; %DeoptimizeFunction(f); } return 'b'"
- "};");
- CompileRun(f_source);
- CompileRun(
- "for (var i = 0; i < 5; i++) {"
- " f('a', new X());"
- "};");
-
- // Compile an optimized version of f.
- i::FLAG_always_opt = true;
- CompileRun(f_source);
- CompileRun("f('a', new X());");
- CHECK(!i_isolate->use_crankshaft() ||
- GetJSFunction(env->Global(), "f")->IsOptimized());
-
- // Call f and force deoptimization while processing the comparison.
- CompileRun(
- "deopt = true;"
- "var result = f('a', new X());");
- }
- NonIncrementalGC(i_isolate);
+ LocalContext env;
+ v8::HandleScope scope(env->GetIsolate());
- CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized());
- CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
- CHECK_EQ(true, env->Global()->Get(v8_str("result"))->BooleanValue());
- CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(i_isolate));
+ const char* f_source = "function f(x, y) { return x < y; };";
+
+ {
+ AllowNativesSyntaxNoInlining options;
+ // Compile function f and collect to type feedback to insert compare ic
+ // call in the optimized code.
+ i::FLAG_prepare_always_opt = true;
+ CompileRun("var count = 0;"
+ "var result = 0;"
+ "var deopt = false;"
+ "function X() { };"
+ "X.prototype.toString = function () {"
+ " if (deopt) { count++; %DeoptimizeFunction(f); } return 'b'"
+ "};");
+ CompileRun(f_source);
+ CompileRun("for (var i = 0; i < 5; i++) {"
+ " f('a', new X());"
+ "};");
+
+ // Compile an optimized version of f.
+ i::FLAG_always_opt = true;
+ CompileRun(f_source);
+ CompileRun("f('a', new X());");
+ CHECK(!CcTest::i_isolate()->use_crankshaft() ||
+ GetJSFunction(env->Global(), "f")->IsOptimized());
+
+ // Call f and force deoptimization while processing the comparison.
+ CompileRun("deopt = true;"
+ "var result = f('a', new X());");
}
- isolate->Exit();
- isolate->Dispose();
+ NonIncrementalGC();
+
+ CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized());
+ CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
+ CHECK_EQ(true, env->Global()->Get(v8_str("result"))->BooleanValue());
+ CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate()));
}
-UNINITIALIZED_TEST(DeoptimizeLoadICStoreIC) {
+TEST(DeoptimizeLoadICStoreIC) {
i::FLAG_turbo_deoptimization = true;
i::FLAG_concurrent_recompilation = false;
- v8::Isolate* isolate = v8::Isolate::New();
- i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
- isolate->Enter();
+ LocalContext env;
+ v8::HandleScope scope(env->GetIsolate());
+
+ // Functions to generate load/store/keyed load/keyed store IC calls.
+ const char* f1_source = "function f1(x) { return x.y; };";
+ const char* g1_source = "function g1(x) { x.y = 1; };";
+ const char* f2_source = "function f2(x, y) { return x[y]; };";
+ const char* g2_source = "function g2(x, y) { x[y] = 1; };";
+
{
- LocalContext env(isolate);
- v8::HandleScope scope(env->GetIsolate());
-
- // Functions to generate load/store/keyed load/keyed store IC calls.
- const char* f1_source = "function f1(x) { return x.y; };";
- const char* g1_source = "function g1(x) { x.y = 1; };";
- const char* f2_source = "function f2(x, y) { return x[y]; };";
- const char* g2_source = "function g2(x, y) { x[y] = 1; };";
-
- {
- AllowNativesSyntaxNoInlining options;
- // Compile functions and collect to type feedback to insert ic
- // calls in the optimized code.
- i::FLAG_prepare_always_opt = true;
- CompileRun(
- "var count = 0;"
- "var result = 0;"
- "var deopt = false;"
- "function X() { };"
- "X.prototype.__defineGetter__('y', function () {"
- " if (deopt) { count++; %DeoptimizeFunction(f1); };"
- " return 13;"
- "});"
- "X.prototype.__defineSetter__('y', function () {"
- " if (deopt) { count++; %DeoptimizeFunction(g1); };"
- "});"
- "X.prototype.__defineGetter__('z', function () {"
- " if (deopt) { count++; %DeoptimizeFunction(f2); };"
- " return 13;"
- "});"
- "X.prototype.__defineSetter__('z', function () {"
- " if (deopt) { count++; %DeoptimizeFunction(g2); };"
- "});");
- CompileRun(f1_source);
- CompileRun(g1_source);
- CompileRun(f2_source);
- CompileRun(g2_source);
- CompileRun(
- "for (var i = 0; i < 5; i++) {"
- " f1(new X());"
- " g1(new X());"
- " f2(new X(), 'z');"
- " g2(new X(), 'z');"
- "};");
-
- // Compile an optimized version of the functions.
- i::FLAG_always_opt = true;
- CompileRun(f1_source);
- CompileRun(g1_source);
- CompileRun(f2_source);
- CompileRun(g2_source);
- CompileRun("f1(new X());");
- CompileRun("g1(new X());");
- CompileRun("f2(new X(), 'z');");
- CompileRun("g2(new X(), 'z');");
- if (i_isolate->use_crankshaft()) {
- CHECK(GetJSFunction(env->Global(), "f1")->IsOptimized());
- CHECK(GetJSFunction(env->Global(), "g1")->IsOptimized());
- CHECK(GetJSFunction(env->Global(), "f2")->IsOptimized());
- CHECK(GetJSFunction(env->Global(), "g2")->IsOptimized());
- }
-
- // Call functions and force deoptimization while processing the ics.
- CompileRun(
- "deopt = true;"
- "var result = f1(new X());"
- "g1(new X());"
- "f2(new X(), 'z');"
- "g2(new X(), 'z');");
+ AllowNativesSyntaxNoInlining options;
+ // Compile functions and collect to type feedback to insert ic
+ // calls in the optimized code.
+ i::FLAG_prepare_always_opt = true;
+ CompileRun("var count = 0;"
+ "var result = 0;"
+ "var deopt = false;"
+ "function X() { };"
+ "X.prototype.__defineGetter__('y', function () {"
+ " if (deopt) { count++; %DeoptimizeFunction(f1); };"
+ " return 13;"
+ "});"
+ "X.prototype.__defineSetter__('y', function () {"
+ " if (deopt) { count++; %DeoptimizeFunction(g1); };"
+ "});"
+ "X.prototype.__defineGetter__('z', function () {"
+ " if (deopt) { count++; %DeoptimizeFunction(f2); };"
+ " return 13;"
+ "});"
+ "X.prototype.__defineSetter__('z', function () {"
+ " if (deopt) { count++; %DeoptimizeFunction(g2); };"
+ "});");
+ CompileRun(f1_source);
+ CompileRun(g1_source);
+ CompileRun(f2_source);
+ CompileRun(g2_source);
+ CompileRun("for (var i = 0; i < 5; i++) {"
+ " f1(new X());"
+ " g1(new X());"
+ " f2(new X(), 'z');"
+ " g2(new X(), 'z');"
+ "};");
+
+ // Compile an optimized version of the functions.
+ i::FLAG_always_opt = true;
+ CompileRun(f1_source);
+ CompileRun(g1_source);
+ CompileRun(f2_source);
+ CompileRun(g2_source);
+ CompileRun("f1(new X());");
+ CompileRun("g1(new X());");
+ CompileRun("f2(new X(), 'z');");
+ CompileRun("g2(new X(), 'z');");
+ if (CcTest::i_isolate()->use_crankshaft()) {
+ CHECK(GetJSFunction(env->Global(), "f1")->IsOptimized());
+ CHECK(GetJSFunction(env->Global(), "g1")->IsOptimized());
+ CHECK(GetJSFunction(env->Global(), "f2")->IsOptimized());
+ CHECK(GetJSFunction(env->Global(), "g2")->IsOptimized());
}
- NonIncrementalGC(i_isolate);
-
- CHECK(!GetJSFunction(env->Global(), "f1")->IsOptimized());
- CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized());
- CHECK(!GetJSFunction(env->Global(), "f2")->IsOptimized());
- CHECK(!GetJSFunction(env->Global(), "g2")->IsOptimized());
- CHECK_EQ(4, env->Global()->Get(v8_str("count"))->Int32Value());
- CHECK_EQ(13, env->Global()->Get(v8_str("result"))->Int32Value());
+
+ // Call functions and force deoptimization while processing the ics.
+ CompileRun("deopt = true;"
+ "var result = f1(new X());"
+ "g1(new X());"
+ "f2(new X(), 'z');"
+ "g2(new X(), 'z');");
}
- isolate->Exit();
- isolate->Dispose();
+ NonIncrementalGC();
+
+ CHECK(!GetJSFunction(env->Global(), "f1")->IsOptimized());
+ CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized());
+ CHECK(!GetJSFunction(env->Global(), "f2")->IsOptimized());
+ CHECK(!GetJSFunction(env->Global(), "g2")->IsOptimized());
+ CHECK_EQ(4, env->Global()->Get(v8_str("count"))->Int32Value());
+ CHECK_EQ(13, env->Global()->Get(v8_str("result"))->Int32Value());
}
-UNINITIALIZED_TEST(DeoptimizeLoadICStoreICNested) {
+TEST(DeoptimizeLoadICStoreICNested) {
i::FLAG_turbo_deoptimization = true;
i::FLAG_concurrent_recompilation = false;
- v8::Isolate* isolate = v8::Isolate::New();
- i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
- isolate->Enter();
+ LocalContext env;
+ v8::HandleScope scope(env->GetIsolate());
+
+ // Functions to generate load/store/keyed load/keyed store IC calls.
+ const char* f1_source = "function f1(x) { return x.y; };";
+ const char* g1_source = "function g1(x) { x.y = 1; };";
+ const char* f2_source = "function f2(x, y) { return x[y]; };";
+ const char* g2_source = "function g2(x, y) { x[y] = 1; };";
+
{
- LocalContext env(isolate);
- v8::HandleScope scope(env->GetIsolate());
-
- // Functions to generate load/store/keyed load/keyed store IC calls.
- const char* f1_source = "function f1(x) { return x.y; };";
- const char* g1_source = "function g1(x) { x.y = 1; };";
- const char* f2_source = "function f2(x, y) { return x[y]; };";
- const char* g2_source = "function g2(x, y) { x[y] = 1; };";
-
- {
- AllowNativesSyntaxNoInlining options;
- // Compile functions and collect to type feedback to insert ic
- // calls in the optimized code.
- i::FLAG_prepare_always_opt = true;
- CompileRun(
- "var count = 0;"
- "var result = 0;"
- "var deopt = false;"
- "function X() { };"
- "X.prototype.__defineGetter__('y', function () {"
- " g1(this);"
- " return 13;"
- "});"
- "X.prototype.__defineSetter__('y', function () {"
- " f2(this, 'z');"
- "});"
- "X.prototype.__defineGetter__('z', function () {"
- " g2(this, 'z');"
- "});"
- "X.prototype.__defineSetter__('z', function () {"
- " if (deopt) {"
- " count++;"
- " %DeoptimizeFunction(f1);"
- " %DeoptimizeFunction(g1);"
- " %DeoptimizeFunction(f2);"
- " %DeoptimizeFunction(g2); };"
- "});");
- CompileRun(f1_source);
- CompileRun(g1_source);
- CompileRun(f2_source);
- CompileRun(g2_source);
- CompileRun(
- "for (var i = 0; i < 5; i++) {"
- " f1(new X());"
- " g1(new X());"
- " f2(new X(), 'z');"
- " g2(new X(), 'z');"
- "};");
-
- // Compile an optimized version of the functions.
- i::FLAG_always_opt = true;
- CompileRun(f1_source);
- CompileRun(g1_source);
- CompileRun(f2_source);
- CompileRun(g2_source);
- CompileRun("f1(new X());");
- CompileRun("g1(new X());");
- CompileRun("f2(new X(), 'z');");
- CompileRun("g2(new X(), 'z');");
- if (i_isolate->use_crankshaft()) {
- CHECK(GetJSFunction(env->Global(), "f1")->IsOptimized());
- CHECK(GetJSFunction(env->Global(), "g1")->IsOptimized());
- CHECK(GetJSFunction(env->Global(), "f2")->IsOptimized());
- CHECK(GetJSFunction(env->Global(), "g2")->IsOptimized());
- }
-
- // Call functions and force deoptimization while processing the ics.
- CompileRun(
- "deopt = true;"
- "var result = f1(new X());");
+ AllowNativesSyntaxNoInlining options;
+ // Compile functions and collect to type feedback to insert ic
+ // calls in the optimized code.
+ i::FLAG_prepare_always_opt = true;
+ CompileRun("var count = 0;"
+ "var result = 0;"
+ "var deopt = false;"
+ "function X() { };"
+ "X.prototype.__defineGetter__('y', function () {"
+ " g1(this);"
+ " return 13;"
+ "});"
+ "X.prototype.__defineSetter__('y', function () {"
+ " f2(this, 'z');"
+ "});"
+ "X.prototype.__defineGetter__('z', function () {"
+ " g2(this, 'z');"
+ "});"
+ "X.prototype.__defineSetter__('z', function () {"
+ " if (deopt) {"
+ " count++;"
+ " %DeoptimizeFunction(f1);"
+ " %DeoptimizeFunction(g1);"
+ " %DeoptimizeFunction(f2);"
+ " %DeoptimizeFunction(g2); };"
+ "});");
+ CompileRun(f1_source);
+ CompileRun(g1_source);
+ CompileRun(f2_source);
+ CompileRun(g2_source);
+ CompileRun("for (var i = 0; i < 5; i++) {"
+ " f1(new X());"
+ " g1(new X());"
+ " f2(new X(), 'z');"
+ " g2(new X(), 'z');"
+ "};");
+
+ // Compile an optimized version of the functions.
+ i::FLAG_always_opt = true;
+ CompileRun(f1_source);
+ CompileRun(g1_source);
+ CompileRun(f2_source);
+ CompileRun(g2_source);
+ CompileRun("f1(new X());");
+ CompileRun("g1(new X());");
+ CompileRun("f2(new X(), 'z');");
+ CompileRun("g2(new X(), 'z');");
+ if (CcTest::i_isolate()->use_crankshaft()) {
+ CHECK(GetJSFunction(env->Global(), "f1")->IsOptimized());
+ CHECK(GetJSFunction(env->Global(), "g1")->IsOptimized());
+ CHECK(GetJSFunction(env->Global(), "f2")->IsOptimized());
+ CHECK(GetJSFunction(env->Global(), "g2")->IsOptimized());
}
- NonIncrementalGC(i_isolate);
- CHECK(!GetJSFunction(env->Global(), "f1")->IsOptimized());
- CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized());
- CHECK(!GetJSFunction(env->Global(), "f2")->IsOptimized());
- CHECK(!GetJSFunction(env->Global(), "g2")->IsOptimized());
- CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
- CHECK_EQ(13, env->Global()->Get(v8_str("result"))->Int32Value());
+ // Call functions and force deoptimization while processing the ics.
+ CompileRun("deopt = true;"
+ "var result = f1(new X());");
}
- isolate->Exit();
- isolate->Dispose();
+ NonIncrementalGC();
+
+ CHECK(!GetJSFunction(env->Global(), "f1")->IsOptimized());
+ CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized());
+ CHECK(!GetJSFunction(env->Global(), "f2")->IsOptimized());
+ CHECK(!GetJSFunction(env->Global(), "g2")->IsOptimized());
+ CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
+ CHECK_EQ(13, env->Global()->Get(v8_str("result"))->Int32Value());
}
}
-UNINITIALIZED_TEST(TestCodeFlushing) {
+TEST(TestCodeFlushing) {
// If we do not flush code this test is invalid.
if (!FLAG_flush_code) return;
i::FLAG_allow_natives_syntax = true;
i::FLAG_optimize_for_size = false;
- v8::Isolate* isolate = v8::Isolate::New();
- i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
- isolate->Enter();
- Factory* factory = i_isolate->factory();
- {
- v8::HandleScope scope(isolate);
- v8::Context::New(isolate)->Enter();
- const char* source =
- "function foo() {"
- " var x = 42;"
- " var y = 42;"
- " var z = x + y;"
- "};"
- "foo()";
- Handle<String> foo_name = factory->InternalizeUtf8String("foo");
-
- // This compile will add the code to the compilation cache.
- {
- v8::HandleScope scope(isolate);
- CompileRun(source);
- }
+ CcTest::InitializeVM();
+ Isolate* isolate = CcTest::i_isolate();
+ Factory* factory = isolate->factory();
+ v8::HandleScope scope(CcTest::isolate());
+ const char* source = "function foo() {"
+ " var x = 42;"
+ " var y = 42;"
+ " var z = x + y;"
+ "};"
+ "foo()";
+ Handle<String> foo_name = factory->InternalizeUtf8String("foo");
- // Check function is compiled.
- Handle<Object> func_value = Object::GetProperty(i_isolate->global_object(),
- foo_name).ToHandleChecked();
- CHECK(func_value->IsJSFunction());
- Handle<JSFunction> function = Handle<JSFunction>::cast(func_value);
- CHECK(function->shared()->is_compiled());
+ // This compile will add the code to the compilation cache.
+ { v8::HandleScope scope(CcTest::isolate());
+ CompileRun(source);
+ }
- // The code will survive at least two GCs.
- i_isolate->heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
- i_isolate->heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
- CHECK(function->shared()->is_compiled());
+ // Check function is compiled.
+ Handle<Object> func_value = Object::GetProperty(
+ CcTest::i_isolate()->global_object(), foo_name).ToHandleChecked();
+ CHECK(func_value->IsJSFunction());
+ Handle<JSFunction> function = Handle<JSFunction>::cast(func_value);
+ CHECK(function->shared()->is_compiled());
- // Simulate several GCs that use full marking.
- const int kAgingThreshold = 6;
- for (int i = 0; i < kAgingThreshold; i++) {
- i_isolate->heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
- }
+ // The code will survive at least two GCs.
+ CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
+ CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
+ CHECK(function->shared()->is_compiled());
- // foo should no longer be in the compilation cache
- CHECK(!function->shared()->is_compiled() || function->IsOptimized());
- CHECK(!function->is_compiled() || function->IsOptimized());
- // Call foo to get it recompiled.
- CompileRun("foo()");
- CHECK(function->shared()->is_compiled());
- CHECK(function->is_compiled());
+ // Simulate several GCs that use full marking.
+ const int kAgingThreshold = 6;
+ for (int i = 0; i < kAgingThreshold; i++) {
+ CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
}
- isolate->Exit();
- isolate->Dispose();
+
+ // foo should no longer be in the compilation cache
+ CHECK(!function->shared()->is_compiled() || function->IsOptimized());
+ CHECK(!function->is_compiled() || function->IsOptimized());
+ // Call foo to get it recompiled.
+ CompileRun("foo()");
+ CHECK(function->shared()->is_compiled());
+ CHECK(function->is_compiled());
}
};
-void ReleaseStackTraceDataTest(v8::Isolate* isolate, const char* source,
- const char* accessor) {
+void ReleaseStackTraceDataTest(const char* source, const char* accessor) {
// Test that the data retained by the Error.stack accessor is released
// after the first time the accessor is fired. We use external string
// to check whether the data is being released since the external string
// resource's callback is fired when the external string is GC'ed.
- i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
- v8::HandleScope scope(isolate);
+ v8::HandleScope scope(CcTest::isolate());
SourceResource* resource = new SourceResource(i::StrDup(source));
{
- v8::HandleScope scope(isolate);
+ v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::String> source_string =
- v8::String::NewExternal(isolate, resource);
- i_isolate->heap()->CollectAllAvailableGarbage();
+ v8::String::NewExternal(CcTest::isolate(), resource);
+ CcTest::heap()->CollectAllAvailableGarbage();
v8::Script::Compile(source_string)->Run();
CHECK(!resource->IsDisposed());
}
- // i_isolate->heap()->CollectAllAvailableGarbage();
+ // CcTest::heap()->CollectAllAvailableGarbage();
CHECK(!resource->IsDisposed());
CompileRun(accessor);
- i_isolate->heap()->CollectAllAvailableGarbage();
+ CcTest::heap()->CollectAllAvailableGarbage();
// External source has been released.
CHECK(resource->IsDisposed());
}
-UNINITIALIZED_TEST(ReleaseStackTraceData) {
+TEST(ReleaseStackTraceData) {
if (i::FLAG_always_opt) {
// TODO(ulan): Remove this once the memory leak via code_next_link is fixed.
// See: https://codereview.chromium.org/181833004/
}
FLAG_use_ic = false; // ICs retain objects.
FLAG_concurrent_recompilation = false;
- v8::Isolate* isolate = v8::Isolate::New();
- {
- v8::Isolate::Scope isolate_scope(isolate);
- v8::HandleScope handle_scope(isolate);
- v8::Context::New(isolate)->Enter();
- static const char* source1 = "var error = null; "
- /* Normal Error */ "try { "
- " throw new Error(); "
- "} catch (e) { "
- " error = e; "
- "} ";
- static const char* source2 = "var error = null; "
- /* Stack overflow */ "try { "
- " (function f() { f(); })(); "
- "} catch (e) { "
- " error = e; "
- "} ";
- static const char* source3 = "var error = null; "
- /* Normal Error */ "try { "
- /* as prototype */ " throw new Error(); "
- "} catch (e) { "
- " error = {}; "
- " error.__proto__ = e; "
- "} ";
- static const char* source4 = "var error = null; "
- /* Stack overflow */ "try { "
- /* as prototype */ " (function f() { f(); })(); "
- "} catch (e) { "
- " error = {}; "
- " error.__proto__ = e; "
- "} ";
- static const char* getter = "error.stack";
- static const char* setter = "error.stack = 0";
-
- ReleaseStackTraceDataTest(isolate, source1, setter);
- ReleaseStackTraceDataTest(isolate, source2, setter);
- // We do not test source3 and source4 with setter, since the setter is
- // supposed to (untypically) write to the receiver, not the holder. This is
- // to emulate the behavior of a data property.
-
- ReleaseStackTraceDataTest(isolate, source1, getter);
- ReleaseStackTraceDataTest(isolate, source2, getter);
- ReleaseStackTraceDataTest(isolate, source3, getter);
- ReleaseStackTraceDataTest(isolate, source4, getter);
- }
+ CcTest::InitializeVM();
+ static const char* source1 = "var error = null; "
+ /* Normal Error */ "try { "
+ " throw new Error(); "
+ "} catch (e) { "
+ " error = e; "
+ "} ";
+ static const char* source2 = "var error = null; "
+ /* Stack overflow */ "try { "
+ " (function f() { f(); })(); "
+ "} catch (e) { "
+ " error = e; "
+ "} ";
+ static const char* source3 = "var error = null; "
+ /* Normal Error */ "try { "
+ /* as prototype */ " throw new Error(); "
+ "} catch (e) { "
+ " error = {}; "
+ " error.__proto__ = e; "
+ "} ";
+ static const char* source4 = "var error = null; "
+ /* Stack overflow */ "try { "
+ /* as prototype */ " (function f() { f(); })(); "
+ "} catch (e) { "
+ " error = {}; "
+ " error.__proto__ = e; "
+ "} ";
+ static const char* getter = "error.stack";
+ static const char* setter = "error.stack = 0";
+
+ ReleaseStackTraceDataTest(source1, setter);
+ ReleaseStackTraceDataTest(source2, setter);
+ // We do not test source3 and source4 with setter, since the setter is
+ // supposed to (untypically) write to the receiver, not the holder. This is
+ // to emulate the behavior of a data property.
+
+ ReleaseStackTraceDataTest(source1, getter);
+ ReleaseStackTraceDataTest(source2, getter);
+ ReleaseStackTraceDataTest(source3, getter);
+ ReleaseStackTraceDataTest(source4, getter);
}
}
-UNINITIALIZED_TEST(PromotionQueue) {
+TEST(PromotionQueue) {
i::FLAG_expose_gc = true;
i::FLAG_max_semi_space_size = 2;
- v8::Isolate* isolate = v8::Isolate::New();
- i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
- {
- v8::Isolate::Scope isolate_scope(isolate);
- v8::HandleScope handle_scope(isolate);
- v8::Context::New(isolate)->Enter();
- Heap* heap = i_isolate->heap();
- NewSpace* new_space = heap->new_space();
-
- // In this test we will try to overwrite the promotion queue which is at the
- // end of to-space. To actually make that possible, we need at least two
- // semi-space pages and take advantage of fragementation.
- // (1) Grow semi-space to two pages.
- // (2) Create a few small long living objects and call the scavenger to
- // move them to the other semi-space.
- // (3) Create a huge object, i.e., remainder of first semi-space page and
- // create another huge object which should be of maximum allocatable memory
- // size of the second semi-space page.
- // (4) Call the scavenger again.
- // What will happen is: the scavenger will promote the objects created in
- // (2) and will create promotion queue entries at the end of the second
- // semi-space page during the next scavenge when it promotes the objects to
- // the old generation. The first allocation of (3) will fill up the first
- // semi-space page. The second allocation in (3) will not fit into the
- // first semi-space page, but it will overwrite the promotion queue which
- // are in the second semi-space page. If the right guards are in place, the
- // promotion queue will be evacuated in that case.
-
- // Grow the semi-space to two pages to make semi-space copy overwrite the
- // promotion queue, which will be at the end of the second page.
- intptr_t old_capacity = new_space->TotalCapacity();
- new_space->Grow();
- CHECK(new_space->IsAtMaximumCapacity());
- CHECK(2 * old_capacity == new_space->TotalCapacity());
-
- // Call the scavenger two times to get an empty new space
- heap->CollectGarbage(NEW_SPACE);
- heap->CollectGarbage(NEW_SPACE);
-
- // First create a few objects which will survive a scavenge, and will get
- // promoted to the old generation later on. These objects will create
- // promotion queue entries at the end of the second semi-space page.
- const int number_handles = 12;
- Handle<FixedArray> handles[number_handles];
- for (int i = 0; i < number_handles; i++) {
- handles[i] = i_isolate->factory()->NewFixedArray(1, NOT_TENURED);
- }
- heap->CollectGarbage(NEW_SPACE);
-
- // Create the first huge object which will exactly fit the first semi-space
- // page.
- int new_linear_size =
- static_cast<int>(*heap->new_space()->allocation_limit_address() -
- *heap->new_space()->allocation_top_address());
- int length = new_linear_size / kPointerSize - FixedArray::kHeaderSize;
- Handle<FixedArray> first =
- i_isolate->factory()->NewFixedArray(length, NOT_TENURED);
- CHECK(heap->InNewSpace(*first));
-
- // Create the second huge object of maximum allocatable second semi-space
- // page size.
- new_linear_size =
- static_cast<int>(*heap->new_space()->allocation_limit_address() -
- *heap->new_space()->allocation_top_address());
- length = Page::kMaxRegularHeapObjectSize / kPointerSize -
- FixedArray::kHeaderSize;
- Handle<FixedArray> second =
- i_isolate->factory()->NewFixedArray(length, NOT_TENURED);
- CHECK(heap->InNewSpace(*second));
-
- // This scavenge will corrupt memory if the promotion queue is not
- // evacuated.
- heap->CollectGarbage(NEW_SPACE);
+ CcTest::InitializeVM();
+ v8::HandleScope scope(CcTest::isolate());
+ Isolate* isolate = CcTest::i_isolate();
+ Heap* heap = isolate->heap();
+ NewSpace* new_space = heap->new_space();
+
+ // In this test we will try to overwrite the promotion queue which is at the
+ // end of to-space. To actually make that possible, we need at least two
+ // semi-space pages and take advantage of fragementation.
+ // (1) Grow semi-space to two pages.
+ // (2) Create a few small long living objects and call the scavenger to
+ // move them to the other semi-space.
+ // (3) Create a huge object, i.e., remainder of first semi-space page and
+ // create another huge object which should be of maximum allocatable memory
+ // size of the second semi-space page.
+ // (4) Call the scavenger again.
+ // What will happen is: the scavenger will promote the objects created in (2)
+ // and will create promotion queue entries at the end of the second
+ // semi-space page during the next scavenge when it promotes the objects to
+ // the old generation. The first allocation of (3) will fill up the first
+ // semi-space page. The second allocation in (3) will not fit into the first
+ // semi-space page, but it will overwrite the promotion queue which are in
+ // the second semi-space page. If the right guards are in place, the promotion
+ // queue will be evacuated in that case.
+
+ // Grow the semi-space to two pages to make semi-space copy overwrite the
+ // promotion queue, which will be at the end of the second page.
+ intptr_t old_capacity = new_space->TotalCapacity();
+ new_space->Grow();
+ CHECK(new_space->IsAtMaximumCapacity());
+ CHECK(2 * old_capacity == new_space->TotalCapacity());
+
+ // Call the scavenger two times to get an empty new space
+ heap->CollectGarbage(NEW_SPACE);
+ heap->CollectGarbage(NEW_SPACE);
+
+ // First create a few objects which will survive a scavenge, and will get
+ // promoted to the old generation later on. These objects will create
+ // promotion queue entries at the end of the second semi-space page.
+ const int number_handles = 12;
+ Handle<FixedArray> handles[number_handles];
+ for (int i = 0; i < number_handles; i++) {
+ handles[i] = isolate->factory()->NewFixedArray(1, NOT_TENURED);
}
- isolate->Dispose();
+ heap->CollectGarbage(NEW_SPACE);
+
+ // Create the first huge object which will exactly fit the first semi-space
+ // page.
+ int new_linear_size = static_cast<int>(
+ *heap->new_space()->allocation_limit_address() -
+ *heap->new_space()->allocation_top_address());
+ int length = new_linear_size / kPointerSize - FixedArray::kHeaderSize;
+ Handle<FixedArray> first =
+ isolate->factory()->NewFixedArray(length, NOT_TENURED);
+ CHECK(heap->InNewSpace(*first));
+
+ // Create the second huge object of maximum allocatable second semi-space
+ // page size.
+ new_linear_size = static_cast<int>(
+ *heap->new_space()->allocation_limit_address() -
+ *heap->new_space()->allocation_top_address());
+ length = Page::kMaxRegularHeapObjectSize / kPointerSize -
+ FixedArray::kHeaderSize;
+ Handle<FixedArray> second =
+ isolate->factory()->NewFixedArray(length, NOT_TENURED);
+ CHECK(heap->InNewSpace(*second));
+
+ // This scavenge will corrupt memory if the promotion queue is not evacuated.
+ heap->CollectGarbage(NEW_SPACE);
}
// --- T h e A c t u a l T e s t s
TEST(LiveEditDiffer) {
+ v8::internal::V8::Initialize(NULL);
CompareStrings("zz1zzz12zz123zzz", "zzzzzzzzzz", 6);
CompareStrings("zz1zzz12zz123zzz", "zz0zzz0zz0zzz", 9);
CompareStrings("123456789", "987654321", 16);
temp_file_(NULL),
// Need to run this prior to creating the scope.
trick_to_run_init_flags_(init_flags_()),
- isolate_(v8::Isolate::New()),
- isolate_scope_(isolate_),
- scope_(isolate_),
- env_(v8::Context::New(isolate_)),
- logger_(reinterpret_cast<i::Isolate*>(isolate_)->logger()) {
+ scope_(CcTest::isolate()),
+ env_(v8::Context::New(CcTest::isolate())),
+ logger_(CcTest::i_isolate()->logger()) {
env_->Enter();
}
v8::Handle<v8::Context>& env() { return env_; }
- v8::Isolate* isolate() { return isolate_; }
-
Logger* logger() { return logger_; }
FILE* StopLoggingGetTempFile() {
const bool saved_prof_;
FILE* temp_file_;
const bool trick_to_run_init_flags_;
- v8::Isolate* isolate_;
- v8::Isolate::Scope isolate_scope_;
v8::HandleScope scope_;
v8::Handle<v8::Context> env_;
Logger* logger_;
TEST(LogCallbacks) {
- v8::Isolate* isolate;
- {
- ScopedLoggerInitializer initialize_logger;
- isolate = initialize_logger.isolate();
- Logger* logger = initialize_logger.logger();
-
- v8::Local<v8::FunctionTemplate> obj = v8::Local<v8::FunctionTemplate>::New(
- isolate, v8::FunctionTemplate::New(isolate));
- obj->SetClassName(v8_str("Obj"));
- v8::Handle<v8::ObjectTemplate> proto = obj->PrototypeTemplate();
- v8::Local<v8::Signature> signature = v8::Signature::New(isolate, obj);
- proto->Set(v8_str("method1"),
- v8::FunctionTemplate::New(isolate, ObjMethod1,
- v8::Handle<v8::Value>(), signature),
- static_cast<v8::PropertyAttribute>(v8::DontDelete));
-
- initialize_logger.env()->Global()->Set(v8_str("Obj"), obj->GetFunction());
- CompileRun("Obj.prototype.method1.toString();");
-
- logger->LogCompiledFunctions();
-
- bool exists = false;
- i::Vector<const char> log(
- i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true));
- CHECK(exists);
-
- i::EmbeddedVector<char, 100> ref_data;
- i::SNPrintF(ref_data,
- "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"method1\"",
- reinterpret_cast<intptr_t>(ObjMethod1));
-
- CHECK_NE(NULL, StrNStr(log.start(), ref_data.start(), log.length()));
- log.Dispose();
- }
- isolate->Dispose();
+ v8::Isolate* isolate = CcTest::isolate();
+ ScopedLoggerInitializer initialize_logger;
+ Logger* logger = initialize_logger.logger();
+
+ v8::Local<v8::FunctionTemplate> obj =
+ v8::Local<v8::FunctionTemplate>::New(isolate,
+ v8::FunctionTemplate::New(isolate));
+ obj->SetClassName(v8_str("Obj"));
+ v8::Handle<v8::ObjectTemplate> proto = obj->PrototypeTemplate();
+ v8::Local<v8::Signature> signature =
+ v8::Signature::New(isolate, obj);
+ proto->Set(v8_str("method1"),
+ v8::FunctionTemplate::New(isolate,
+ ObjMethod1,
+ v8::Handle<v8::Value>(),
+ signature),
+ static_cast<v8::PropertyAttribute>(v8::DontDelete));
+
+ initialize_logger.env()->Global()->Set(v8_str("Obj"), obj->GetFunction());
+ CompileRun("Obj.prototype.method1.toString();");
+
+ logger->LogCompiledFunctions();
+
+ bool exists = false;
+ i::Vector<const char> log(
+ i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true));
+ CHECK(exists);
+
+ i::EmbeddedVector<char, 100> ref_data;
+ i::SNPrintF(ref_data,
+ "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"method1\"",
+ reinterpret_cast<intptr_t>(ObjMethod1));
+
+ CHECK_NE(NULL, StrNStr(log.start(), ref_data.start(), log.length()));
+ log.Dispose();
}
TEST(LogAccessorCallbacks) {
- v8::Isolate* isolate;
- {
- ScopedLoggerInitializer initialize_logger;
- isolate = initialize_logger.isolate();
- Logger* logger = initialize_logger.logger();
-
- v8::Local<v8::FunctionTemplate> obj = v8::Local<v8::FunctionTemplate>::New(
- isolate, v8::FunctionTemplate::New(isolate));
- obj->SetClassName(v8_str("Obj"));
- v8::Handle<v8::ObjectTemplate> inst = obj->InstanceTemplate();
- inst->SetAccessor(v8_str("prop1"), Prop1Getter, Prop1Setter);
- inst->SetAccessor(v8_str("prop2"), Prop2Getter);
-
- logger->LogAccessorCallbacks();
-
- bool exists = false;
- i::Vector<const char> log(
- i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true));
- CHECK(exists);
-
- EmbeddedVector<char, 100> prop1_getter_record;
- i::SNPrintF(prop1_getter_record,
- "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"get prop1\"",
- reinterpret_cast<intptr_t>(Prop1Getter));
- CHECK_NE(NULL,
- StrNStr(log.start(), prop1_getter_record.start(), log.length()));
-
- EmbeddedVector<char, 100> prop1_setter_record;
- i::SNPrintF(prop1_setter_record,
- "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"set prop1\"",
- reinterpret_cast<intptr_t>(Prop1Setter));
- CHECK_NE(NULL,
- StrNStr(log.start(), prop1_setter_record.start(), log.length()));
-
- EmbeddedVector<char, 100> prop2_getter_record;
- i::SNPrintF(prop2_getter_record,
- "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"get prop2\"",
- reinterpret_cast<intptr_t>(Prop2Getter));
- CHECK_NE(NULL,
- StrNStr(log.start(), prop2_getter_record.start(), log.length()));
- log.Dispose();
- }
- isolate->Dispose();
+ v8::Isolate* isolate = CcTest::isolate();
+ ScopedLoggerInitializer initialize_logger;
+ Logger* logger = initialize_logger.logger();
+
+ v8::Local<v8::FunctionTemplate> obj =
+ v8::Local<v8::FunctionTemplate>::New(isolate,
+ v8::FunctionTemplate::New(isolate));
+ obj->SetClassName(v8_str("Obj"));
+ v8::Handle<v8::ObjectTemplate> inst = obj->InstanceTemplate();
+ inst->SetAccessor(v8_str("prop1"), Prop1Getter, Prop1Setter);
+ inst->SetAccessor(v8_str("prop2"), Prop2Getter);
+
+ logger->LogAccessorCallbacks();
+
+ bool exists = false;
+ i::Vector<const char> log(
+ i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true));
+ CHECK(exists);
+
+ EmbeddedVector<char, 100> prop1_getter_record;
+ i::SNPrintF(prop1_getter_record,
+ "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"get prop1\"",
+ reinterpret_cast<intptr_t>(Prop1Getter));
+ CHECK_NE(NULL,
+ StrNStr(log.start(), prop1_getter_record.start(), log.length()));
+
+ EmbeddedVector<char, 100> prop1_setter_record;
+ i::SNPrintF(prop1_setter_record,
+ "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"set prop1\"",
+ reinterpret_cast<intptr_t>(Prop1Setter));
+ CHECK_NE(NULL,
+ StrNStr(log.start(), prop1_setter_record.start(), log.length()));
+
+ EmbeddedVector<char, 100> prop2_getter_record;
+ i::SNPrintF(prop2_getter_record,
+ "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"get prop2\"",
+ reinterpret_cast<intptr_t>(Prop2Getter));
+ CHECK_NE(NULL,
+ StrNStr(log.start(), prop2_getter_record.start(), log.length()));
+ log.Dispose();
}
// are using V8.
// Start with profiling to capture all code events from the beginning.
- v8::Isolate* isolate;
- {
- ScopedLoggerInitializer initialize_logger;
- isolate = initialize_logger.isolate();
- Logger* logger = initialize_logger.logger();
-
- // Compile and run a function that creates other functions.
- CompileRun(
- "(function f(obj) {\n"
- " obj.test =\n"
- " (function a(j) { return function b() { return j; } })(100);\n"
- "})(this);");
- logger->StopProfiler();
- reinterpret_cast<i::Isolate*>(isolate)->heap()->CollectAllGarbage(
- i::Heap::kMakeHeapIterableMask);
- logger->StringEvent("test-logging-done", "");
-
- // Iterate heap to find compiled functions, will write to log.
- logger->LogCompiledFunctions();
- logger->StringEvent("test-traversal-done", "");
-
- bool exists = false;
- i::Vector<const char> log(
- i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true));
- CHECK(exists);
- v8::Handle<v8::String> log_str = v8::String::NewFromUtf8(
- isolate, log.start(), v8::String::kNormalString, log.length());
- initialize_logger.env()->Global()->Set(v8_str("_log"), log_str);
-
- i::Vector<const unsigned char> source = TestSources::GetScriptsSource();
- v8::Handle<v8::String> source_str = v8::String::NewFromUtf8(
- isolate, reinterpret_cast<const char*>(source.start()),
- v8::String::kNormalString, source.length());
- v8::TryCatch try_catch;
- v8::Handle<v8::Script> script = CompileWithOrigin(source_str, "");
- if (script.IsEmpty()) {
- v8::String::Utf8Value exception(try_catch.Exception());
- printf("compile: %s\n", *exception);
- CHECK(false);
- }
- v8::Handle<v8::Value> result = script->Run();
- if (result.IsEmpty()) {
- v8::String::Utf8Value exception(try_catch.Exception());
- printf("run: %s\n", *exception);
- CHECK(false);
- }
- // The result either be a "true" literal or problem description.
- if (!result->IsTrue()) {
- v8::Local<v8::String> s = result->ToString();
- i::ScopedVector<char> data(s->Utf8Length() + 1);
- CHECK_NE(NULL, data.start());
- s->WriteUtf8(data.start());
- printf("%s\n", data.start());
- // Make sure that our output is written prior crash due to CHECK failure.
- fflush(stdout);
- CHECK(false);
- }
+ ScopedLoggerInitializer initialize_logger;
+ Logger* logger = initialize_logger.logger();
+
+ // Compile and run a function that creates other functions.
+ CompileRun(
+ "(function f(obj) {\n"
+ " obj.test =\n"
+ " (function a(j) { return function b() { return j; } })(100);\n"
+ "})(this);");
+ logger->StopProfiler();
+ CcTest::heap()->CollectAllGarbage(i::Heap::kMakeHeapIterableMask);
+ logger->StringEvent("test-logging-done", "");
+
+ // Iterate heap to find compiled functions, will write to log.
+ logger->LogCompiledFunctions();
+ logger->StringEvent("test-traversal-done", "");
+
+ bool exists = false;
+ i::Vector<const char> log(
+ i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true));
+ CHECK(exists);
+ v8::Handle<v8::String> log_str = v8::String::NewFromUtf8(
+ CcTest::isolate(), log.start(), v8::String::kNormalString, log.length());
+ initialize_logger.env()->Global()->Set(v8_str("_log"), log_str);
+
+ i::Vector<const unsigned char> source = TestSources::GetScriptsSource();
+ v8::Handle<v8::String> source_str = v8::String::NewFromUtf8(
+ CcTest::isolate(), reinterpret_cast<const char*>(source.start()),
+ v8::String::kNormalString, source.length());
+ v8::TryCatch try_catch;
+ v8::Handle<v8::Script> script = CompileWithOrigin(source_str, "");
+ if (script.IsEmpty()) {
+ v8::String::Utf8Value exception(try_catch.Exception());
+ printf("compile: %s\n", *exception);
+ CHECK(false);
+ }
+ v8::Handle<v8::Value> result = script->Run();
+ if (result.IsEmpty()) {
+ v8::String::Utf8Value exception(try_catch.Exception());
+ printf("run: %s\n", *exception);
+ CHECK(false);
+ }
+ // The result either be a "true" literal or problem description.
+ if (!result->IsTrue()) {
+ v8::Local<v8::String> s = result->ToString();
+ i::ScopedVector<char> data(s->Utf8Length() + 1);
+ CHECK_NE(NULL, data.start());
+ s->WriteUtf8(data.start());
+ printf("%s\n", data.start());
+ // Make sure that our output is written prior crash due to CHECK failure.
+ fflush(stdout);
+ CHECK(false);
}
- isolate->Dispose();
}
TEST(LoadAndStoreWithRepresentation) {
+ v8::internal::V8::Initialize(NULL);
+
// Allocate an executable page of memory.
size_t actual_size;
byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
TEST(LoadAndStoreWithRepresentation) {
+ v8::internal::V8::Initialize(NULL);
+
// Allocate an executable page of memory.
size_t actual_size;
byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
// Test that we can move a Smi value literally into a register.
TEST(SmiMove) {
+ i::V8::Initialize(NULL);
// Allocate an executable page of memory.
size_t actual_size;
byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
// Test that we can compare smis for equality (and more).
TEST(SmiCompare) {
+ i::V8::Initialize(NULL);
// Allocate an executable page of memory.
size_t actual_size;
byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
TEST(Integer32ToSmi) {
+ i::V8::Initialize(NULL);
// Allocate an executable page of memory.
size_t actual_size;
byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
TEST(Integer64PlusConstantToSmi) {
+ i::V8::Initialize(NULL);
// Allocate an executable page of memory.
size_t actual_size;
byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
TEST(SmiCheck) {
+ i::V8::Initialize(NULL);
// Allocate an executable page of memory.
size_t actual_size;
byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
TEST(SmiNeg) {
+ i::V8::Initialize(NULL);
// Allocate an executable page of memory.
size_t actual_size;
byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
TEST(SmiAdd) {
+ i::V8::Initialize(NULL);
// Allocate an executable page of memory.
size_t actual_size;
byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
TEST(SmiSub) {
+ i::V8::Initialize(NULL);
// Allocate an executable page of memory.
size_t actual_size;
byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
TEST(SmiMul) {
+ i::V8::Initialize(NULL);
// Allocate an executable page of memory.
size_t actual_size;
byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
TEST(SmiDiv) {
+ i::V8::Initialize(NULL);
// Allocate an executable page of memory.
size_t actual_size;
byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
TEST(SmiMod) {
+ i::V8::Initialize(NULL);
// Allocate an executable page of memory.
size_t actual_size;
byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
TEST(SmiIndex) {
+ i::V8::Initialize(NULL);
// Allocate an executable page of memory.
size_t actual_size;
byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
TEST(SmiSelectNonSmi) {
+ i::V8::Initialize(NULL);
// Allocate an executable page of memory.
size_t actual_size;
byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
TEST(SmiAnd) {
+ i::V8::Initialize(NULL);
// Allocate an executable page of memory.
size_t actual_size;
byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
TEST(SmiOr) {
+ i::V8::Initialize(NULL);
// Allocate an executable page of memory.
size_t actual_size;
byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
TEST(SmiXor) {
+ i::V8::Initialize(NULL);
// Allocate an executable page of memory.
size_t actual_size;
byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
TEST(SmiNot) {
+ i::V8::Initialize(NULL);
// Allocate an executable page of memory.
size_t actual_size;
byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
TEST(SmiShiftLeft) {
+ i::V8::Initialize(NULL);
// Allocate an executable page of memory.
size_t actual_size;
byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
TEST(SmiShiftLogicalRight) {
+ i::V8::Initialize(NULL);
// Allocate an executable page of memory.
size_t actual_size;
byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
TEST(SmiShiftArithmeticRight) {
+ i::V8::Initialize(NULL);
// Allocate an executable page of memory.
size_t actual_size;
byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
TEST(PositiveSmiTimesPowerOfTwoToInteger64) {
+ i::V8::Initialize(NULL);
// Allocate an executable page of memory.
size_t actual_size;
byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
TEST(OperandOffset) {
+ i::V8::Initialize(NULL);
uint32_t data[256];
for (uint32_t i = 0; i < 256; i++) { data[i] = i * 0x01010101; }
TEST(LoadAndStoreWithRepresentation) {
+ v8::internal::V8::Initialize(NULL);
+
// Allocate an executable page of memory.
size_t actual_size;
byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
TEST(LoadAndStoreWithRepresentation) {
+ v8::internal::V8::Initialize(NULL);
+
// Allocate an executable page of memory.
size_t actual_size;
byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
using namespace v8::internal;
-static const int64_t kRandomSeeds[] = {-1, 1, 42, 100, 1234567890, 987654321};
+static const int kMaxRuns = 12345;
+static const int kRandomSeeds[] = {
+ -1, 1, 42, 100, 1234567890, 987654321
+};
TEST(RandomSeedFlagIsUsed) {
for (unsigned n = 0; n < arraysize(kRandomSeeds); ++n) {
- FLAG_random_seed = static_cast<int>(kRandomSeeds[n]);
+ FLAG_random_seed = kRandomSeeds[n];
v8::Isolate* i = v8::Isolate::New();
- v8::base::RandomNumberGenerator& rng =
+ v8::base::RandomNumberGenerator& rng1 =
*reinterpret_cast<Isolate*>(i)->random_number_generator();
- CHECK_EQ(kRandomSeeds[n], rng.initial_seed());
+ v8::base::RandomNumberGenerator rng2(kRandomSeeds[n]);
+ for (int k = 1; k <= kMaxRuns; ++k) {
+ int64_t i1, i2;
+ rng1.NextBytes(&i1, sizeof(i1));
+ rng2.NextBytes(&i2, sizeof(i2));
+ CHECK_EQ(i2, i1);
+ CHECK_EQ(rng2.NextInt(), rng1.NextInt());
+ CHECK_EQ(rng2.NextInt(k), rng1.NextInt(k));
+ CHECK_EQ(rng2.NextDouble(), rng1.NextDouble());
+ }
i->Dispose();
}
}
static bool CheckParse(const char* input) {
+ V8::Initialize(NULL);
v8::HandleScope scope(CcTest::isolate());
Zone zone(CcTest::i_isolate());
FlatStringReader reader(CcTest::i_isolate(), CStrVector(input));
static void CheckParseEq(const char* input, const char* expected) {
+ V8::Initialize(NULL);
v8::HandleScope scope(CcTest::isolate());
Zone zone(CcTest::i_isolate());
FlatStringReader reader(CcTest::i_isolate(), CStrVector(input));
static bool CheckSimple(const char* input) {
+ V8::Initialize(NULL);
v8::HandleScope scope(CcTest::isolate());
Zone zone(CcTest::i_isolate());
FlatStringReader reader(CcTest::i_isolate(), CStrVector(input));
static MinMaxPair CheckMinMaxMatch(const char* input) {
+ V8::Initialize(NULL);
v8::HandleScope scope(CcTest::isolate());
Zone zone(CcTest::i_isolate());
FlatStringReader reader(CcTest::i_isolate(), CStrVector(input));
}
TEST(Parser) {
+ V8::Initialize(NULL);
+
CHECK_PARSE_ERROR("?");
CheckParseEq("abc", "'abc'");
static void ExpectError(const char* input,
const char* expected) {
+ V8::Initialize(NULL);
v8::HandleScope scope(CcTest::isolate());
Zone zone(CcTest::i_isolate());
FlatStringReader reader(CcTest::i_isolate(), CStrVector(input));
TEST(CharacterClassEscapes) {
+ v8::internal::V8::Initialize(NULL);
TestCharacterClassEscapes('.', IsRegExpNewline);
TestCharacterClassEscapes('d', IsDigit);
TestCharacterClassEscapes('D', NotDigit);
static RegExpNode* Compile(const char* input, bool multiline, bool is_one_byte,
Zone* zone) {
+ V8::Initialize(NULL);
Isolate* isolate = CcTest::i_isolate();
FlatStringReader reader(isolate, CStrVector(input));
RegExpCompileData compile_data;
TEST(SplayTreeSimple) {
+ v8::internal::V8::Initialize(NULL);
static const unsigned kLimit = 1000;
Zone zone(CcTest::i_isolate());
ZoneSplayTree<TestConfig> tree(&zone);
TEST(DispatchTableConstruction) {
+ v8::internal::V8::Initialize(NULL);
// Initialize test data.
static const int kLimit = 1000;
static const int kRangeCount = 8;
#else // V8_INTERPRETED_REGEXP
TEST(MacroAssembler) {
+ V8::Initialize(NULL);
byte codes[1024];
Zone zone(CcTest::i_isolate());
RegExpMacroAssemblerIrregexp m(Vector<byte>(codes, 1024), &zone);
TEST(AddInverseToTable) {
+ v8::internal::V8::Initialize(NULL);
static const int kLimit = 1000;
static const int kRangeCount = 16;
for (int t = 0; t < 10; t++) {
TEST(CharacterRangeCaseIndependence) {
+ v8::internal::V8::Initialize(NULL);
TestSimpleRangeCaseIndependence(CharacterRange::Singleton('a'),
CharacterRange::Singleton('A'));
TestSimpleRangeCaseIndependence(CharacterRange::Singleton('z'),
TEST(CharClassDifference) {
+ v8::internal::V8::Initialize(NULL);
Zone zone(CcTest::i_isolate());
ZoneList<CharacterRange>* base =
new(&zone) ZoneList<CharacterRange>(1, &zone);
TEST(CanonicalizeCharacterSets) {
+ v8::internal::V8::Initialize(NULL);
Zone zone(CcTest::i_isolate());
ZoneList<CharacterRange>* list =
new(&zone) ZoneList<CharacterRange>(4, &zone);
TEST(CharacterRangeMerge) {
+ v8::internal::V8::Initialize(NULL);
Zone zone(CcTest::i_isolate());
ZoneList<CharacterRange> l1(4, &zone);
ZoneList<CharacterRange> l2(4, &zone);
TEST(Graph) {
+ V8::Initialize(NULL);
Execute("\\b\\w+\\b", false, true, true);
}
using namespace v8::internal;
+static const unsigned kCounters = 256;
+static int local_counters[kCounters];
+static const char* local_counter_names[kCounters];
+
+
+static unsigned CounterHash(const char* s) {
+ unsigned hash = 0;
+ while (*++s) {
+ hash |= hash << 5;
+ hash += *s;
+ }
+ return hash;
+}
+
+
+// Callback receiver to track counters in test.
+static int* counter_function(const char* name) {
+ unsigned hash = CounterHash(name) % kCounters;
+ unsigned original_hash = hash;
+ USE(original_hash);
+ while (true) {
+ if (local_counter_names[hash] == name) {
+ return &local_counters[hash];
+ }
+ if (local_counter_names[hash] == 0) {
+ local_counter_names[hash] = name;
+ return &local_counters[hash];
+ }
+ if (strcmp(local_counter_names[hash], name) == 0) {
+ return &local_counters[hash];
+ }
+ hash = (hash + 1) % kCounters;
+ DCHECK(hash != original_hash); // Hash table has been filled up.
+ }
+}
+
template <class T>
static Address AddressOf(T id) {
TEST(ExternalReferenceEncoder) {
Isolate* isolate = CcTest::i_isolate();
+ isolate->stats_table()->SetCounterFunction(counter_function);
v8::V8::Initialize();
ExternalReferenceEncoder encoder(isolate);
Encode(encoder, Builtins::kArrayCode));
CHECK_EQ(make_code(v8::internal::RUNTIME_FUNCTION, Runtime::kAbort),
Encode(encoder, Runtime::kAbort));
+ ExternalReference total_compile_size =
+ ExternalReference(isolate->counters()->total_compile_size());
+ CHECK_EQ(make_code(STATS_COUNTER, Counters::k_total_compile_size),
+ encoder.Encode(total_compile_size.address()));
ExternalReference stack_limit_address =
ExternalReference::address_of_stack_limit(isolate);
CHECK_EQ(make_code(UNCLASSIFIED, 2),
TEST(ExternalReferenceDecoder) {
Isolate* isolate = CcTest::i_isolate();
+ isolate->stats_table()->SetCounterFunction(counter_function);
v8::V8::Initialize();
ExternalReferenceDecoder decoder(isolate);
CHECK_EQ(AddressOf(Runtime::kAbort),
decoder.Decode(make_code(v8::internal::RUNTIME_FUNCTION,
Runtime::kAbort)));
+ ExternalReference total_compile_size =
+ ExternalReference(isolate->counters()->total_compile_size());
+ CHECK_EQ(total_compile_size.address(),
+ decoder.Decode(
+ make_code(STATS_COUNTER,
+ Counters::k_total_compile_size)));
CHECK_EQ(ExternalReference::address_of_stack_limit(isolate).address(),
decoder.Decode(make_code(UNCLASSIFIED, 2)));
CHECK_EQ(ExternalReference::address_of_real_stack_limit(isolate).address(),
}
-static void Serialize(v8::Isolate* isolate) {
+static void Serialize() {
// We have to create one context. One reason for this is so that the builtins
// can be loaded from v8natives.js and their addresses can be processed. This
// will clear the pending fixups array, which would otherwise contain GC roots
// that would confuse the serialization/deserialization process.
+ v8::Isolate* isolate = CcTest::isolate();
{
v8::HandleScope scope(isolate);
v8::Context::New(isolate);
}
- Isolate* internal_isolate = reinterpret_cast<Isolate*>(isolate);
+ Isolate* internal_isolate = CcTest::i_isolate();
internal_isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, "serialize");
WriteToFile(internal_isolate, FLAG_testing_serialization_file);
}
// Test that the whole heap can be serialized.
-UNINITIALIZED_TEST(Serialize) {
+TEST(Serialize) {
if (!Snapshot::HaveASnapshotToStartFrom()) {
- v8::Isolate::CreateParams params;
- params.enable_serializer = true;
- v8::Isolate* isolate = v8::Isolate::New(params);
- Serialize(isolate);
+ CcTest::i_isolate()->enable_serializer();
+ v8::V8::Initialize();
+ Serialize();
}
}
// Test that heap serialization is non-destructive.
-UNINITIALIZED_TEST(SerializeTwice) {
+TEST(SerializeTwice) {
if (!Snapshot::HaveASnapshotToStartFrom()) {
- v8::Isolate::CreateParams params;
- params.enable_serializer = true;
- v8::Isolate* isolate = v8::Isolate::New(params);
- Serialize(isolate);
- Serialize(isolate);
+ CcTest::i_isolate()->enable_serializer();
+ v8::V8::Initialize();
+ Serialize();
+ Serialize();
}
}
}
-v8::Isolate* InitializeFromFile(const char* snapshot_file) {
+bool InitializeFromFile(const char* snapshot_file) {
int len;
byte* str = ReadBytes(snapshot_file, &len);
- if (!str) return NULL;
- v8::Isolate* v8_isolate = NULL;
+ if (!str) return false;
+ bool success;
{
SnapshotByteSource source(str, len);
Deserializer deserializer(&source);
ReserveSpaceForSnapshot(&deserializer, snapshot_file);
- Isolate* isolate = Isolate::NewForTesting();
- v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
- v8::Isolate::Scope isolate_scope(v8_isolate);
- isolate->Init(&deserializer);
+ success = V8::Initialize(&deserializer);
}
DeleteArray(str);
- return v8_isolate;
+ return success;
}
-static v8::Isolate* Deserialize() {
- v8::Isolate* isolate = InitializeFromFile(FLAG_testing_serialization_file);
- CHECK(isolate);
- return isolate;
+static void Deserialize() {
+ CHECK(InitializeFromFile(FLAG_testing_serialization_file));
}
-static void SanityCheck(v8::Isolate* v8_isolate) {
- Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
- v8::HandleScope scope(v8_isolate);
+static void SanityCheck() {
+ Isolate* isolate = CcTest::i_isolate();
+ v8::HandleScope scope(CcTest::isolate());
#ifdef VERIFY_HEAP
- isolate->heap()->Verify();
+ CcTest::heap()->Verify();
#endif
CHECK(isolate->global_object()->IsJSObject());
CHECK(isolate->native_context()->IsContext());
- CHECK(isolate->heap()->string_table()->IsStringTable());
+ CHECK(CcTest::heap()->string_table()->IsStringTable());
isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("Empty"));
}
-UNINITIALIZED_DEPENDENT_TEST(Deserialize, Serialize) {
+DEPENDENT_TEST(Deserialize, Serialize) {
// The serialize-deserialize tests only work if the VM is built without
// serialization. That doesn't matter. We don't need to be able to
// serialize a snapshot in a VM that is booted from a snapshot.
if (!Snapshot::HaveASnapshotToStartFrom()) {
- v8::Isolate* isolate = Deserialize();
- {
- v8::HandleScope handle_scope(isolate);
- v8::Isolate::Scope isolate_scope(isolate);
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ Deserialize();
- v8::Local<v8::Context> env = v8::Context::New(isolate);
- env->Enter();
+ v8::Local<v8::Context> env = v8::Context::New(isolate);
+ env->Enter();
- SanityCheck(isolate);
- }
- isolate->Dispose();
+ SanityCheck();
}
}
-UNINITIALIZED_DEPENDENT_TEST(DeserializeFromSecondSerialization,
- SerializeTwice) {
+DEPENDENT_TEST(DeserializeFromSecondSerialization, SerializeTwice) {
if (!Snapshot::HaveASnapshotToStartFrom()) {
- v8::Isolate* isolate = Deserialize();
- {
- v8::Isolate::Scope isolate_scope(isolate);
- v8::HandleScope handle_scope(isolate);
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ Deserialize();
- v8::Local<v8::Context> env = v8::Context::New(isolate);
- env->Enter();
+ v8::Local<v8::Context> env = v8::Context::New(isolate);
+ env->Enter();
- SanityCheck(isolate);
- }
- isolate->Dispose();
+ SanityCheck();
}
}
-UNINITIALIZED_DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) {
+DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) {
if (!Snapshot::HaveASnapshotToStartFrom()) {
- v8::Isolate* isolate = Deserialize();
- {
- v8::Isolate::Scope isolate_scope(isolate);
- v8::HandleScope handle_scope(isolate);
-
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ Deserialize();
- v8::Local<v8::Context> env = v8::Context::New(isolate);
- env->Enter();
+ v8::Local<v8::Context> env = v8::Context::New(isolate);
+ env->Enter();
- const char* c_source = "\"1234\".length";
- v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, c_source);
- v8::Local<v8::Script> script = v8::Script::Compile(source);
- CHECK_EQ(4, script->Run()->Int32Value());
- }
- isolate->Dispose();
+ const char* c_source = "\"1234\".length";
+ v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, c_source);
+ v8::Local<v8::Script> script = v8::Script::Compile(source);
+ CHECK_EQ(4, script->Run()->Int32Value());
}
}
-UNINITIALIZED_DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2,
- SerializeTwice) {
+DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2,
+ SerializeTwice) {
if (!Snapshot::HaveASnapshotToStartFrom()) {
- v8::Isolate* isolate = Deserialize();
- {
- v8::Isolate::Scope isolate_scope(isolate);
- v8::HandleScope handle_scope(isolate);
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ Deserialize();
- v8::Local<v8::Context> env = v8::Context::New(isolate);
- env->Enter();
+ v8::Local<v8::Context> env = v8::Context::New(isolate);
+ env->Enter();
- const char* c_source = "\"1234\".length";
- v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, c_source);
- v8::Local<v8::Script> script = v8::Script::Compile(source);
- CHECK_EQ(4, script->Run()->Int32Value());
- }
- isolate->Dispose();
+ const char* c_source = "\"1234\".length";
+ v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, c_source);
+ v8::Local<v8::Script> script = v8::Script::Compile(source);
+ CHECK_EQ(4, script->Run()->Int32Value());
}
}
-UNINITIALIZED_TEST(PartialSerialization) {
+TEST(PartialSerialization) {
if (!Snapshot::HaveASnapshotToStartFrom()) {
- v8::Isolate::CreateParams params;
- params.enable_serializer = true;
- v8::Isolate* v8_isolate = v8::Isolate::New(params);
- Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
- v8_isolate->Enter();
- {
- Heap* heap = isolate->heap();
+ Isolate* isolate = CcTest::i_isolate();
+ CcTest::i_isolate()->enable_serializer();
+ v8::V8::Initialize();
+ v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
+ Heap* heap = isolate->heap();
- v8::Persistent<v8::Context> env;
- {
- HandleScope scope(isolate);
- env.Reset(v8_isolate, v8::Context::New(v8_isolate));
- }
- DCHECK(!env.IsEmpty());
- {
- v8::HandleScope handle_scope(v8_isolate);
- v8::Local<v8::Context>::New(v8_isolate, env)->Enter();
- }
- // Make sure all builtin scripts are cached.
- {
- HandleScope scope(isolate);
- for (int i = 0; i < Natives::GetBuiltinsCount(); i++) {
- isolate->bootstrapper()->NativesSourceLookup(i);
- }
- }
- heap->CollectAllGarbage(Heap::kNoGCFlags);
- heap->CollectAllGarbage(Heap::kNoGCFlags);
-
- Object* raw_foo;
- {
- v8::HandleScope handle_scope(v8_isolate);
- v8::Local<v8::String> foo = v8::String::NewFromUtf8(v8_isolate, "foo");
- DCHECK(!foo.IsEmpty());
- raw_foo = *(v8::Utils::OpenHandle(*foo));
+ v8::Persistent<v8::Context> env;
+ {
+ HandleScope scope(isolate);
+ env.Reset(v8_isolate, v8::Context::New(v8_isolate));
+ }
+ DCHECK(!env.IsEmpty());
+ {
+ v8::HandleScope handle_scope(v8_isolate);
+ v8::Local<v8::Context>::New(v8_isolate, env)->Enter();
+ }
+ // Make sure all builtin scripts are cached.
+ { HandleScope scope(isolate);
+ for (int i = 0; i < Natives::GetBuiltinsCount(); i++) {
+ isolate->bootstrapper()->NativesSourceLookup(i);
}
+ }
+ heap->CollectAllGarbage(Heap::kNoGCFlags);
+ heap->CollectAllGarbage(Heap::kNoGCFlags);
- int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
- Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
- SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
+ Object* raw_foo;
+ {
+ v8::HandleScope handle_scope(v8_isolate);
+ v8::Local<v8::String> foo = v8::String::NewFromUtf8(v8_isolate, "foo");
+ DCHECK(!foo.IsEmpty());
+ raw_foo = *(v8::Utils::OpenHandle(*foo));
+ }
- {
- v8::HandleScope handle_scope(v8_isolate);
- v8::Local<v8::Context>::New(v8_isolate, env)->Exit();
- }
- env.Reset();
-
- FileByteSink startup_sink(startup_name.start());
- StartupSerializer startup_serializer(isolate, &startup_sink);
- startup_serializer.SerializeStrongReferences();
-
- FileByteSink partial_sink(FLAG_testing_serialization_file);
- PartialSerializer p_ser(isolate, &startup_serializer, &partial_sink);
- p_ser.Serialize(&raw_foo);
- startup_serializer.SerializeWeakReferences();
-
- partial_sink.WriteSpaceUsed(
- p_ser.CurrentAllocationAddress(NEW_SPACE),
- p_ser.CurrentAllocationAddress(OLD_POINTER_SPACE),
- p_ser.CurrentAllocationAddress(OLD_DATA_SPACE),
- p_ser.CurrentAllocationAddress(CODE_SPACE),
- p_ser.CurrentAllocationAddress(MAP_SPACE),
- p_ser.CurrentAllocationAddress(CELL_SPACE),
- p_ser.CurrentAllocationAddress(PROPERTY_CELL_SPACE));
-
- startup_sink.WriteSpaceUsed(
- startup_serializer.CurrentAllocationAddress(NEW_SPACE),
- startup_serializer.CurrentAllocationAddress(OLD_POINTER_SPACE),
- startup_serializer.CurrentAllocationAddress(OLD_DATA_SPACE),
- startup_serializer.CurrentAllocationAddress(CODE_SPACE),
- startup_serializer.CurrentAllocationAddress(MAP_SPACE),
- startup_serializer.CurrentAllocationAddress(CELL_SPACE),
- startup_serializer.CurrentAllocationAddress(PROPERTY_CELL_SPACE));
- startup_name.Dispose();
+ int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
+ Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
+ SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
+
+ {
+ v8::HandleScope handle_scope(v8_isolate);
+ v8::Local<v8::Context>::New(v8_isolate, env)->Exit();
}
- v8_isolate->Exit();
- v8_isolate->Dispose();
+ env.Reset();
+
+ FileByteSink startup_sink(startup_name.start());
+ StartupSerializer startup_serializer(isolate, &startup_sink);
+ startup_serializer.SerializeStrongReferences();
+
+ FileByteSink partial_sink(FLAG_testing_serialization_file);
+ PartialSerializer p_ser(isolate, &startup_serializer, &partial_sink);
+ p_ser.Serialize(&raw_foo);
+ startup_serializer.SerializeWeakReferences();
+
+ partial_sink.WriteSpaceUsed(
+ p_ser.CurrentAllocationAddress(NEW_SPACE),
+ p_ser.CurrentAllocationAddress(OLD_POINTER_SPACE),
+ p_ser.CurrentAllocationAddress(OLD_DATA_SPACE),
+ p_ser.CurrentAllocationAddress(CODE_SPACE),
+ p_ser.CurrentAllocationAddress(MAP_SPACE),
+ p_ser.CurrentAllocationAddress(CELL_SPACE),
+ p_ser.CurrentAllocationAddress(PROPERTY_CELL_SPACE));
+
+ startup_sink.WriteSpaceUsed(
+ startup_serializer.CurrentAllocationAddress(NEW_SPACE),
+ startup_serializer.CurrentAllocationAddress(OLD_POINTER_SPACE),
+ startup_serializer.CurrentAllocationAddress(OLD_DATA_SPACE),
+ startup_serializer.CurrentAllocationAddress(CODE_SPACE),
+ startup_serializer.CurrentAllocationAddress(MAP_SPACE),
+ startup_serializer.CurrentAllocationAddress(CELL_SPACE),
+ startup_serializer.CurrentAllocationAddress(PROPERTY_CELL_SPACE));
+ startup_name.Dispose();
}
}
-UNINITIALIZED_DEPENDENT_TEST(PartialDeserialization, PartialSerialization) {
+DEPENDENT_TEST(PartialDeserialization, PartialSerialization) {
if (!Snapshot::HaveASnapshotToStartFrom()) {
int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
- v8::Isolate* v8_isolate = InitializeFromFile(startup_name.start());
- CHECK(v8_isolate);
+ CHECK(InitializeFromFile(startup_name.start()));
startup_name.Dispose();
- {
- v8::Isolate::Scope isolate_scope(v8_isolate);
- const char* file_name = FLAG_testing_serialization_file;
+ const char* file_name = FLAG_testing_serialization_file;
- int snapshot_size = 0;
- byte* snapshot = ReadBytes(file_name, &snapshot_size);
+ int snapshot_size = 0;
+ byte* snapshot = ReadBytes(file_name, &snapshot_size);
- Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
- Object* root;
- {
- SnapshotByteSource source(snapshot, snapshot_size);
- Deserializer deserializer(&source);
- ReserveSpaceForSnapshot(&deserializer, file_name);
- deserializer.DeserializePartial(isolate, &root);
- CHECK(root->IsString());
- }
- HandleScope handle_scope(isolate);
- Handle<Object> root_handle(root, isolate);
-
-
- Object* root2;
- {
- SnapshotByteSource source(snapshot, snapshot_size);
- Deserializer deserializer(&source);
- ReserveSpaceForSnapshot(&deserializer, file_name);
- deserializer.DeserializePartial(isolate, &root2);
- CHECK(root2->IsString());
- CHECK(*root_handle == root2);
- }
+ Isolate* isolate = CcTest::i_isolate();
+ Object* root;
+ {
+ SnapshotByteSource source(snapshot, snapshot_size);
+ Deserializer deserializer(&source);
+ ReserveSpaceForSnapshot(&deserializer, file_name);
+ deserializer.DeserializePartial(isolate, &root);
+ CHECK(root->IsString());
+ }
+ HandleScope handle_scope(isolate);
+ Handle<Object> root_handle(root, isolate);
+
+
+ Object* root2;
+ {
+ SnapshotByteSource source(snapshot, snapshot_size);
+ Deserializer deserializer(&source);
+ ReserveSpaceForSnapshot(&deserializer, file_name);
+ deserializer.DeserializePartial(isolate, &root2);
+ CHECK(root2->IsString());
+ CHECK(*root_handle == root2);
}
- v8_isolate->Dispose();
}
}
-UNINITIALIZED_TEST(ContextSerialization) {
+TEST(ContextSerialization) {
if (!Snapshot::HaveASnapshotToStartFrom()) {
- v8::Isolate::CreateParams params;
- params.enable_serializer = true;
- v8::Isolate* v8_isolate = v8::Isolate::New(params);
- Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
+ Isolate* isolate = CcTest::i_isolate();
+ CcTest::i_isolate()->enable_serializer();
+ v8::V8::Initialize();
+ v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
Heap* heap = isolate->heap();
- {
- v8::Isolate::Scope isolate_scope(v8_isolate);
- v8::Persistent<v8::Context> env;
- {
- HandleScope scope(isolate);
- env.Reset(v8_isolate, v8::Context::New(v8_isolate));
- }
- DCHECK(!env.IsEmpty());
- {
- v8::HandleScope handle_scope(v8_isolate);
- v8::Local<v8::Context>::New(v8_isolate, env)->Enter();
- }
- // Make sure all builtin scripts are cached.
- {
- HandleScope scope(isolate);
- for (int i = 0; i < Natives::GetBuiltinsCount(); i++) {
- isolate->bootstrapper()->NativesSourceLookup(i);
- }
+ v8::Persistent<v8::Context> env;
+ {
+ HandleScope scope(isolate);
+ env.Reset(v8_isolate, v8::Context::New(v8_isolate));
+ }
+ DCHECK(!env.IsEmpty());
+ {
+ v8::HandleScope handle_scope(v8_isolate);
+ v8::Local<v8::Context>::New(v8_isolate, env)->Enter();
+ }
+ // Make sure all builtin scripts are cached.
+ { HandleScope scope(isolate);
+ for (int i = 0; i < Natives::GetBuiltinsCount(); i++) {
+ isolate->bootstrapper()->NativesSourceLookup(i);
}
- // If we don't do this then we end up with a stray root pointing at the
- // context even after we have disposed of env.
- heap->CollectAllGarbage(Heap::kNoGCFlags);
-
- int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
- Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
- SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
+ }
+ // If we don't do this then we end up with a stray root pointing at the
+ // context even after we have disposed of env.
+ heap->CollectAllGarbage(Heap::kNoGCFlags);
- {
- v8::HandleScope handle_scope(v8_isolate);
- v8::Local<v8::Context>::New(v8_isolate, env)->Exit();
- }
+ int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
+ Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
+ SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
- i::Object* raw_context = *v8::Utils::OpenPersistent(env);
-
- env.Reset();
-
- FileByteSink startup_sink(startup_name.start());
- StartupSerializer startup_serializer(isolate, &startup_sink);
- startup_serializer.SerializeStrongReferences();
-
- FileByteSink partial_sink(FLAG_testing_serialization_file);
- PartialSerializer p_ser(isolate, &startup_serializer, &partial_sink);
- p_ser.Serialize(&raw_context);
- startup_serializer.SerializeWeakReferences();
-
- partial_sink.WriteSpaceUsed(
- p_ser.CurrentAllocationAddress(NEW_SPACE),
- p_ser.CurrentAllocationAddress(OLD_POINTER_SPACE),
- p_ser.CurrentAllocationAddress(OLD_DATA_SPACE),
- p_ser.CurrentAllocationAddress(CODE_SPACE),
- p_ser.CurrentAllocationAddress(MAP_SPACE),
- p_ser.CurrentAllocationAddress(CELL_SPACE),
- p_ser.CurrentAllocationAddress(PROPERTY_CELL_SPACE));
-
- startup_sink.WriteSpaceUsed(
- startup_serializer.CurrentAllocationAddress(NEW_SPACE),
- startup_serializer.CurrentAllocationAddress(OLD_POINTER_SPACE),
- startup_serializer.CurrentAllocationAddress(OLD_DATA_SPACE),
- startup_serializer.CurrentAllocationAddress(CODE_SPACE),
- startup_serializer.CurrentAllocationAddress(MAP_SPACE),
- startup_serializer.CurrentAllocationAddress(CELL_SPACE),
- startup_serializer.CurrentAllocationAddress(PROPERTY_CELL_SPACE));
- startup_name.Dispose();
+ {
+ v8::HandleScope handle_scope(v8_isolate);
+ v8::Local<v8::Context>::New(v8_isolate, env)->Exit();
}
- v8_isolate->Dispose();
+
+ i::Object* raw_context = *v8::Utils::OpenPersistent(env);
+
+ env.Reset();
+
+ FileByteSink startup_sink(startup_name.start());
+ StartupSerializer startup_serializer(isolate, &startup_sink);
+ startup_serializer.SerializeStrongReferences();
+
+ FileByteSink partial_sink(FLAG_testing_serialization_file);
+ PartialSerializer p_ser(isolate, &startup_serializer, &partial_sink);
+ p_ser.Serialize(&raw_context);
+ startup_serializer.SerializeWeakReferences();
+
+ partial_sink.WriteSpaceUsed(
+ p_ser.CurrentAllocationAddress(NEW_SPACE),
+ p_ser.CurrentAllocationAddress(OLD_POINTER_SPACE),
+ p_ser.CurrentAllocationAddress(OLD_DATA_SPACE),
+ p_ser.CurrentAllocationAddress(CODE_SPACE),
+ p_ser.CurrentAllocationAddress(MAP_SPACE),
+ p_ser.CurrentAllocationAddress(CELL_SPACE),
+ p_ser.CurrentAllocationAddress(PROPERTY_CELL_SPACE));
+
+ startup_sink.WriteSpaceUsed(
+ startup_serializer.CurrentAllocationAddress(NEW_SPACE),
+ startup_serializer.CurrentAllocationAddress(OLD_POINTER_SPACE),
+ startup_serializer.CurrentAllocationAddress(OLD_DATA_SPACE),
+ startup_serializer.CurrentAllocationAddress(CODE_SPACE),
+ startup_serializer.CurrentAllocationAddress(MAP_SPACE),
+ startup_serializer.CurrentAllocationAddress(CELL_SPACE),
+ startup_serializer.CurrentAllocationAddress(PROPERTY_CELL_SPACE));
+ startup_name.Dispose();
}
}
-UNINITIALIZED_DEPENDENT_TEST(ContextDeserialization, ContextSerialization) {
+DEPENDENT_TEST(ContextDeserialization, ContextSerialization) {
if (!Snapshot::HaveASnapshotToStartFrom()) {
int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
- v8::Isolate* v8_isolate = InitializeFromFile(startup_name.start());
- CHECK(v8_isolate);
+ CHECK(InitializeFromFile(startup_name.start()));
startup_name.Dispose();
- {
- v8::Isolate::Scope isolate_scope(v8_isolate);
- const char* file_name = FLAG_testing_serialization_file;
+ const char* file_name = FLAG_testing_serialization_file;
- int snapshot_size = 0;
- byte* snapshot = ReadBytes(file_name, &snapshot_size);
+ int snapshot_size = 0;
+ byte* snapshot = ReadBytes(file_name, &snapshot_size);
- Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
- Object* root;
- {
- SnapshotByteSource source(snapshot, snapshot_size);
- Deserializer deserializer(&source);
- ReserveSpaceForSnapshot(&deserializer, file_name);
- deserializer.DeserializePartial(isolate, &root);
- CHECK(root->IsContext());
- }
- HandleScope handle_scope(isolate);
- Handle<Object> root_handle(root, isolate);
-
-
- Object* root2;
- {
- SnapshotByteSource source(snapshot, snapshot_size);
- Deserializer deserializer(&source);
- ReserveSpaceForSnapshot(&deserializer, file_name);
- deserializer.DeserializePartial(isolate, &root2);
- CHECK(root2->IsContext());
- CHECK(*root_handle != root2);
- }
+ Isolate* isolate = CcTest::i_isolate();
+ Object* root;
+ {
+ SnapshotByteSource source(snapshot, snapshot_size);
+ Deserializer deserializer(&source);
+ ReserveSpaceForSnapshot(&deserializer, file_name);
+ deserializer.DeserializePartial(isolate, &root);
+ CHECK(root->IsContext());
+ }
+ HandleScope handle_scope(isolate);
+ Handle<Object> root_handle(root, isolate);
+
+
+ Object* root2;
+ {
+ SnapshotByteSource source(snapshot, snapshot_size);
+ Deserializer deserializer(&source);
+ ReserveSpaceForSnapshot(&deserializer, file_name);
+ deserializer.DeserializePartial(isolate, &root2);
+ CHECK(root2->IsContext());
+ CHECK(*root_handle != root2);
}
- v8_isolate->Dispose();
}
}
v8::ScriptCompiler::CachedData* cache;
v8::Isolate* isolate1 = v8::Isolate::New();
+ v8::Isolate* isolate2 = v8::Isolate::New();
{
v8::Isolate::Scope iscope(isolate1);
v8::HandleScope scope(isolate1);
}
isolate1->Dispose();
- v8::Isolate* isolate2 = v8::Isolate::New();
{
v8::Isolate::Scope iscope(isolate2);
v8::HandleScope scope(isolate2);
TEST(Regress3540) {
Isolate* isolate = CcTest::i_isolate();
+ isolate->InitializeLoggingAndCounters();
Heap* heap = isolate->heap();
+ CHECK(heap->ConfigureHeapDefault());
MemoryAllocator* memory_allocator = new MemoryAllocator(isolate);
CHECK(
memory_allocator->SetUp(heap->MaxReserved(), heap->MaxExecutableSize()));
TEST(MemoryChunk) {
Isolate* isolate = CcTest::i_isolate();
+ isolate->InitializeLoggingAndCounters();
Heap* heap = isolate->heap();
+ CHECK(heap->ConfigureHeapDefault());
size_t reserve_area_size = 1 * MB;
size_t initial_commit_area_size, second_commit_area_size;
TEST(MemoryAllocator) {
Isolate* isolate = CcTest::i_isolate();
+ isolate->InitializeLoggingAndCounters();
Heap* heap = isolate->heap();
+ CHECK(isolate->heap()->ConfigureHeapDefault());
MemoryAllocator* memory_allocator = new MemoryAllocator(isolate);
CHECK(memory_allocator->SetUp(heap->MaxReserved(),
TEST(NewSpace) {
Isolate* isolate = CcTest::i_isolate();
+ isolate->InitializeLoggingAndCounters();
Heap* heap = isolate->heap();
+ CHECK(heap->ConfigureHeapDefault());
MemoryAllocator* memory_allocator = new MemoryAllocator(isolate);
CHECK(memory_allocator->SetUp(heap->MaxReserved(),
heap->MaxExecutableSize()));
TEST(OldSpace) {
Isolate* isolate = CcTest::i_isolate();
+ isolate->InitializeLoggingAndCounters();
Heap* heap = isolate->heap();
+ CHECK(heap->ConfigureHeapDefault());
MemoryAllocator* memory_allocator = new MemoryAllocator(isolate);
CHECK(memory_allocator->SetUp(heap->MaxReserved(),
heap->MaxExecutableSize()));
# Currently always deopt on minus zero
'math-floor-of-div-minus-zero': [SKIP],
- 'math-floor-of-div-nosudiv': [SKIP],
-
############################################################################
# Slow tests.
'regress/regress-2185-2': [PASS, SLOW],
int main(int argc, char* argv[]) {
- v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
v8::V8::InitializeICU();
v8::Platform* platform = v8::platform::CreateDefaultPlatform();
v8::V8::InitializePlatform(platform);
- v8::V8::Initialize();
+ v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
Encoding encoding = LATIN1;
bool print_tokens = false;
std::vector<std::string> fnames;
int main(int argc, char* argv[]) {
- v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
v8::V8::InitializeICU();
v8::Platform* platform = v8::platform::CreateDefaultPlatform();
v8::V8::InitializePlatform(platform);
- v8::V8::Initialize();
+ v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
Encoding encoding = LATIN1;
std::vector<std::string> fnames;
std::string benchmark;