Upgrade V8 to version 4.9.385.28
https://chromium.googlesource.com/v8/v8/+/4.9.385.28
FPIIM-449
Change-Id: I4b2e74289d4bf3667f2f3dc8aa2e541f63e26eb4
diff --git a/tools/parser-shell.cc b/tools/parser-shell.cc
index 2cafc83..5d4b0cc 100644
--- a/tools/parser-shell.cc
+++ b/tools/parser-shell.cc
@@ -36,15 +36,25 @@
#include "include/libplatform/libplatform.h"
#include "src/api.h"
#include "src/compiler.h"
-#include "src/scanner-character-streams.h"
+#include "src/parsing/scanner-character-streams.h"
+#include "src/parsing/parser.h"
+#include "src/parsing/preparse-data-format.h"
+#include "src/parsing/preparse-data.h"
+#include "src/parsing/preparser.h"
#include "tools/shell-utils.h"
-#include "src/parser.h"
-#include "src/preparse-data-format.h"
-#include "src/preparse-data.h"
-#include "src/preparser.h"
using namespace v8::internal;
+class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
+ public:
+ virtual void* Allocate(size_t length) {
+ void* data = AllocateUninitialized(length);
+ return data == NULL ? data : memset(data, 0, length);
+ }
+ virtual void* AllocateUninitialized(size_t length) { return malloc(length); }
+ virtual void Free(void* data, size_t) { free(data); }
+};
+
class StringResource8 : public v8::String::ExternalOneByteStringResource {
public:
StringResource8(const char* data, int length)
@@ -59,43 +69,49 @@
std::pair<v8::base::TimeDelta, v8::base::TimeDelta> RunBaselineParser(
const char* fname, Encoding encoding, int repeat, v8::Isolate* isolate,
- v8::Handle<v8::Context> context) {
+ v8::Local<v8::Context> context) {
int length = 0;
const byte* source = ReadFileAndRepeat(fname, &length, repeat);
- v8::Handle<v8::String> source_handle;
+ v8::Local<v8::String> source_handle;
switch (encoding) {
case UTF8: {
source_handle = v8::String::NewFromUtf8(
- isolate, reinterpret_cast<const char*>(source));
+ isolate, reinterpret_cast<const char*>(source),
+ v8::NewStringType::kNormal).ToLocalChecked();
break;
}
case UTF16: {
- source_handle = v8::String::NewFromTwoByte(
- isolate, reinterpret_cast<const uint16_t*>(source),
- v8::String::kNormalString, length / 2);
+ source_handle =
+ v8::String::NewFromTwoByte(
+ isolate, reinterpret_cast<const uint16_t*>(source),
+ v8::NewStringType::kNormal, length / 2).ToLocalChecked();
break;
}
case LATIN1: {
StringResource8* string_resource =
new StringResource8(reinterpret_cast<const char*>(source), length);
- source_handle = v8::String::NewExternal(isolate, string_resource);
+ source_handle = v8::String::NewExternalOneByte(isolate, string_resource)
+ .ToLocalChecked();
break;
}
}
v8::base::TimeDelta parse_time1, parse_time2;
- Handle<Script> script = Isolate::Current()->factory()->NewScript(
- v8::Utils::OpenHandle(*source_handle));
+ Handle<Script> script =
+ reinterpret_cast<i::Isolate*>(isolate)->factory()->NewScript(
+ v8::Utils::OpenHandle(*source_handle));
i::ScriptData* cached_data_impl = NULL;
// First round of parsing (produce data to cache).
{
- CompilationInfoWithZone info(script);
- info.MarkAsGlobal();
- info.SetCachedData(&cached_data_impl,
- v8::ScriptCompiler::kProduceParserCache);
+ Zone zone;
+ ParseInfo info(&zone, script);
+ info.set_global();
+ info.set_cached_data(&cached_data_impl);
+ info.set_compile_options(v8::ScriptCompiler::kProduceParserCache);
v8::base::ElapsedTimer timer;
timer.Start();
// Allow lazy parsing; otherwise we won't produce cached data.
- bool success = Parser::Parse(&info, true);
+ info.set_allow_lazy_parsing();
+ bool success = Parser::ParseStatic(&info);
parse_time1 = timer.Elapsed();
if (!success) {
fprintf(stderr, "Parsing failed\n");
@@ -104,14 +120,16 @@
}
// Second round of parsing (consume cached data).
{
- CompilationInfoWithZone info(script);
- info.MarkAsGlobal();
- info.SetCachedData(&cached_data_impl,
- v8::ScriptCompiler::kConsumeParserCache);
+ Zone zone;
+ ParseInfo info(&zone, script);
+ info.set_global();
+ info.set_cached_data(&cached_data_impl);
+ info.set_compile_options(v8::ScriptCompiler::kConsumeParserCache);
v8::base::ElapsedTimer timer;
timer.Start();
// Allow lazy parsing; otherwise cached data won't help.
- bool success = Parser::Parse(&info, true);
+ info.set_allow_lazy_parsing();
+ bool success = Parser::ParseStatic(&info);
parse_time2 = timer.Elapsed();
if (!success) {
fprintf(stderr, "Parsing failed\n");
@@ -128,6 +146,8 @@
v8::Platform* platform = v8::platform::CreateDefaultPlatform();
v8::V8::InitializePlatform(platform);
v8::V8::Initialize();
+ v8::V8::InitializeExternalStartupData(argv[0]);
+
Encoding encoding = LATIN1;
std::vector<std::string> fnames;
std::string benchmark;
@@ -148,11 +168,14 @@
fnames.push_back(std::string(argv[i]));
}
}
- v8::Isolate* isolate = v8::Isolate::New();
+ ArrayBufferAllocator array_buffer_allocator;
+ v8::Isolate::CreateParams create_params;
+ create_params.array_buffer_allocator = &array_buffer_allocator;
+ v8::Isolate* isolate = v8::Isolate::New(create_params);
{
v8::Isolate::Scope isolate_scope(isolate);
v8::HandleScope handle_scope(isolate);
- v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate);
+ v8::Local<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate);
v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global);
DCHECK(!context.IsEmpty());
{