2010-01-15 14:20:31 +00:00
|
|
|
// Copyright 2007-2010 the V8 project authors. All rights reserved.
|
2008-08-22 13:33:59 +00:00
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are
|
|
|
|
// met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright
|
|
|
|
// notice, this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above
|
|
|
|
// copyright notice, this list of conditions and the following
|
|
|
|
// disclaimer in the documentation and/or other materials provided
|
|
|
|
// with the distribution.
|
|
|
|
// * Neither the name of Google Inc. nor the names of its
|
|
|
|
// contributors may be used to endorse or promote products derived
|
|
|
|
// from this software without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
#include <signal.h>
|
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include <sys/stat.h>
|
2013-05-02 20:18:42 +00:00
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/v8.h"
|
2008-08-22 13:33:59 +00:00
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/bootstrapper.h"
|
2014-07-16 06:59:14 +00:00
|
|
|
#include "src/compilation-cache.h"
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/debug.h"
|
2014-08-05 08:18:22 +00:00
|
|
|
#include "src/heap/spaces.h"
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/natives.h"
|
|
|
|
#include "src/objects.h"
|
2014-09-25 07:16:15 +00:00
|
|
|
#include "src/runtime/runtime.h"
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/scopeinfo.h"
|
|
|
|
#include "src/serialize.h"
|
|
|
|
#include "src/snapshot.h"
|
|
|
|
#include "test/cctest/cctest.h"
|
2008-08-22 13:33:59 +00:00
|
|
|
|
|
|
|
using namespace v8::internal;
|
|
|
|
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
static Address AddressOf(T id) {
|
2013-09-19 09:17:13 +00:00
|
|
|
return ExternalReference(id, CcTest::i_isolate()).address();
|
2008-08-22 13:33:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
static uint32_t Encode(const ExternalReferenceEncoder& encoder, T id) {
|
|
|
|
return encoder.Encode(AddressOf(id));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int make_code(TypeCode type, int id) {
|
|
|
|
return static_cast<uint32_t>(type) << kReferenceTypeShift | id;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(ExternalReferenceEncoder) {
|
2013-09-19 09:17:13 +00:00
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
2011-08-04 15:18:18 +00:00
|
|
|
v8::V8::Initialize();
|
|
|
|
|
2013-09-03 11:54:08 +00:00
|
|
|
ExternalReferenceEncoder encoder(isolate);
|
2011-03-23 13:40:07 +00:00
|
|
|
CHECK_EQ(make_code(BUILTIN, Builtins::kArrayCode),
|
|
|
|
Encode(encoder, Builtins::kArrayCode));
|
2011-02-16 13:56:23 +00:00
|
|
|
CHECK_EQ(make_code(v8::internal::RUNTIME_FUNCTION, Runtime::kAbort),
|
2008-08-22 13:33:59 +00:00
|
|
|
Encode(encoder, Runtime::kAbort));
|
2009-11-05 13:59:40 +00:00
|
|
|
ExternalReference stack_limit_address =
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference::address_of_stack_limit(isolate);
|
2014-08-06 07:20:14 +00:00
|
|
|
CHECK_EQ(make_code(UNCLASSIFIED, 2),
|
2009-11-05 13:59:40 +00:00
|
|
|
encoder.Encode(stack_limit_address.address()));
|
|
|
|
ExternalReference real_stack_limit_address =
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference::address_of_real_stack_limit(isolate);
|
2014-08-06 07:20:14 +00:00
|
|
|
CHECK_EQ(make_code(UNCLASSIFIED, 3),
|
2009-11-05 13:59:40 +00:00
|
|
|
encoder.Encode(real_stack_limit_address.address()));
|
2014-08-06 07:20:14 +00:00
|
|
|
CHECK_EQ(make_code(UNCLASSIFIED, 8),
|
2011-03-22 13:20:04 +00:00
|
|
|
encoder.Encode(ExternalReference::debug_break(isolate).address()));
|
2014-08-06 07:20:14 +00:00
|
|
|
CHECK_EQ(
|
|
|
|
make_code(UNCLASSIFIED, 4),
|
|
|
|
encoder.Encode(ExternalReference::new_space_start(isolate).address()));
|
|
|
|
CHECK_EQ(
|
|
|
|
make_code(UNCLASSIFIED, 1),
|
|
|
|
encoder.Encode(ExternalReference::roots_array_start(isolate).address()));
|
|
|
|
CHECK_EQ(make_code(UNCLASSIFIED, 34),
|
2013-01-23 16:29:48 +00:00
|
|
|
encoder.Encode(ExternalReference::cpu_features().address()));
|
2008-08-22 13:33:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(ExternalReferenceDecoder) {
|
2013-09-19 09:17:13 +00:00
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
2011-08-04 15:18:18 +00:00
|
|
|
v8::V8::Initialize();
|
|
|
|
|
2013-09-03 11:54:08 +00:00
|
|
|
ExternalReferenceDecoder decoder(isolate);
|
2011-03-23 13:40:07 +00:00
|
|
|
CHECK_EQ(AddressOf(Builtins::kArrayCode),
|
|
|
|
decoder.Decode(make_code(BUILTIN, Builtins::kArrayCode)));
|
2008-08-22 13:33:59 +00:00
|
|
|
CHECK_EQ(AddressOf(Runtime::kAbort),
|
2011-02-16 13:56:23 +00:00
|
|
|
decoder.Decode(make_code(v8::internal::RUNTIME_FUNCTION,
|
|
|
|
Runtime::kAbort)));
|
2011-03-22 13:20:04 +00:00
|
|
|
CHECK_EQ(ExternalReference::address_of_stack_limit(isolate).address(),
|
2014-08-06 07:20:14 +00:00
|
|
|
decoder.Decode(make_code(UNCLASSIFIED, 2)));
|
2011-03-22 13:20:04 +00:00
|
|
|
CHECK_EQ(ExternalReference::address_of_real_stack_limit(isolate).address(),
|
2014-08-06 07:20:14 +00:00
|
|
|
decoder.Decode(make_code(UNCLASSIFIED, 3)));
|
2011-03-22 13:20:04 +00:00
|
|
|
CHECK_EQ(ExternalReference::debug_break(isolate).address(),
|
2014-08-06 07:20:14 +00:00
|
|
|
decoder.Decode(make_code(UNCLASSIFIED, 8)));
|
2011-03-22 13:20:04 +00:00
|
|
|
CHECK_EQ(ExternalReference::new_space_start(isolate).address(),
|
2014-08-06 07:20:14 +00:00
|
|
|
decoder.Decode(make_code(UNCLASSIFIED, 4)));
|
2008-08-22 13:33:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-23 11:23:57 +00:00
|
|
|
void WritePayload(const List<byte>& payload, const char* file_name) {
|
|
|
|
FILE* file = v8::base::OS::FOpen(file_name, "wb");
|
|
|
|
if (file == NULL) {
|
|
|
|
PrintF("Unable to write to snapshot file \"%s\"\n", file_name);
|
|
|
|
exit(1);
|
2010-01-27 08:25:48 +00:00
|
|
|
}
|
2014-10-23 11:23:57 +00:00
|
|
|
size_t written = fwrite(payload.begin(), 1, payload.length(), file);
|
|
|
|
if (written != static_cast<size_t>(payload.length())) {
|
|
|
|
i::PrintF("Writing snapshot file failed.. Aborting.\n");
|
|
|
|
exit(1);
|
2010-01-27 08:25:48 +00:00
|
|
|
}
|
2014-10-23 11:23:57 +00:00
|
|
|
fclose(file);
|
|
|
|
}
|
2010-01-27 08:25:48 +00:00
|
|
|
|
|
|
|
|
2014-10-23 11:23:57 +00:00
|
|
|
void WriteSpaceUsed(Serializer* ser, const char* file_name) {
|
|
|
|
int file_name_length = StrLength(file_name) + 10;
|
2010-01-27 08:25:48 +00:00
|
|
|
Vector<char> name = Vector<char>::New(file_name_length + 1);
|
2014-10-23 11:23:57 +00:00
|
|
|
SNPrintF(name, "%s.size", file_name);
|
2014-06-30 13:25:46 +00:00
|
|
|
FILE* fp = v8::base::OS::FOpen(name.start(), "w");
|
2010-10-29 07:10:41 +00:00
|
|
|
name.Dispose();
|
2014-10-15 14:04:53 +00:00
|
|
|
|
|
|
|
Vector<const uint32_t> chunks = ser->FinalAllocationChunks(NEW_SPACE);
|
|
|
|
CHECK_EQ(1, chunks.length());
|
|
|
|
fprintf(fp, "new %d\n", chunks[0]);
|
|
|
|
chunks = ser->FinalAllocationChunks(OLD_POINTER_SPACE);
|
|
|
|
CHECK_EQ(1, chunks.length());
|
|
|
|
fprintf(fp, "pointer %d\n", chunks[0]);
|
|
|
|
chunks = ser->FinalAllocationChunks(OLD_DATA_SPACE);
|
|
|
|
CHECK_EQ(1, chunks.length());
|
|
|
|
fprintf(fp, "data %d\n", chunks[0]);
|
|
|
|
chunks = ser->FinalAllocationChunks(CODE_SPACE);
|
|
|
|
CHECK_EQ(1, chunks.length());
|
|
|
|
fprintf(fp, "code %d\n", chunks[0]);
|
|
|
|
chunks = ser->FinalAllocationChunks(MAP_SPACE);
|
|
|
|
CHECK_EQ(1, chunks.length());
|
|
|
|
fprintf(fp, "map %d\n", chunks[0]);
|
|
|
|
chunks = ser->FinalAllocationChunks(CELL_SPACE);
|
|
|
|
CHECK_EQ(1, chunks.length());
|
|
|
|
fprintf(fp, "cell %d\n", chunks[0]);
|
|
|
|
chunks = ser->FinalAllocationChunks(PROPERTY_CELL_SPACE);
|
|
|
|
CHECK_EQ(1, chunks.length());
|
|
|
|
fprintf(fp, "property cell %d\n", chunks[0]);
|
|
|
|
chunks = ser->FinalAllocationChunks(LO_SPACE);
|
|
|
|
CHECK_EQ(1, chunks.length());
|
|
|
|
fprintf(fp, "lo %d\n", chunks[0]);
|
2010-01-27 08:25:48 +00:00
|
|
|
fclose(fp);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-03 11:54:08 +00:00
|
|
|
static bool WriteToFile(Isolate* isolate, const char* snapshot_file) {
|
2014-10-23 11:23:57 +00:00
|
|
|
SnapshotByteSink sink;
|
|
|
|
StartupSerializer ser(isolate, &sink);
|
2010-01-27 08:25:48 +00:00
|
|
|
ser.Serialize();
|
2014-10-15 14:04:53 +00:00
|
|
|
ser.FinalizeAllocation();
|
2012-09-14 11:16:56 +00:00
|
|
|
|
2014-10-23 11:23:57 +00:00
|
|
|
WritePayload(sink.data(), snapshot_file);
|
|
|
|
WriteSpaceUsed(&ser, snapshot_file);
|
2012-09-14 11:16:56 +00:00
|
|
|
|
2010-01-27 08:25:48 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
static void Serialize(v8::Isolate* isolate) {
|
2009-10-27 11:54:01 +00:00
|
|
|
// 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.
|
2014-09-19 08:01:35 +00:00
|
|
|
v8::Isolate::Scope isolate_scope(isolate);
|
2013-05-08 07:45:16 +00:00
|
|
|
{
|
|
|
|
v8::HandleScope scope(isolate);
|
|
|
|
v8::Context::New(isolate);
|
|
|
|
}
|
2013-09-19 12:06:27 +00:00
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
Isolate* internal_isolate = reinterpret_cast<Isolate*>(isolate);
|
2014-10-14 12:21:18 +00:00
|
|
|
internal_isolate->heap()->CollectAllAvailableGarbage("serialize");
|
2013-09-19 12:06:27 +00:00
|
|
|
WriteToFile(internal_isolate, FLAG_testing_serialization_file);
|
2008-08-22 13:33:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-27 11:54:01 +00:00
|
|
|
// Test that the whole heap can be serialized.
|
2014-09-19 08:01:35 +00:00
|
|
|
UNINITIALIZED_TEST(Serialize) {
|
2012-06-19 18:38:03 +00:00
|
|
|
if (!Snapshot::HaveASnapshotToStartFrom()) {
|
2014-09-19 08:01:35 +00:00
|
|
|
v8::Isolate::CreateParams params;
|
|
|
|
params.enable_serializer = true;
|
|
|
|
v8::Isolate* isolate = v8::Isolate::New(params);
|
|
|
|
Serialize(isolate);
|
2012-06-19 18:38:03 +00:00
|
|
|
}
|
2009-10-27 11:54:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-25 12:55:33 +00:00
|
|
|
// Test that heap serialization is non-destructive.
|
2014-09-19 08:01:35 +00:00
|
|
|
UNINITIALIZED_TEST(SerializeTwice) {
|
2012-06-19 18:38:03 +00:00
|
|
|
if (!Snapshot::HaveASnapshotToStartFrom()) {
|
2014-09-19 08:01:35 +00:00
|
|
|
v8::Isolate::CreateParams params;
|
|
|
|
params.enable_serializer = true;
|
|
|
|
v8::Isolate* isolate = v8::Isolate::New(params);
|
|
|
|
Serialize(isolate);
|
|
|
|
Serialize(isolate);
|
2012-06-19 18:38:03 +00:00
|
|
|
}
|
2009-11-25 12:55:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-22 13:33:59 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// Tests that the heap can be deserialized.
|
|
|
|
|
2014-06-23 13:52:17 +00:00
|
|
|
|
|
|
|
static void ReserveSpaceForSnapshot(Deserializer* deserializer,
|
|
|
|
const char* file_name) {
|
|
|
|
int file_name_length = StrLength(file_name) + 10;
|
|
|
|
Vector<char> name = Vector<char>::New(file_name_length + 1);
|
|
|
|
SNPrintF(name, "%s.size", file_name);
|
2014-06-30 13:25:46 +00:00
|
|
|
FILE* fp = v8::base::OS::FOpen(name.start(), "r");
|
2014-06-23 13:52:17 +00:00
|
|
|
name.Dispose();
|
|
|
|
int new_size, pointer_size, data_size, code_size, map_size, cell_size,
|
2014-09-25 07:32:13 +00:00
|
|
|
property_cell_size, lo_size;
|
2014-10-20 12:04:22 +00:00
|
|
|
#if V8_CC_MSVC
|
2014-06-23 13:52:17 +00:00
|
|
|
// Avoid warning about unsafe fscanf from MSVC.
|
|
|
|
// Please note that this is only fine if %c and %s are not being used.
|
|
|
|
#define fscanf fscanf_s
|
|
|
|
#endif
|
|
|
|
CHECK_EQ(1, fscanf(fp, "new %d\n", &new_size));
|
|
|
|
CHECK_EQ(1, fscanf(fp, "pointer %d\n", &pointer_size));
|
|
|
|
CHECK_EQ(1, fscanf(fp, "data %d\n", &data_size));
|
|
|
|
CHECK_EQ(1, fscanf(fp, "code %d\n", &code_size));
|
|
|
|
CHECK_EQ(1, fscanf(fp, "map %d\n", &map_size));
|
|
|
|
CHECK_EQ(1, fscanf(fp, "cell %d\n", &cell_size));
|
|
|
|
CHECK_EQ(1, fscanf(fp, "property cell %d\n", &property_cell_size));
|
2014-09-25 07:32:13 +00:00
|
|
|
CHECK_EQ(1, fscanf(fp, "lo %d\n", &lo_size));
|
2014-10-20 12:04:22 +00:00
|
|
|
#if V8_CC_MSVC
|
2014-06-23 13:52:17 +00:00
|
|
|
#undef fscanf
|
|
|
|
#endif
|
|
|
|
fclose(fp);
|
2014-10-15 14:04:53 +00:00
|
|
|
deserializer->AddReservation(NEW_SPACE, new_size);
|
|
|
|
deserializer->AddReservation(OLD_POINTER_SPACE, pointer_size);
|
|
|
|
deserializer->AddReservation(OLD_DATA_SPACE, data_size);
|
|
|
|
deserializer->AddReservation(CODE_SPACE, code_size);
|
|
|
|
deserializer->AddReservation(MAP_SPACE, map_size);
|
|
|
|
deserializer->AddReservation(CELL_SPACE, cell_size);
|
|
|
|
deserializer->AddReservation(PROPERTY_CELL_SPACE, property_cell_size);
|
|
|
|
deserializer->AddReservation(LO_SPACE, lo_size);
|
2014-06-23 13:52:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
v8::Isolate* InitializeFromFile(const char* snapshot_file) {
|
2014-06-23 13:52:17 +00:00
|
|
|
int len;
|
|
|
|
byte* str = ReadBytes(snapshot_file, &len);
|
2014-09-19 08:01:35 +00:00
|
|
|
if (!str) return NULL;
|
|
|
|
v8::Isolate* v8_isolate = NULL;
|
2014-06-23 13:52:17 +00:00
|
|
|
{
|
|
|
|
SnapshotByteSource source(str, len);
|
|
|
|
Deserializer deserializer(&source);
|
|
|
|
ReserveSpaceForSnapshot(&deserializer, snapshot_file);
|
2014-09-19 08:01:35 +00:00
|
|
|
Isolate* isolate = Isolate::NewForTesting();
|
|
|
|
v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
|
|
|
|
v8::Isolate::Scope isolate_scope(v8_isolate);
|
|
|
|
isolate->Init(&deserializer);
|
2014-06-23 13:52:17 +00:00
|
|
|
}
|
|
|
|
DeleteArray(str);
|
2014-09-19 08:01:35 +00:00
|
|
|
return v8_isolate;
|
2014-06-23 13:52:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
static v8::Isolate* Deserialize() {
|
|
|
|
v8::Isolate* isolate = InitializeFromFile(FLAG_testing_serialization_file);
|
|
|
|
CHECK(isolate);
|
|
|
|
return isolate;
|
2008-08-22 13:33:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
static void SanityCheck(v8::Isolate* v8_isolate) {
|
|
|
|
Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
|
|
|
|
v8::HandleScope scope(v8_isolate);
|
2012-10-15 06:34:22 +00:00
|
|
|
#ifdef VERIFY_HEAP
|
2014-09-19 08:01:35 +00:00
|
|
|
isolate->heap()->Verify();
|
2008-08-22 13:33:59 +00:00
|
|
|
#endif
|
2013-06-04 10:30:05 +00:00
|
|
|
CHECK(isolate->global_object()->IsJSObject());
|
|
|
|
CHECK(isolate->native_context()->IsContext());
|
2014-09-19 08:01:35 +00:00
|
|
|
CHECK(isolate->heap()->string_table()->IsStringTable());
|
2014-09-10 12:38:12 +00:00
|
|
|
isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("Empty"));
|
2008-08-22 13:33:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
UNINITIALIZED_DEPENDENT_TEST(Deserialize, Serialize) {
|
2010-03-23 11:40:38 +00:00
|
|
|
// 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.
|
2012-06-19 18:38:03 +00:00
|
|
|
if (!Snapshot::HaveASnapshotToStartFrom()) {
|
2014-09-19 08:01:35 +00:00
|
|
|
v8::Isolate* isolate = Deserialize();
|
|
|
|
{
|
|
|
|
v8::HandleScope handle_scope(isolate);
|
|
|
|
v8::Isolate::Scope isolate_scope(isolate);
|
2008-08-22 13:33:59 +00:00
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
v8::Local<v8::Context> env = v8::Context::New(isolate);
|
|
|
|
env->Enter();
|
2009-11-25 12:55:33 +00:00
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
SanityCheck(isolate);
|
|
|
|
}
|
|
|
|
isolate->Dispose();
|
2010-03-23 11:40:38 +00:00
|
|
|
}
|
2009-11-25 12:55:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
UNINITIALIZED_DEPENDENT_TEST(DeserializeFromSecondSerialization,
|
|
|
|
SerializeTwice) {
|
2012-06-19 18:38:03 +00:00
|
|
|
if (!Snapshot::HaveASnapshotToStartFrom()) {
|
2014-09-19 08:01:35 +00:00
|
|
|
v8::Isolate* isolate = Deserialize();
|
|
|
|
{
|
|
|
|
v8::Isolate::Scope isolate_scope(isolate);
|
|
|
|
v8::HandleScope handle_scope(isolate);
|
2009-11-25 12:55:33 +00:00
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
v8::Local<v8::Context> env = v8::Context::New(isolate);
|
|
|
|
env->Enter();
|
2009-10-27 11:54:01 +00:00
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
SanityCheck(isolate);
|
|
|
|
}
|
|
|
|
isolate->Dispose();
|
2010-03-23 11:40:38 +00:00
|
|
|
}
|
2009-10-27 11:54:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
UNINITIALIZED_DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) {
|
2012-06-19 18:38:03 +00:00
|
|
|
if (!Snapshot::HaveASnapshotToStartFrom()) {
|
2014-09-19 08:01:35 +00:00
|
|
|
v8::Isolate* isolate = Deserialize();
|
|
|
|
{
|
|
|
|
v8::Isolate::Scope isolate_scope(isolate);
|
|
|
|
v8::HandleScope handle_scope(isolate);
|
|
|
|
|
2008-08-22 13:33:59 +00:00
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
v8::Local<v8::Context> env = v8::Context::New(isolate);
|
|
|
|
env->Enter();
|
2009-10-27 11:54:01 +00:00
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
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();
|
2010-03-23 11:40:38 +00:00
|
|
|
}
|
2009-10-27 11:54:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
UNINITIALIZED_DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2,
|
|
|
|
SerializeTwice) {
|
2012-06-19 18:38:03 +00:00
|
|
|
if (!Snapshot::HaveASnapshotToStartFrom()) {
|
2014-09-19 08:01:35 +00:00
|
|
|
v8::Isolate* isolate = Deserialize();
|
|
|
|
{
|
|
|
|
v8::Isolate::Scope isolate_scope(isolate);
|
|
|
|
v8::HandleScope handle_scope(isolate);
|
2009-11-25 12:55:33 +00:00
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
v8::Local<v8::Context> env = v8::Context::New(isolate);
|
|
|
|
env->Enter();
|
2009-11-25 12:55:33 +00:00
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
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();
|
2010-03-23 11:40:38 +00:00
|
|
|
}
|
2009-11-25 12:55:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
UNINITIALIZED_TEST(PartialSerialization) {
|
2012-06-19 18:38:03 +00:00
|
|
|
if (!Snapshot::HaveASnapshotToStartFrom()) {
|
2014-09-19 08:01:35 +00:00
|
|
|
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();
|
2014-09-18 21:57:10 +00:00
|
|
|
{
|
2014-09-19 08:01:35 +00:00
|
|
|
Heap* heap = isolate->heap();
|
2010-01-14 14:46:31 +00:00
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
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));
|
|
|
|
}
|
2010-01-14 14:46:31 +00:00
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
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);
|
2014-09-18 21:57:10 +00:00
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
{
|
|
|
|
v8::HandleScope handle_scope(v8_isolate);
|
|
|
|
v8::Local<v8::Context>::New(v8_isolate, env)->Exit();
|
|
|
|
}
|
|
|
|
env.Reset();
|
|
|
|
|
2014-10-23 11:23:57 +00:00
|
|
|
SnapshotByteSink startup_sink;
|
2014-09-19 08:01:35 +00:00
|
|
|
StartupSerializer startup_serializer(isolate, &startup_sink);
|
|
|
|
startup_serializer.SerializeStrongReferences();
|
|
|
|
|
2014-10-23 11:23:57 +00:00
|
|
|
SnapshotByteSink partial_sink;
|
|
|
|
PartialSerializer partial_serializer(isolate, &startup_serializer,
|
|
|
|
&partial_sink);
|
|
|
|
partial_serializer.Serialize(&raw_foo);
|
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
startup_serializer.SerializeWeakReferences();
|
|
|
|
|
2014-10-23 11:23:57 +00:00
|
|
|
partial_serializer.FinalizeAllocation();
|
2014-10-15 14:04:53 +00:00
|
|
|
startup_serializer.FinalizeAllocation();
|
|
|
|
|
2014-10-23 11:23:57 +00:00
|
|
|
WritePayload(partial_sink.data(), FLAG_testing_serialization_file);
|
|
|
|
WritePayload(startup_sink.data(), startup_name.start());
|
|
|
|
|
|
|
|
WriteSpaceUsed(&partial_serializer, FLAG_testing_serialization_file);
|
|
|
|
WriteSpaceUsed(&startup_serializer, startup_name.start());
|
2014-10-15 14:04:53 +00:00
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
startup_name.Dispose();
|
2013-05-28 11:54:52 +00:00
|
|
|
}
|
2014-09-19 08:01:35 +00:00
|
|
|
v8_isolate->Exit();
|
|
|
|
v8_isolate->Dispose();
|
2012-06-19 18:38:03 +00:00
|
|
|
}
|
2010-01-15 14:20:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
UNINITIALIZED_DEPENDENT_TEST(PartialDeserialization, PartialSerialization) {
|
2014-06-23 13:52:17 +00:00
|
|
|
if (!Snapshot::HaveASnapshotToStartFrom()) {
|
2010-03-23 11:40:38 +00:00
|
|
|
int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
|
|
|
|
Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
|
2014-06-13 16:43:27 +00:00
|
|
|
SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
|
2010-03-23 11:40:38 +00:00
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
v8::Isolate* v8_isolate = InitializeFromFile(startup_name.start());
|
|
|
|
CHECK(v8_isolate);
|
2010-10-29 07:10:41 +00:00
|
|
|
startup_name.Dispose();
|
2014-09-18 21:57:10 +00:00
|
|
|
{
|
2014-09-19 08:01:35 +00:00
|
|
|
v8::Isolate::Scope isolate_scope(v8_isolate);
|
2014-09-18 21:57:10 +00:00
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
const char* file_name = FLAG_testing_serialization_file;
|
2014-09-18 21:57:10 +00:00
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
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);
|
|
|
|
}
|
2010-03-23 11:40:38 +00:00
|
|
|
}
|
2014-09-19 08:01:35 +00:00
|
|
|
v8_isolate->Dispose();
|
2010-01-27 08:25:48 +00:00
|
|
|
}
|
2010-03-23 11:40:38 +00:00
|
|
|
}
|
2010-01-27 08:25:48 +00:00
|
|
|
|
2010-03-23 11:40:38 +00:00
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
UNINITIALIZED_TEST(ContextSerialization) {
|
2012-06-19 18:38:03 +00:00
|
|
|
if (!Snapshot::HaveASnapshotToStartFrom()) {
|
2014-09-19 08:01:35 +00:00
|
|
|
v8::Isolate::CreateParams params;
|
|
|
|
params.enable_serializer = true;
|
|
|
|
v8::Isolate* v8_isolate = v8::Isolate::New(params);
|
|
|
|
Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
|
2013-02-15 09:27:10 +00:00
|
|
|
Heap* heap = isolate->heap();
|
2014-09-18 21:57:10 +00:00
|
|
|
{
|
2014-09-19 08:01:35 +00:00
|
|
|
v8::Isolate::Scope isolate_scope(v8_isolate);
|
|
|
|
|
|
|
|
v8::Persistent<v8::Context> env;
|
|
|
|
{
|
|
|
|
HandleScope scope(isolate);
|
|
|
|
env.Reset(v8_isolate, v8::Context::New(v8_isolate));
|
2014-09-18 21:07:50 +00:00
|
|
|
}
|
2014-09-19 08:01:35 +00:00
|
|
|
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);
|
2010-03-23 11:40:38 +00:00
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
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);
|
2010-03-23 11:40:38 +00:00
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
{
|
|
|
|
v8::HandleScope handle_scope(v8_isolate);
|
|
|
|
v8::Local<v8::Context>::New(v8_isolate, env)->Exit();
|
|
|
|
}
|
2014-09-18 21:57:10 +00:00
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
i::Object* raw_context = *v8::Utils::OpenPersistent(env);
|
|
|
|
|
|
|
|
env.Reset();
|
|
|
|
|
2014-10-23 11:23:57 +00:00
|
|
|
SnapshotByteSink startup_sink;
|
2014-09-19 08:01:35 +00:00
|
|
|
StartupSerializer startup_serializer(isolate, &startup_sink);
|
|
|
|
startup_serializer.SerializeStrongReferences();
|
|
|
|
|
2014-10-23 11:23:57 +00:00
|
|
|
SnapshotByteSink partial_sink;
|
|
|
|
PartialSerializer partial_serializer(isolate, &startup_serializer,
|
|
|
|
&partial_sink);
|
|
|
|
partial_serializer.Serialize(&raw_context);
|
2014-09-19 08:01:35 +00:00
|
|
|
startup_serializer.SerializeWeakReferences();
|
|
|
|
|
2014-10-23 11:23:57 +00:00
|
|
|
partial_serializer.FinalizeAllocation();
|
2014-10-15 14:04:53 +00:00
|
|
|
startup_serializer.FinalizeAllocation();
|
|
|
|
|
2014-10-23 11:23:57 +00:00
|
|
|
WritePayload(partial_sink.data(), FLAG_testing_serialization_file);
|
|
|
|
WritePayload(startup_sink.data(), startup_name.start());
|
|
|
|
|
|
|
|
WriteSpaceUsed(&partial_serializer, FLAG_testing_serialization_file);
|
|
|
|
WriteSpaceUsed(&startup_serializer, startup_name.start());
|
2014-10-15 14:04:53 +00:00
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
startup_name.Dispose();
|
|
|
|
}
|
|
|
|
v8_isolate->Dispose();
|
2012-06-19 18:38:03 +00:00
|
|
|
}
|
2010-03-23 11:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
UNINITIALIZED_DEPENDENT_TEST(ContextDeserialization, ContextSerialization) {
|
2012-06-19 18:38:03 +00:00
|
|
|
if (!Snapshot::HaveASnapshotToStartFrom()) {
|
2010-03-23 11:40:38 +00:00
|
|
|
int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
|
|
|
|
Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
|
2014-06-13 16:43:27 +00:00
|
|
|
SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
|
2010-03-23 11:40:38 +00:00
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
v8::Isolate* v8_isolate = InitializeFromFile(startup_name.start());
|
|
|
|
CHECK(v8_isolate);
|
2010-10-29 07:10:41 +00:00
|
|
|
startup_name.Dispose();
|
2014-09-18 21:57:10 +00:00
|
|
|
{
|
2014-09-19 08:01:35 +00:00
|
|
|
v8::Isolate::Scope isolate_scope(v8_isolate);
|
2014-09-18 21:57:10 +00:00
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
const char* file_name = FLAG_testing_serialization_file;
|
2014-09-18 21:57:10 +00:00
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
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);
|
|
|
|
}
|
2010-03-23 11:40:38 +00:00
|
|
|
}
|
2014-09-19 08:01:35 +00:00
|
|
|
v8_isolate->Dispose();
|
2010-01-27 08:25:48 +00:00
|
|
|
}
|
2010-01-14 14:46:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-22 19:09:09 +00:00
|
|
|
TEST(TestThatAlwaysSucceeds) {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(TestThatAlwaysFails) {
|
|
|
|
bool ArtificialFailure = false;
|
|
|
|
CHECK(ArtificialFailure);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) {
|
|
|
|
bool ArtificialFailure2 = false;
|
|
|
|
CHECK(ArtificialFailure2);
|
|
|
|
}
|
2014-07-14 11:22:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
int CountBuiltins() {
|
|
|
|
// Check that we have not deserialized any additional builtin.
|
|
|
|
HeapIterator iterator(CcTest::heap());
|
|
|
|
DisallowHeapAllocation no_allocation;
|
|
|
|
int counter = 0;
|
|
|
|
for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) {
|
|
|
|
if (obj->IsCode() && Code::cast(obj)->kind() == Code::BUILTIN) counter++;
|
|
|
|
}
|
|
|
|
return counter;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-15 08:46:47 +00:00
|
|
|
TEST(SerializeToplevelOnePlusOne) {
|
2014-07-14 11:22:03 +00:00
|
|
|
FLAG_serialize_toplevel = true;
|
2014-07-15 08:46:47 +00:00
|
|
|
LocalContext context;
|
2014-07-16 06:59:14 +00:00
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
isolate->compilation_cache()->Disable(); // Disable same-isolate code cache.
|
2014-07-14 11:22:03 +00:00
|
|
|
|
2014-07-16 06:59:14 +00:00
|
|
|
v8::HandleScope scope(CcTest::isolate());
|
2014-07-14 11:22:03 +00:00
|
|
|
|
2014-07-16 06:59:14 +00:00
|
|
|
const char* source = "1 + 1";
|
2014-07-14 11:22:03 +00:00
|
|
|
|
2014-07-16 06:59:14 +00:00
|
|
|
Handle<String> orig_source = isolate->factory()
|
|
|
|
->NewStringFromUtf8(CStrVector(source))
|
|
|
|
.ToHandleChecked();
|
|
|
|
Handle<String> copy_source = isolate->factory()
|
|
|
|
->NewStringFromUtf8(CStrVector(source))
|
|
|
|
.ToHandleChecked();
|
|
|
|
CHECK(!orig_source.is_identical_to(copy_source));
|
|
|
|
CHECK(orig_source->Equals(*copy_source));
|
2014-07-14 11:22:03 +00:00
|
|
|
|
|
|
|
ScriptData* cache = NULL;
|
|
|
|
|
Change ScriptCompiler::CompileOptions to allow for two 'cache' modes
(parser or code) and to be explicit about cache consumption or production
(rather than making presence of cached_data imply one or the other.)
Also add a --cache flag to d8, to allow testing the functionality.
-----------------------------
API change
Reason: Currently, V8 supports a 'parser cache' for repeatedly executing the same script. We'd like to add a 2nd mode that would cache code, and would like to let the embedder decide which mode they chose (if any).
Note: Previously, the 'use cached data' property was implied by the presence of the cached data itself. (That is, kNoCompileOptions and source->cached_data != NULL.) That is no longer sufficient, since the presence of data is no longer sufficient to determine /which kind/ of data is present.
Changes from old behaviour:
- If you previously didn't use caching, nothing changes.
Example:
v8::CompileUnbound(isolate, source, kNoCompileOptions);
- If you previously used caching, it worked like this:
- 1st run:
v8::CompileUnbound(isolate, source, kProduceToCache);
Then, source->cached_data would contain the
data-to-be cached. This remains the same, except you
need to tell V8 which type of data you want.
v8::CompileUnbound(isolate, source, kProduceParserCache);
- 2nd run:
v8::CompileUnbound(isolate, source, kNoCompileOptions);
with source->cached_data set to the data you received in
the first run. This will now ignore the cached data, and
you need to explicitly tell V8 to use it:
v8::CompileUnbound(isolate, source, kConsumeParserCache);
-----------------------------
BUG=
R=marja@chromium.org, yangguo@chromium.org
Review URL: https://codereview.chromium.org/389573006
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22431 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2014-07-16 12:18:33 +00:00
|
|
|
Handle<SharedFunctionInfo> orig = Compiler::CompileScript(
|
|
|
|
orig_source, Handle<String>(), 0, 0, false,
|
|
|
|
Handle<Context>(isolate->native_context()), NULL, &cache,
|
|
|
|
v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE);
|
2014-07-14 11:22:03 +00:00
|
|
|
|
|
|
|
int builtins_count = CountBuiltins();
|
|
|
|
|
2014-07-16 06:59:14 +00:00
|
|
|
Handle<SharedFunctionInfo> copy;
|
|
|
|
{
|
|
|
|
DisallowCompilation no_compile_expected(isolate);
|
Change ScriptCompiler::CompileOptions to allow for two 'cache' modes
(parser or code) and to be explicit about cache consumption or production
(rather than making presence of cached_data imply one or the other.)
Also add a --cache flag to d8, to allow testing the functionality.
-----------------------------
API change
Reason: Currently, V8 supports a 'parser cache' for repeatedly executing the same script. We'd like to add a 2nd mode that would cache code, and would like to let the embedder decide which mode they chose (if any).
Note: Previously, the 'use cached data' property was implied by the presence of the cached data itself. (That is, kNoCompileOptions and source->cached_data != NULL.) That is no longer sufficient, since the presence of data is no longer sufficient to determine /which kind/ of data is present.
Changes from old behaviour:
- If you previously didn't use caching, nothing changes.
Example:
v8::CompileUnbound(isolate, source, kNoCompileOptions);
- If you previously used caching, it worked like this:
- 1st run:
v8::CompileUnbound(isolate, source, kProduceToCache);
Then, source->cached_data would contain the
data-to-be cached. This remains the same, except you
need to tell V8 which type of data you want.
v8::CompileUnbound(isolate, source, kProduceParserCache);
- 2nd run:
v8::CompileUnbound(isolate, source, kNoCompileOptions);
with source->cached_data set to the data you received in
the first run. This will now ignore the cached data, and
you need to explicitly tell V8 to use it:
v8::CompileUnbound(isolate, source, kConsumeParserCache);
-----------------------------
BUG=
R=marja@chromium.org, yangguo@chromium.org
Review URL: https://codereview.chromium.org/389573006
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22431 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2014-07-16 12:18:33 +00:00
|
|
|
copy = Compiler::CompileScript(
|
|
|
|
copy_source, Handle<String>(), 0, 0, false,
|
|
|
|
Handle<Context>(isolate->native_context()), NULL, &cache,
|
|
|
|
v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE);
|
2014-07-16 06:59:14 +00:00
|
|
|
}
|
Change ScriptCompiler::CompileOptions to allow for two 'cache' modes
(parser or code) and to be explicit about cache consumption or production
(rather than making presence of cached_data imply one or the other.)
Also add a --cache flag to d8, to allow testing the functionality.
-----------------------------
API change
Reason: Currently, V8 supports a 'parser cache' for repeatedly executing the same script. We'd like to add a 2nd mode that would cache code, and would like to let the embedder decide which mode they chose (if any).
Note: Previously, the 'use cached data' property was implied by the presence of the cached data itself. (That is, kNoCompileOptions and source->cached_data != NULL.) That is no longer sufficient, since the presence of data is no longer sufficient to determine /which kind/ of data is present.
Changes from old behaviour:
- If you previously didn't use caching, nothing changes.
Example:
v8::CompileUnbound(isolate, source, kNoCompileOptions);
- If you previously used caching, it worked like this:
- 1st run:
v8::CompileUnbound(isolate, source, kProduceToCache);
Then, source->cached_data would contain the
data-to-be cached. This remains the same, except you
need to tell V8 which type of data you want.
v8::CompileUnbound(isolate, source, kProduceParserCache);
- 2nd run:
v8::CompileUnbound(isolate, source, kNoCompileOptions);
with source->cached_data set to the data you received in
the first run. This will now ignore the cached data, and
you need to explicitly tell V8 to use it:
v8::CompileUnbound(isolate, source, kConsumeParserCache);
-----------------------------
BUG=
R=marja@chromium.org, yangguo@chromium.org
Review URL: https://codereview.chromium.org/389573006
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22431 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2014-07-16 12:18:33 +00:00
|
|
|
|
2014-07-15 08:46:47 +00:00
|
|
|
CHECK_NE(*orig, *copy);
|
2014-07-16 06:59:14 +00:00
|
|
|
CHECK(Script::cast(copy->script())->source() == *copy_source);
|
2014-07-15 10:17:22 +00:00
|
|
|
|
2014-07-15 08:46:47 +00:00
|
|
|
Handle<JSFunction> copy_fun =
|
2014-07-14 11:22:03 +00:00
|
|
|
isolate->factory()->NewFunctionFromSharedFunctionInfo(
|
2014-07-15 08:46:47 +00:00
|
|
|
copy, isolate->native_context());
|
2014-07-14 11:22:03 +00:00
|
|
|
Handle<JSObject> global(isolate->context()->global_object());
|
2014-07-15 08:46:47 +00:00
|
|
|
Handle<Object> copy_result =
|
|
|
|
Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked();
|
|
|
|
CHECK_EQ(2, Handle<Smi>::cast(copy_result)->value());
|
2014-07-14 11:22:03 +00:00
|
|
|
|
|
|
|
CHECK_EQ(builtins_count, CountBuiltins());
|
|
|
|
|
|
|
|
delete cache;
|
|
|
|
}
|
2014-07-15 08:46:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
TEST(SerializeToplevelInternalizedString) {
|
|
|
|
FLAG_serialize_toplevel = true;
|
|
|
|
LocalContext context;
|
2014-07-16 06:59:14 +00:00
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
isolate->compilation_cache()->Disable(); // Disable same-isolate code cache.
|
|
|
|
|
2014-07-15 08:46:47 +00:00
|
|
|
v8::HandleScope scope(CcTest::isolate());
|
|
|
|
|
2014-07-16 06:59:14 +00:00
|
|
|
const char* source = "'string1'";
|
2014-07-15 08:46:47 +00:00
|
|
|
|
2014-07-16 06:59:14 +00:00
|
|
|
Handle<String> orig_source = isolate->factory()
|
|
|
|
->NewStringFromUtf8(CStrVector(source))
|
|
|
|
.ToHandleChecked();
|
|
|
|
Handle<String> copy_source = isolate->factory()
|
|
|
|
->NewStringFromUtf8(CStrVector(source))
|
|
|
|
.ToHandleChecked();
|
|
|
|
CHECK(!orig_source.is_identical_to(copy_source));
|
|
|
|
CHECK(orig_source->Equals(*copy_source));
|
2014-07-15 08:46:47 +00:00
|
|
|
|
|
|
|
Handle<JSObject> global(isolate->context()->global_object());
|
|
|
|
ScriptData* cache = NULL;
|
|
|
|
|
Change ScriptCompiler::CompileOptions to allow for two 'cache' modes
(parser or code) and to be explicit about cache consumption or production
(rather than making presence of cached_data imply one or the other.)
Also add a --cache flag to d8, to allow testing the functionality.
-----------------------------
API change
Reason: Currently, V8 supports a 'parser cache' for repeatedly executing the same script. We'd like to add a 2nd mode that would cache code, and would like to let the embedder decide which mode they chose (if any).
Note: Previously, the 'use cached data' property was implied by the presence of the cached data itself. (That is, kNoCompileOptions and source->cached_data != NULL.) That is no longer sufficient, since the presence of data is no longer sufficient to determine /which kind/ of data is present.
Changes from old behaviour:
- If you previously didn't use caching, nothing changes.
Example:
v8::CompileUnbound(isolate, source, kNoCompileOptions);
- If you previously used caching, it worked like this:
- 1st run:
v8::CompileUnbound(isolate, source, kProduceToCache);
Then, source->cached_data would contain the
data-to-be cached. This remains the same, except you
need to tell V8 which type of data you want.
v8::CompileUnbound(isolate, source, kProduceParserCache);
- 2nd run:
v8::CompileUnbound(isolate, source, kNoCompileOptions);
with source->cached_data set to the data you received in
the first run. This will now ignore the cached data, and
you need to explicitly tell V8 to use it:
v8::CompileUnbound(isolate, source, kConsumeParserCache);
-----------------------------
BUG=
R=marja@chromium.org, yangguo@chromium.org
Review URL: https://codereview.chromium.org/389573006
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22431 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2014-07-16 12:18:33 +00:00
|
|
|
Handle<SharedFunctionInfo> orig = Compiler::CompileScript(
|
|
|
|
orig_source, Handle<String>(), 0, 0, false,
|
|
|
|
Handle<Context>(isolate->native_context()), NULL, &cache,
|
|
|
|
v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE);
|
2014-07-15 08:46:47 +00:00
|
|
|
Handle<JSFunction> orig_fun =
|
|
|
|
isolate->factory()->NewFunctionFromSharedFunctionInfo(
|
|
|
|
orig, isolate->native_context());
|
|
|
|
Handle<Object> orig_result =
|
|
|
|
Execution::Call(isolate, orig_fun, global, 0, NULL).ToHandleChecked();
|
|
|
|
CHECK(orig_result->IsInternalizedString());
|
|
|
|
|
|
|
|
int builtins_count = CountBuiltins();
|
|
|
|
|
2014-07-16 06:59:14 +00:00
|
|
|
Handle<SharedFunctionInfo> copy;
|
|
|
|
{
|
|
|
|
DisallowCompilation no_compile_expected(isolate);
|
Change ScriptCompiler::CompileOptions to allow for two 'cache' modes
(parser or code) and to be explicit about cache consumption or production
(rather than making presence of cached_data imply one or the other.)
Also add a --cache flag to d8, to allow testing the functionality.
-----------------------------
API change
Reason: Currently, V8 supports a 'parser cache' for repeatedly executing the same script. We'd like to add a 2nd mode that would cache code, and would like to let the embedder decide which mode they chose (if any).
Note: Previously, the 'use cached data' property was implied by the presence of the cached data itself. (That is, kNoCompileOptions and source->cached_data != NULL.) That is no longer sufficient, since the presence of data is no longer sufficient to determine /which kind/ of data is present.
Changes from old behaviour:
- If you previously didn't use caching, nothing changes.
Example:
v8::CompileUnbound(isolate, source, kNoCompileOptions);
- If you previously used caching, it worked like this:
- 1st run:
v8::CompileUnbound(isolate, source, kProduceToCache);
Then, source->cached_data would contain the
data-to-be cached. This remains the same, except you
need to tell V8 which type of data you want.
v8::CompileUnbound(isolate, source, kProduceParserCache);
- 2nd run:
v8::CompileUnbound(isolate, source, kNoCompileOptions);
with source->cached_data set to the data you received in
the first run. This will now ignore the cached data, and
you need to explicitly tell V8 to use it:
v8::CompileUnbound(isolate, source, kConsumeParserCache);
-----------------------------
BUG=
R=marja@chromium.org, yangguo@chromium.org
Review URL: https://codereview.chromium.org/389573006
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22431 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2014-07-16 12:18:33 +00:00
|
|
|
copy = Compiler::CompileScript(
|
|
|
|
copy_source, Handle<String>(), 0, 0, false,
|
|
|
|
Handle<Context>(isolate->native_context()), NULL, &cache,
|
|
|
|
v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE);
|
2014-07-16 06:59:14 +00:00
|
|
|
}
|
2014-07-15 08:46:47 +00:00
|
|
|
CHECK_NE(*orig, *copy);
|
2014-07-16 06:59:14 +00:00
|
|
|
CHECK(Script::cast(copy->script())->source() == *copy_source);
|
2014-07-15 10:17:22 +00:00
|
|
|
|
2014-07-15 08:46:47 +00:00
|
|
|
Handle<JSFunction> copy_fun =
|
|
|
|
isolate->factory()->NewFunctionFromSharedFunctionInfo(
|
|
|
|
copy, isolate->native_context());
|
|
|
|
CHECK_NE(*orig_fun, *copy_fun);
|
|
|
|
Handle<Object> copy_result =
|
|
|
|
Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked();
|
|
|
|
CHECK(orig_result.is_identical_to(copy_result));
|
|
|
|
Handle<String> expected =
|
|
|
|
isolate->factory()->NewStringFromAsciiChecked("string1");
|
|
|
|
|
|
|
|
CHECK(Handle<String>::cast(copy_result)->Equals(*expected));
|
|
|
|
CHECK_EQ(builtins_count, CountBuiltins());
|
|
|
|
|
|
|
|
delete cache;
|
|
|
|
}
|
2014-07-23 07:16:32 +00:00
|
|
|
|
|
|
|
|
2014-09-25 07:32:13 +00:00
|
|
|
Vector<const uint8_t> ConstructSource(Vector<const uint8_t> head,
|
|
|
|
Vector<const uint8_t> body,
|
|
|
|
Vector<const uint8_t> tail, int repeats) {
|
|
|
|
int source_length = head.length() + body.length() * repeats + tail.length();
|
|
|
|
uint8_t* source = NewArray<uint8_t>(static_cast<size_t>(source_length));
|
|
|
|
CopyChars(source, head.start(), head.length());
|
|
|
|
for (int i = 0; i < repeats; i++) {
|
|
|
|
CopyChars(source + head.length() + i * body.length(), body.start(),
|
|
|
|
body.length());
|
|
|
|
}
|
|
|
|
CopyChars(source + head.length() + repeats * body.length(), tail.start(),
|
|
|
|
tail.length());
|
|
|
|
return Vector<const uint8_t>(const_cast<const uint8_t*>(source),
|
|
|
|
source_length);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(SerializeToplevelLargeCodeObject) {
|
|
|
|
FLAG_serialize_toplevel = true;
|
|
|
|
LocalContext context;
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
isolate->compilation_cache()->Disable(); // Disable same-isolate code cache.
|
|
|
|
|
|
|
|
v8::HandleScope scope(CcTest::isolate());
|
|
|
|
|
|
|
|
Vector<const uint8_t> source =
|
|
|
|
ConstructSource(STATIC_CHAR_VECTOR("var j=1; try { if (j) throw 1;"),
|
|
|
|
STATIC_CHAR_VECTOR("for(var i=0;i<1;i++)j++;"),
|
|
|
|
STATIC_CHAR_VECTOR("} catch (e) { j=7; } j"), 10000);
|
|
|
|
Handle<String> source_str =
|
|
|
|
isolate->factory()->NewStringFromOneByte(source).ToHandleChecked();
|
|
|
|
|
|
|
|
Handle<JSObject> global(isolate->context()->global_object());
|
|
|
|
ScriptData* cache = NULL;
|
|
|
|
|
|
|
|
Handle<SharedFunctionInfo> orig = Compiler::CompileScript(
|
|
|
|
source_str, Handle<String>(), 0, 0, false,
|
|
|
|
Handle<Context>(isolate->native_context()), NULL, &cache,
|
|
|
|
v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE);
|
|
|
|
|
|
|
|
CHECK(isolate->heap()->InSpace(orig->code(), LO_SPACE));
|
|
|
|
|
|
|
|
Handle<SharedFunctionInfo> copy;
|
|
|
|
{
|
|
|
|
DisallowCompilation no_compile_expected(isolate);
|
|
|
|
copy = Compiler::CompileScript(
|
|
|
|
source_str, Handle<String>(), 0, 0, false,
|
|
|
|
Handle<Context>(isolate->native_context()), NULL, &cache,
|
|
|
|
v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE);
|
|
|
|
}
|
|
|
|
CHECK_NE(*orig, *copy);
|
|
|
|
|
|
|
|
Handle<JSFunction> copy_fun =
|
|
|
|
isolate->factory()->NewFunctionFromSharedFunctionInfo(
|
|
|
|
copy, isolate->native_context());
|
|
|
|
|
|
|
|
Handle<Object> copy_result =
|
|
|
|
Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked();
|
|
|
|
|
|
|
|
int result_int;
|
|
|
|
CHECK(copy_result->ToInt32(&result_int));
|
|
|
|
CHECK_EQ(7, result_int);
|
|
|
|
|
|
|
|
delete cache;
|
|
|
|
source.Dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-27 16:40:04 +00:00
|
|
|
TEST(SerializeToplevelLargeStrings) {
|
2014-09-25 07:32:13 +00:00
|
|
|
FLAG_serialize_toplevel = true;
|
|
|
|
LocalContext context;
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
2014-10-27 16:40:04 +00:00
|
|
|
Factory* f = isolate->factory();
|
2014-09-25 07:32:13 +00:00
|
|
|
isolate->compilation_cache()->Disable(); // Disable same-isolate code cache.
|
|
|
|
|
|
|
|
v8::HandleScope scope(CcTest::isolate());
|
|
|
|
|
2014-10-27 16:40:04 +00:00
|
|
|
Vector<const uint8_t> source_s = ConstructSource(
|
2014-09-25 07:32:13 +00:00
|
|
|
STATIC_CHAR_VECTOR("var s = \""), STATIC_CHAR_VECTOR("abcdef"),
|
2014-10-27 16:40:04 +00:00
|
|
|
STATIC_CHAR_VECTOR("\";"), 1000000);
|
|
|
|
Vector<const uint8_t> source_t = ConstructSource(
|
|
|
|
STATIC_CHAR_VECTOR("var t = \""), STATIC_CHAR_VECTOR("uvwxyz"),
|
|
|
|
STATIC_CHAR_VECTOR("\"; s + t"), 999999);
|
2014-09-25 07:32:13 +00:00
|
|
|
Handle<String> source_str =
|
2014-10-27 16:40:04 +00:00
|
|
|
f->NewConsString(f->NewStringFromOneByte(source_s).ToHandleChecked(),
|
|
|
|
f->NewStringFromOneByte(source_t).ToHandleChecked())
|
|
|
|
.ToHandleChecked();
|
2014-09-25 07:32:13 +00:00
|
|
|
|
|
|
|
Handle<JSObject> global(isolate->context()->global_object());
|
|
|
|
ScriptData* cache = NULL;
|
|
|
|
|
|
|
|
Handle<SharedFunctionInfo> orig = Compiler::CompileScript(
|
|
|
|
source_str, Handle<String>(), 0, 0, false,
|
|
|
|
Handle<Context>(isolate->native_context()), NULL, &cache,
|
|
|
|
v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE);
|
|
|
|
|
|
|
|
Handle<SharedFunctionInfo> copy;
|
|
|
|
{
|
|
|
|
DisallowCompilation no_compile_expected(isolate);
|
|
|
|
copy = Compiler::CompileScript(
|
|
|
|
source_str, Handle<String>(), 0, 0, false,
|
|
|
|
Handle<Context>(isolate->native_context()), NULL, &cache,
|
|
|
|
v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE);
|
|
|
|
}
|
|
|
|
CHECK_NE(*orig, *copy);
|
|
|
|
|
|
|
|
Handle<JSFunction> copy_fun =
|
|
|
|
isolate->factory()->NewFunctionFromSharedFunctionInfo(
|
|
|
|
copy, isolate->native_context());
|
|
|
|
|
|
|
|
Handle<Object> copy_result =
|
|
|
|
Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked();
|
|
|
|
|
2014-10-27 16:40:04 +00:00
|
|
|
CHECK_EQ(6 * 1999999, Handle<String>::cast(copy_result)->length());
|
|
|
|
Handle<Object> property = JSObject::GetDataProperty(
|
|
|
|
isolate->global_object(), f->NewStringFromAsciiChecked("s"));
|
|
|
|
CHECK(isolate->heap()->InSpace(HeapObject::cast(*property), LO_SPACE));
|
|
|
|
property = JSObject::GetDataProperty(isolate->global_object(),
|
|
|
|
f->NewStringFromAsciiChecked("t"));
|
|
|
|
CHECK(isolate->heap()->InSpace(HeapObject::cast(*property), LO_SPACE));
|
2014-10-24 12:40:05 +00:00
|
|
|
// Make sure we do not serialize too much, e.g. include the source string.
|
2014-10-27 16:40:04 +00:00
|
|
|
CHECK_LT(cache->length(), 13000000);
|
2014-09-25 07:32:13 +00:00
|
|
|
|
|
|
|
delete cache;
|
2014-10-27 16:40:04 +00:00
|
|
|
source_s.Dispose();
|
|
|
|
source_t.Dispose();
|
2014-09-25 07:32:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-15 14:04:53 +00:00
|
|
|
TEST(SerializeToplevelThreeBigStrings) {
|
|
|
|
FLAG_serialize_toplevel = true;
|
|
|
|
LocalContext context;
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
Factory* f = isolate->factory();
|
|
|
|
isolate->compilation_cache()->Disable(); // Disable same-isolate code cache.
|
|
|
|
|
|
|
|
v8::HandleScope scope(CcTest::isolate());
|
|
|
|
|
|
|
|
Vector<const uint8_t> source_a =
|
|
|
|
ConstructSource(STATIC_CHAR_VECTOR("var a = \""), STATIC_CHAR_VECTOR("a"),
|
|
|
|
STATIC_CHAR_VECTOR("\";"), 700000);
|
|
|
|
Handle<String> source_a_str =
|
|
|
|
f->NewStringFromOneByte(source_a).ToHandleChecked();
|
|
|
|
|
|
|
|
Vector<const uint8_t> source_b =
|
|
|
|
ConstructSource(STATIC_CHAR_VECTOR("var b = \""), STATIC_CHAR_VECTOR("b"),
|
|
|
|
STATIC_CHAR_VECTOR("\";"), 600000);
|
|
|
|
Handle<String> source_b_str =
|
|
|
|
f->NewStringFromOneByte(source_b).ToHandleChecked();
|
|
|
|
|
|
|
|
Vector<const uint8_t> source_c =
|
|
|
|
ConstructSource(STATIC_CHAR_VECTOR("var c = \""), STATIC_CHAR_VECTOR("c"),
|
|
|
|
STATIC_CHAR_VECTOR("\";"), 500000);
|
|
|
|
Handle<String> source_c_str =
|
|
|
|
f->NewStringFromOneByte(source_c).ToHandleChecked();
|
|
|
|
|
|
|
|
Handle<String> source_str =
|
|
|
|
f->NewConsString(
|
|
|
|
f->NewConsString(source_a_str, source_b_str).ToHandleChecked(),
|
|
|
|
source_c_str).ToHandleChecked();
|
|
|
|
|
|
|
|
Handle<JSObject> global(isolate->context()->global_object());
|
|
|
|
ScriptData* cache = NULL;
|
|
|
|
|
|
|
|
Handle<SharedFunctionInfo> orig = Compiler::CompileScript(
|
|
|
|
source_str, Handle<String>(), 0, 0, false,
|
|
|
|
Handle<Context>(isolate->native_context()), NULL, &cache,
|
|
|
|
v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE);
|
|
|
|
|
|
|
|
Handle<SharedFunctionInfo> copy;
|
|
|
|
{
|
|
|
|
DisallowCompilation no_compile_expected(isolate);
|
|
|
|
copy = Compiler::CompileScript(
|
|
|
|
source_str, Handle<String>(), 0, 0, false,
|
|
|
|
Handle<Context>(isolate->native_context()), NULL, &cache,
|
|
|
|
v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE);
|
|
|
|
}
|
|
|
|
CHECK_NE(*orig, *copy);
|
|
|
|
|
|
|
|
Handle<JSFunction> copy_fun =
|
|
|
|
isolate->factory()->NewFunctionFromSharedFunctionInfo(
|
|
|
|
copy, isolate->native_context());
|
|
|
|
|
2014-10-15 14:42:32 +00:00
|
|
|
USE(Execution::Call(isolate, copy_fun, global, 0, NULL));
|
2014-10-15 14:04:53 +00:00
|
|
|
|
|
|
|
CHECK_EQ(600000 + 700000, CompileRun("(a + b).length")->Int32Value());
|
|
|
|
CHECK_EQ(500000 + 600000, CompileRun("(b + c).length")->Int32Value());
|
|
|
|
Heap* heap = isolate->heap();
|
2014-11-24 10:30:39 +00:00
|
|
|
CHECK(heap->InSpace(
|
|
|
|
*v8::Utils::OpenHandle(*CompileRun("a")->ToString(CcTest::isolate())),
|
|
|
|
OLD_DATA_SPACE));
|
|
|
|
CHECK(heap->InSpace(
|
|
|
|
*v8::Utils::OpenHandle(*CompileRun("b")->ToString(CcTest::isolate())),
|
|
|
|
OLD_DATA_SPACE));
|
|
|
|
CHECK(heap->InSpace(
|
|
|
|
*v8::Utils::OpenHandle(*CompileRun("c")->ToString(CcTest::isolate())),
|
|
|
|
OLD_DATA_SPACE));
|
2014-10-15 14:04:53 +00:00
|
|
|
|
|
|
|
delete cache;
|
|
|
|
source_a.Dispose();
|
|
|
|
source_b.Dispose();
|
2014-10-16 13:26:28 +00:00
|
|
|
source_c.Dispose();
|
2014-10-15 14:04:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-02 08:18:03 +00:00
|
|
|
class SerializerOneByteResource
|
|
|
|
: public v8::String::ExternalOneByteStringResource {
|
2014-10-02 07:12:46 +00:00
|
|
|
public:
|
2014-10-02 08:18:03 +00:00
|
|
|
SerializerOneByteResource(const char* data, size_t length)
|
2014-10-02 07:12:46 +00:00
|
|
|
: data_(data), length_(length) {}
|
|
|
|
virtual const char* data() const { return data_; }
|
|
|
|
virtual size_t length() const { return length_; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
const char* data_;
|
|
|
|
size_t length_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-10-02 08:18:03 +00:00
|
|
|
class SerializerTwoByteResource : public v8::String::ExternalStringResource {
|
2014-10-02 07:12:46 +00:00
|
|
|
public:
|
2014-10-02 08:18:03 +00:00
|
|
|
SerializerTwoByteResource(const char* data, size_t length)
|
2014-10-02 07:12:46 +00:00
|
|
|
: data_(AsciiToTwoByteString(data)), length_(length) {}
|
2014-10-02 08:18:03 +00:00
|
|
|
~SerializerTwoByteResource() { DeleteArray<const uint16_t>(data_); }
|
2014-10-02 07:12:46 +00:00
|
|
|
|
|
|
|
virtual const uint16_t* data() const { return data_; }
|
|
|
|
virtual size_t length() const { return length_; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
const uint16_t* data_;
|
|
|
|
size_t length_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
TEST(SerializeToplevelExternalString) {
|
|
|
|
FLAG_serialize_toplevel = true;
|
|
|
|
LocalContext context;
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
isolate->compilation_cache()->Disable(); // Disable same-isolate code cache.
|
|
|
|
|
|
|
|
v8::HandleScope scope(CcTest::isolate());
|
|
|
|
|
|
|
|
// Obtain external internalized one-byte string.
|
2014-10-02 08:18:03 +00:00
|
|
|
SerializerOneByteResource one_byte_resource("one_byte", 8);
|
2014-10-02 07:12:46 +00:00
|
|
|
Handle<String> one_byte_string =
|
|
|
|
isolate->factory()->NewStringFromAsciiChecked("one_byte");
|
|
|
|
one_byte_string = isolate->factory()->InternalizeString(one_byte_string);
|
|
|
|
one_byte_string->MakeExternal(&one_byte_resource);
|
|
|
|
CHECK(one_byte_string->IsExternalOneByteString());
|
|
|
|
CHECK(one_byte_string->IsInternalizedString());
|
|
|
|
|
|
|
|
// Obtain external internalized two-byte string.
|
2014-10-02 08:18:03 +00:00
|
|
|
SerializerTwoByteResource two_byte_resource("two_byte", 8);
|
2014-10-02 07:12:46 +00:00
|
|
|
Handle<String> two_byte_string =
|
|
|
|
isolate->factory()->NewStringFromAsciiChecked("two_byte");
|
|
|
|
two_byte_string = isolate->factory()->InternalizeString(two_byte_string);
|
|
|
|
two_byte_string->MakeExternal(&two_byte_resource);
|
|
|
|
CHECK(two_byte_string->IsExternalTwoByteString());
|
|
|
|
CHECK(two_byte_string->IsInternalizedString());
|
|
|
|
|
|
|
|
const char* source =
|
|
|
|
"var o = {} \n"
|
|
|
|
"o.one_byte = 7; \n"
|
|
|
|
"o.two_byte = 8; \n"
|
|
|
|
"o.one_byte + o.two_byte; \n";
|
|
|
|
Handle<String> source_string = isolate->factory()
|
|
|
|
->NewStringFromUtf8(CStrVector(source))
|
|
|
|
.ToHandleChecked();
|
|
|
|
|
|
|
|
Handle<JSObject> global(isolate->context()->global_object());
|
|
|
|
ScriptData* cache = NULL;
|
|
|
|
|
|
|
|
Handle<SharedFunctionInfo> orig = Compiler::CompileScript(
|
|
|
|
source_string, Handle<String>(), 0, 0, false,
|
|
|
|
Handle<Context>(isolate->native_context()), NULL, &cache,
|
|
|
|
v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE);
|
|
|
|
|
|
|
|
Handle<SharedFunctionInfo> copy;
|
|
|
|
{
|
|
|
|
DisallowCompilation no_compile_expected(isolate);
|
|
|
|
copy = Compiler::CompileScript(
|
|
|
|
source_string, Handle<String>(), 0, 0, false,
|
|
|
|
Handle<Context>(isolate->native_context()), NULL, &cache,
|
|
|
|
v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE);
|
|
|
|
}
|
|
|
|
CHECK_NE(*orig, *copy);
|
|
|
|
|
|
|
|
Handle<JSFunction> copy_fun =
|
|
|
|
isolate->factory()->NewFunctionFromSharedFunctionInfo(
|
|
|
|
copy, isolate->native_context());
|
|
|
|
|
|
|
|
Handle<Object> copy_result =
|
|
|
|
Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked();
|
|
|
|
|
|
|
|
CHECK_EQ(15.0f, copy_result->Number());
|
|
|
|
|
|
|
|
delete cache;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(SerializeToplevelLargeExternalString) {
|
|
|
|
FLAG_serialize_toplevel = true;
|
|
|
|
LocalContext context;
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
isolate->compilation_cache()->Disable(); // Disable same-isolate code cache.
|
|
|
|
|
|
|
|
Factory* f = isolate->factory();
|
|
|
|
|
|
|
|
v8::HandleScope scope(CcTest::isolate());
|
|
|
|
|
|
|
|
// Create a huge external internalized string to use as variable name.
|
|
|
|
Vector<const uint8_t> string =
|
|
|
|
ConstructSource(STATIC_CHAR_VECTOR(""), STATIC_CHAR_VECTOR("abcdef"),
|
2014-10-24 07:29:39 +00:00
|
|
|
STATIC_CHAR_VECTOR(""), 999999);
|
2014-10-02 07:12:46 +00:00
|
|
|
Handle<String> name = f->NewStringFromOneByte(string).ToHandleChecked();
|
2014-10-02 08:18:03 +00:00
|
|
|
SerializerOneByteResource one_byte_resource(
|
2014-10-02 07:12:46 +00:00
|
|
|
reinterpret_cast<const char*>(string.start()), string.length());
|
|
|
|
name = f->InternalizeString(name);
|
|
|
|
name->MakeExternal(&one_byte_resource);
|
|
|
|
CHECK(name->IsExternalOneByteString());
|
|
|
|
CHECK(name->IsInternalizedString());
|
|
|
|
CHECK(isolate->heap()->InSpace(*name, LO_SPACE));
|
|
|
|
|
|
|
|
// Create the source, which is "var <literal> = 42; <literal>".
|
|
|
|
Handle<String> source_str =
|
|
|
|
f->NewConsString(
|
|
|
|
f->NewConsString(f->NewStringFromAsciiChecked("var "), name)
|
|
|
|
.ToHandleChecked(),
|
|
|
|
f->NewConsString(f->NewStringFromAsciiChecked(" = 42; "), name)
|
|
|
|
.ToHandleChecked()).ToHandleChecked();
|
|
|
|
|
|
|
|
Handle<JSObject> global(isolate->context()->global_object());
|
|
|
|
ScriptData* cache = NULL;
|
|
|
|
|
|
|
|
Handle<SharedFunctionInfo> orig = Compiler::CompileScript(
|
|
|
|
source_str, Handle<String>(), 0, 0, false,
|
|
|
|
Handle<Context>(isolate->native_context()), NULL, &cache,
|
|
|
|
v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE);
|
|
|
|
|
|
|
|
Handle<SharedFunctionInfo> copy;
|
|
|
|
{
|
|
|
|
DisallowCompilation no_compile_expected(isolate);
|
|
|
|
copy = Compiler::CompileScript(
|
|
|
|
source_str, Handle<String>(), 0, 0, false,
|
|
|
|
Handle<Context>(isolate->native_context()), NULL, &cache,
|
|
|
|
v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE);
|
|
|
|
}
|
|
|
|
CHECK_NE(*orig, *copy);
|
|
|
|
|
|
|
|
Handle<JSFunction> copy_fun =
|
2014-10-02 09:39:13 +00:00
|
|
|
f->NewFunctionFromSharedFunctionInfo(copy, isolate->native_context());
|
2014-10-02 07:12:46 +00:00
|
|
|
|
|
|
|
Handle<Object> copy_result =
|
|
|
|
Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked();
|
|
|
|
|
|
|
|
CHECK_EQ(42.0f, copy_result->Number());
|
|
|
|
|
|
|
|
delete cache;
|
|
|
|
string.Dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-02 09:39:13 +00:00
|
|
|
TEST(SerializeToplevelExternalScriptName) {
|
|
|
|
FLAG_serialize_toplevel = true;
|
|
|
|
LocalContext context;
|
|
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
|
|
isolate->compilation_cache()->Disable(); // Disable same-isolate code cache.
|
|
|
|
|
|
|
|
Factory* f = isolate->factory();
|
|
|
|
|
|
|
|
v8::HandleScope scope(CcTest::isolate());
|
|
|
|
|
|
|
|
const char* source =
|
|
|
|
"var a = [1, 2, 3, 4];"
|
|
|
|
"a.reduce(function(x, y) { return x + y }, 0)";
|
|
|
|
|
|
|
|
Handle<String> source_string =
|
|
|
|
f->NewStringFromUtf8(CStrVector(source)).ToHandleChecked();
|
|
|
|
|
|
|
|
const SerializerOneByteResource one_byte_resource("one_byte", 8);
|
|
|
|
Handle<String> name =
|
|
|
|
f->NewExternalStringFromOneByte(&one_byte_resource).ToHandleChecked();
|
|
|
|
CHECK(name->IsExternalOneByteString());
|
|
|
|
CHECK(!name->IsInternalizedString());
|
|
|
|
|
|
|
|
Handle<JSObject> global(isolate->context()->global_object());
|
|
|
|
ScriptData* cache = NULL;
|
|
|
|
|
|
|
|
Handle<SharedFunctionInfo> orig = Compiler::CompileScript(
|
|
|
|
source_string, name, 0, 0, false,
|
|
|
|
Handle<Context>(isolate->native_context()), NULL, &cache,
|
|
|
|
v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE);
|
|
|
|
|
|
|
|
Handle<SharedFunctionInfo> copy;
|
|
|
|
{
|
|
|
|
DisallowCompilation no_compile_expected(isolate);
|
|
|
|
copy = Compiler::CompileScript(
|
|
|
|
source_string, name, 0, 0, false,
|
|
|
|
Handle<Context>(isolate->native_context()), NULL, &cache,
|
|
|
|
v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE);
|
|
|
|
}
|
|
|
|
CHECK_NE(*orig, *copy);
|
|
|
|
|
|
|
|
Handle<JSFunction> copy_fun =
|
|
|
|
f->NewFunctionFromSharedFunctionInfo(copy, isolate->native_context());
|
|
|
|
|
|
|
|
Handle<Object> copy_result =
|
|
|
|
Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked();
|
|
|
|
|
|
|
|
CHECK_EQ(10.0f, copy_result->Number());
|
|
|
|
|
|
|
|
delete cache;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-24 08:37:03 +00:00
|
|
|
static bool toplevel_test_code_event_found = false;
|
|
|
|
|
|
|
|
|
|
|
|
static void SerializerCodeEventListener(const v8::JitCodeEvent* event) {
|
|
|
|
if (event->type == v8::JitCodeEvent::CODE_ADDED &&
|
|
|
|
memcmp(event->name.str, "Script:~test", 12) == 0) {
|
|
|
|
toplevel_test_code_event_found = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-23 07:16:32 +00:00
|
|
|
TEST(SerializeToplevelIsolates) {
|
|
|
|
FLAG_serialize_toplevel = true;
|
|
|
|
|
|
|
|
const char* source = "function f() { return 'abc'; }; f() + 'def'";
|
|
|
|
v8::ScriptCompiler::CachedData* cache;
|
|
|
|
|
2014-07-24 12:11:30 +00:00
|
|
|
v8::Isolate* isolate1 = v8::Isolate::New();
|
2014-07-23 07:16:32 +00:00
|
|
|
{
|
2014-07-24 12:11:30 +00:00
|
|
|
v8::Isolate::Scope iscope(isolate1);
|
|
|
|
v8::HandleScope scope(isolate1);
|
|
|
|
v8::Local<v8::Context> context = v8::Context::New(isolate1);
|
2014-07-23 07:16:32 +00:00
|
|
|
v8::Context::Scope context_scope(context);
|
|
|
|
|
|
|
|
v8::Local<v8::String> source_str = v8_str(source);
|
|
|
|
v8::ScriptOrigin origin(v8_str("test"));
|
|
|
|
v8::ScriptCompiler::Source source(source_str, origin);
|
|
|
|
v8::Local<v8::UnboundScript> script = v8::ScriptCompiler::CompileUnbound(
|
2014-07-24 12:11:30 +00:00
|
|
|
isolate1, &source, v8::ScriptCompiler::kProduceCodeCache);
|
2014-07-23 07:16:32 +00:00
|
|
|
const v8::ScriptCompiler::CachedData* data = source.GetCachedData();
|
2014-10-17 09:54:48 +00:00
|
|
|
CHECK(data);
|
2014-07-23 07:16:32 +00:00
|
|
|
// Persist cached data.
|
|
|
|
uint8_t* buffer = NewArray<uint8_t>(data->length);
|
|
|
|
MemCopy(buffer, data->data, data->length);
|
|
|
|
cache = new v8::ScriptCompiler::CachedData(
|
|
|
|
buffer, data->length, v8::ScriptCompiler::CachedData::BufferOwned);
|
|
|
|
|
|
|
|
v8::Local<v8::Value> result = script->BindToCurrentContext()->Run();
|
2014-11-24 10:30:39 +00:00
|
|
|
CHECK(result->ToString(isolate1)->Equals(v8_str("abcdef")));
|
2014-07-23 07:16:32 +00:00
|
|
|
}
|
2014-07-24 12:11:30 +00:00
|
|
|
isolate1->Dispose();
|
2014-07-23 07:16:32 +00:00
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
v8::Isolate* isolate2 = v8::Isolate::New();
|
2014-10-24 08:37:03 +00:00
|
|
|
isolate2->SetJitCodeEventHandler(v8::kJitCodeEventDefault,
|
|
|
|
SerializerCodeEventListener);
|
|
|
|
toplevel_test_code_event_found = false;
|
2014-07-23 07:16:32 +00:00
|
|
|
{
|
2014-07-24 12:11:30 +00:00
|
|
|
v8::Isolate::Scope iscope(isolate2);
|
|
|
|
v8::HandleScope scope(isolate2);
|
|
|
|
v8::Local<v8::Context> context = v8::Context::New(isolate2);
|
2014-07-23 07:16:32 +00:00
|
|
|
v8::Context::Scope context_scope(context);
|
|
|
|
|
|
|
|
v8::Local<v8::String> source_str = v8_str(source);
|
|
|
|
v8::ScriptOrigin origin(v8_str("test"));
|
|
|
|
v8::ScriptCompiler::Source source(source_str, origin, cache);
|
|
|
|
v8::Local<v8::UnboundScript> script;
|
|
|
|
{
|
2014-07-24 12:11:30 +00:00
|
|
|
DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2));
|
2014-07-23 07:16:32 +00:00
|
|
|
script = v8::ScriptCompiler::CompileUnbound(
|
2014-07-24 12:11:30 +00:00
|
|
|
isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache);
|
2014-07-23 07:16:32 +00:00
|
|
|
}
|
2014-11-17 12:16:27 +00:00
|
|
|
CHECK(!cache->rejected);
|
2014-07-23 07:16:32 +00:00
|
|
|
v8::Local<v8::Value> result = script->BindToCurrentContext()->Run();
|
2014-11-24 10:30:39 +00:00
|
|
|
CHECK(result->ToString(isolate2)->Equals(v8_str("abcdef")));
|
2014-07-23 07:16:32 +00:00
|
|
|
}
|
2014-10-24 08:37:03 +00:00
|
|
|
DCHECK(toplevel_test_code_event_found);
|
2014-07-24 12:11:30 +00:00
|
|
|
isolate2->Dispose();
|
2014-07-23 07:16:32 +00:00
|
|
|
}
|
2014-10-17 09:54:48 +00:00
|
|
|
|
|
|
|
|
2014-11-12 11:34:09 +00:00
|
|
|
TEST(SerializeWithHarmonyScoping) {
|
2014-10-17 09:54:48 +00:00
|
|
|
FLAG_serialize_toplevel = true;
|
|
|
|
FLAG_harmony_scoping = true;
|
|
|
|
|
|
|
|
const char* source1 = "'use strict'; let x = 'X'";
|
|
|
|
const char* source2 = "'use strict'; let y = 'Y'";
|
|
|
|
const char* source3 = "'use strict'; x + y";
|
|
|
|
|
|
|
|
v8::ScriptCompiler::CachedData* cache;
|
|
|
|
|
|
|
|
v8::Isolate* isolate1 = v8::Isolate::New();
|
|
|
|
{
|
|
|
|
v8::Isolate::Scope iscope(isolate1);
|
|
|
|
v8::HandleScope scope(isolate1);
|
|
|
|
v8::Local<v8::Context> context = v8::Context::New(isolate1);
|
|
|
|
v8::Context::Scope context_scope(context);
|
|
|
|
|
|
|
|
CompileRun(source1);
|
|
|
|
CompileRun(source2);
|
|
|
|
|
|
|
|
v8::Local<v8::String> source_str = v8_str(source3);
|
|
|
|
v8::ScriptOrigin origin(v8_str("test"));
|
|
|
|
v8::ScriptCompiler::Source source(source_str, origin);
|
|
|
|
v8::Local<v8::UnboundScript> script = v8::ScriptCompiler::CompileUnbound(
|
|
|
|
isolate1, &source, v8::ScriptCompiler::kProduceCodeCache);
|
|
|
|
const v8::ScriptCompiler::CachedData* data = source.GetCachedData();
|
2014-10-17 10:22:47 +00:00
|
|
|
CHECK(data);
|
2014-10-17 09:54:48 +00:00
|
|
|
// Persist cached data.
|
|
|
|
uint8_t* buffer = NewArray<uint8_t>(data->length);
|
|
|
|
MemCopy(buffer, data->data, data->length);
|
|
|
|
cache = new v8::ScriptCompiler::CachedData(
|
|
|
|
buffer, data->length, v8::ScriptCompiler::CachedData::BufferOwned);
|
|
|
|
|
|
|
|
v8::Local<v8::Value> result = script->BindToCurrentContext()->Run();
|
2014-11-24 10:30:39 +00:00
|
|
|
CHECK(result->ToString(isolate1)->Equals(v8_str("XY")));
|
2014-10-17 09:54:48 +00:00
|
|
|
}
|
|
|
|
isolate1->Dispose();
|
|
|
|
|
|
|
|
v8::Isolate* isolate2 = v8::Isolate::New();
|
|
|
|
{
|
|
|
|
v8::Isolate::Scope iscope(isolate2);
|
|
|
|
v8::HandleScope scope(isolate2);
|
|
|
|
v8::Local<v8::Context> context = v8::Context::New(isolate2);
|
|
|
|
v8::Context::Scope context_scope(context);
|
|
|
|
|
|
|
|
// Reverse order of prior running scripts.
|
|
|
|
CompileRun(source2);
|
|
|
|
CompileRun(source1);
|
|
|
|
|
|
|
|
v8::Local<v8::String> source_str = v8_str(source3);
|
|
|
|
v8::ScriptOrigin origin(v8_str("test"));
|
|
|
|
v8::ScriptCompiler::Source source(source_str, origin, cache);
|
|
|
|
v8::Local<v8::UnboundScript> script;
|
|
|
|
{
|
|
|
|
DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2));
|
|
|
|
script = v8::ScriptCompiler::CompileUnbound(
|
|
|
|
isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache);
|
|
|
|
}
|
|
|
|
v8::Local<v8::Value> result = script->BindToCurrentContext()->Run();
|
2014-11-24 10:30:39 +00:00
|
|
|
CHECK(result->ToString(isolate2)->Equals(v8_str("XY")));
|
2014-10-17 09:54:48 +00:00
|
|
|
}
|
|
|
|
isolate2->Dispose();
|
|
|
|
}
|