summaryrefslogtreecommitdiff
path: root/deps
diff options
context:
space:
mode:
authorAli Ijaz Sheikh <ofrobots@google.com>2015-08-31 17:10:53 -0700
committerRod Vagg <rod@vagg.org>2015-09-06 21:38:06 +1000
commit4e3d767f4c33ac8e6d05f6fedc0dd65814c0b6e3 (patch)
treecf36eab49a0bed7830b364b87b9dc98fc1eaafc4 /deps
parent439c1dde15c80b5eac4a02701ed30dfec324d3cf (diff)
downloadnode-new-4e3d767f4c33ac8e6d05f6fedc0dd65814c0b6e3.tar.gz
deps: upgrade V8 to 4.5.103.30
Pick up https://github.com/v8/v8-git-mirror/commit/f9a0a1636a4623a5522c33674e110b346d085340 Commit log at https://chromium.googlesource.com/v8/v8.git/+log/branch-heads/4.5 PR-URL: https://github.com/nodejs/node/pull/2632 Reviewed-By: targos - Michaƫl Zasso <mic.besace@gmail.com> Reviewed-By: rvagg - Rod Vagg <rod@vagg.org>
Diffstat (limited to 'deps')
-rw-r--r--deps/v8/BUILD.gn4
-rw-r--r--deps/v8/include/v8-version.h2
-rw-r--r--deps/v8/include/v8.h19
-rw-r--r--deps/v8/samples/hello-world.cc1
-rw-r--r--deps/v8/samples/process.cc1
-rw-r--r--deps/v8/samples/shell.cc1
-rw-r--r--deps/v8/src/api.cc13
-rw-r--r--deps/v8/src/arm/assembler-arm.cc3
-rw-r--r--deps/v8/src/arm64/assembler-arm64.cc3
-rw-r--r--deps/v8/src/base/cpu.h3
-rw-r--r--deps/v8/src/d8.cc14
-rw-r--r--deps/v8/src/d8.gyp2
-rw-r--r--deps/v8/src/heap/heap.cc13
-rw-r--r--deps/v8/src/heap/heap.h4
-rw-r--r--deps/v8/src/heap/memory-reducer.cc25
-rw-r--r--deps/v8/src/preparser.h14
-rw-r--r--deps/v8/src/startup-data-util.cc110
-rw-r--r--deps/v8/src/startup-data-util.h40
-rw-r--r--deps/v8/test/cctest/cctest.cc8
-rw-r--r--deps/v8/test/cctest/cctest.gyp2
-rw-r--r--deps/v8/test/cctest/test-parsing.cc61
-rw-r--r--deps/v8/test/unittests/run-all-unittests.cc8
-rw-r--r--deps/v8/test/unittests/unittests.gyp2
-rw-r--r--deps/v8/tools/gyp/v8.gyp2
-rw-r--r--deps/v8/tools/parser-shell.cc2
25 files changed, 210 insertions, 147 deletions
diff --git a/deps/v8/BUILD.gn b/deps/v8/BUILD.gn
index 059ee07086..3eb7fc73eb 100644
--- a/deps/v8/BUILD.gn
+++ b/deps/v8/BUILD.gn
@@ -1077,6 +1077,8 @@ source_set("v8_base") {
"src/splay-tree.h",
"src/splay-tree-inl.h",
"src/snapshot/snapshot.h",
+ "src/startup-data-util.h",
+ "src/startup-data-util.cc",
"src/string-builder.cc",
"src/string-builder.h",
"src/string-search.cc",
@@ -1678,8 +1680,6 @@ if ((current_toolchain == host_toolchain && v8_toolset_for_d8 == "host") ||
sources = [
"src/d8.cc",
"src/d8.h",
- "src/startup-data-util.h",
- "src/startup-data-util.cc",
]
configs -= [ "//build/config/compiler:chromium_code" ]
diff --git a/deps/v8/include/v8-version.h b/deps/v8/include/v8-version.h
index f6f62d736a..a2dc5b0db6 100644
--- a/deps/v8/include/v8-version.h
+++ b/deps/v8/include/v8-version.h
@@ -11,7 +11,7 @@
#define V8_MAJOR_VERSION 4
#define V8_MINOR_VERSION 5
#define V8_BUILD_NUMBER 103
-#define V8_PATCH_LEVEL 24
+#define V8_PATCH_LEVEL 30
// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h
index 6e1db3a581..c651b7cd09 100644
--- a/deps/v8/include/v8.h
+++ b/deps/v8/include/v8.h
@@ -6248,6 +6248,25 @@ class V8_EXPORT V8 {
static bool InitializeICU(const char* icu_data_file = NULL);
/**
+ * Initialize the external startup data. The embedder only needs to
+ * invoke this method when external startup data was enabled in a build.
+ *
+ * If V8 was compiled with the startup data in an external file, then
+ * V8 needs to be given those external files during startup. There are
+ * three ways to do this:
+ * - InitializeExternalStartupData(const char*)
+ * This will look in the given directory for files "natives_blob.bin"
+ * and "snapshot_blob.bin" - which is what the default build calls them.
+ * - InitializeExternalStartupData(const char*, const char*)
+ * As above, but will directly use the two given file names.
+ * - Call SetNativesDataBlob, SetNativesDataBlob.
+ * This will read the blobs from the given data structures and will
+ * not perform any file IO.
+ */
+ static void InitializeExternalStartupData(const char* directory_path);
+ static void InitializeExternalStartupData(const char* natives_blob,
+ const char* snapshot_blob);
+ /**
* Sets the v8::Platform to use. This should be invoked before V8 is
* initialized.
*/
diff --git a/deps/v8/samples/hello-world.cc b/deps/v8/samples/hello-world.cc
index 8be5a31fca..3b952d816b 100644
--- a/deps/v8/samples/hello-world.cc
+++ b/deps/v8/samples/hello-world.cc
@@ -25,6 +25,7 @@ class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
int main(int argc, char* argv[]) {
// Initialize V8.
V8::InitializeICU();
+ V8::InitializeExternalStartupData(argv[0]);
Platform* platform = platform::CreateDefaultPlatform();
V8::InitializePlatform(platform);
V8::Initialize();
diff --git a/deps/v8/samples/process.cc b/deps/v8/samples/process.cc
index a62950a76a..6f7a47f1b0 100644
--- a/deps/v8/samples/process.cc
+++ b/deps/v8/samples/process.cc
@@ -686,6 +686,7 @@ void PrintMap(map<string, string>* m) {
int main(int argc, char* argv[]) {
v8::V8::InitializeICU();
+ v8::V8::InitializeExternalStartupData(argv[0]);
v8::Platform* platform = v8::platform::CreateDefaultPlatform();
v8::V8::InitializePlatform(platform);
v8::V8::Initialize();
diff --git a/deps/v8/samples/shell.cc b/deps/v8/samples/shell.cc
index 3a743d6c13..bd621c5465 100644
--- a/deps/v8/samples/shell.cc
+++ b/deps/v8/samples/shell.cc
@@ -75,6 +75,7 @@ class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
int main(int argc, char* argv[]) {
v8::V8::InitializeICU();
+ v8::V8::InitializeExternalStartupData(argv[0]);
v8::Platform* platform = v8::platform::CreateDefaultPlatform();
v8::V8::InitializePlatform(platform);
v8::V8::Initialize();
diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc
index 5ff8ccbae5..593aea641b 100644
--- a/deps/v8/src/api.cc
+++ b/deps/v8/src/api.cc
@@ -49,6 +49,7 @@
#include "src/simulator.h"
#include "src/snapshot/natives.h"
#include "src/snapshot/snapshot.h"
+#include "src/startup-data-util.h"
#include "src/unicode-inl.h"
#include "src/v8threads.h"
#include "src/version.h"
@@ -5398,11 +5399,23 @@ HeapObjectStatistics::HeapObjectStatistics()
object_count_(0),
object_size_(0) {}
+
bool v8::V8::InitializeICU(const char* icu_data_file) {
return i::InitializeICU(icu_data_file);
}
+void v8::V8::InitializeExternalStartupData(const char* directory_path) {
+ i::InitializeExternalStartupData(directory_path);
+}
+
+
+void v8::V8::InitializeExternalStartupData(const char* natives_blob,
+ const char* snapshot_blob) {
+ i::InitializeExternalStartupData(natives_blob, snapshot_blob);
+}
+
+
const char* v8::V8::GetVersion() {
return i::Version::GetVersion();
}
diff --git a/deps/v8/src/arm/assembler-arm.cc b/deps/v8/src/arm/assembler-arm.cc
index 96bdf79fac..481a3b5ced 100644
--- a/deps/v8/src/arm/assembler-arm.cc
+++ b/deps/v8/src/arm/assembler-arm.cc
@@ -128,7 +128,8 @@ void CpuFeatures::ProbeImpl(bool cross_compile) {
if (FLAG_enable_32dregs && cpu.has_vfp3_d32()) supported_ |= 1u << VFP32DREGS;
if (cpu.implementer() == base::CPU::NVIDIA &&
- cpu.variant() == base::CPU::NVIDIA_DENVER) {
+ cpu.variant() == base::CPU::NVIDIA_DENVER &&
+ cpu.part() <= base::CPU::NVIDIA_DENVER_V10) {
supported_ |= 1u << COHERENT_CACHE;
}
#endif
diff --git a/deps/v8/src/arm64/assembler-arm64.cc b/deps/v8/src/arm64/assembler-arm64.cc
index 5445fe1a1b..f27d3b97b0 100644
--- a/deps/v8/src/arm64/assembler-arm64.cc
+++ b/deps/v8/src/arm64/assembler-arm64.cc
@@ -53,7 +53,8 @@ void CpuFeatures::ProbeImpl(bool cross_compile) {
// Probe for runtime features
base::CPU cpu;
if (cpu.implementer() == base::CPU::NVIDIA &&
- cpu.variant() == base::CPU::NVIDIA_DENVER) {
+ cpu.variant() == base::CPU::NVIDIA_DENVER &&
+ cpu.part() <= base::CPU::NVIDIA_DENVER_V10) {
supported_ |= 1u << COHERENT_CACHE;
}
}
diff --git a/deps/v8/src/base/cpu.h b/deps/v8/src/base/cpu.h
index f6c5a8506a..1dc0a91f65 100644
--- a/deps/v8/src/base/cpu.h
+++ b/deps/v8/src/base/cpu.h
@@ -59,6 +59,9 @@ class CPU final {
static const int ARM_CORTEX_A12 = 0xc0c;
static const int ARM_CORTEX_A15 = 0xc0f;
+ // Denver-specific part code
+ static const int NVIDIA_DENVER_V10 = 0x002;
+
// PPC-specific part codes
enum {
PPC_POWER5,
diff --git a/deps/v8/src/d8.cc b/deps/v8/src/d8.cc
index 7db6f3ed9e..45bf33167f 100644
--- a/deps/v8/src/d8.cc
+++ b/deps/v8/src/d8.cc
@@ -50,10 +50,6 @@
#include "src/v8.h"
#endif // !V8_SHARED
-#ifdef V8_USE_EXTERNAL_STARTUP_DATA
-#include "src/startup-data-util.h"
-#endif // V8_USE_EXTERNAL_STARTUP_DATA
-
#if !defined(_WIN32) && !defined(_WIN64)
#include <unistd.h> // NOLINT
#else
@@ -2316,10 +2312,12 @@ int Shell::Main(int argc, char* argv[]) {
g_platform = v8::platform::CreateDefaultPlatform();
v8::V8::InitializePlatform(g_platform);
v8::V8::Initialize();
-#ifdef V8_USE_EXTERNAL_STARTUP_DATA
- v8::StartupDataHandler startup_data(argv[0], options.natives_blob,
- options.snapshot_blob);
-#endif
+ if (options.natives_blob || options.snapshot_blob) {
+ v8::V8::InitializeExternalStartupData(options.natives_blob,
+ options.snapshot_blob);
+ } else {
+ v8::V8::InitializeExternalStartupData(argv[0]);
+ }
SetFlagsFromString("--trace-hydrogen-file=hydrogen.cfg");
SetFlagsFromString("--trace-turbo-cfg-file=turbo.cfg");
SetFlagsFromString("--redirect-code-traces-to=code.asm");
diff --git a/deps/v8/src/d8.gyp b/deps/v8/src/d8.gyp
index 548459a790..e92a321990 100644
--- a/deps/v8/src/d8.gyp
+++ b/deps/v8/src/d8.gyp
@@ -50,8 +50,6 @@
'sources': [
'd8.h',
'd8.cc',
- 'startup-data-util.h',
- 'startup-data-util.cc'
],
'conditions': [
[ 'want_separate_host_toolset==1', {
diff --git a/deps/v8/src/heap/heap.cc b/deps/v8/src/heap/heap.cc
index 47717c162b..3d95373001 100644
--- a/deps/v8/src/heap/heap.cc
+++ b/deps/v8/src/heap/heap.cc
@@ -4867,19 +4867,6 @@ void Heap::ReduceNewSpaceSize() {
}
-void Heap::FinalizeIncrementalMarkingIfComplete(const char* comment) {
- if (FLAG_overapproximate_weak_closure &&
- (incremental_marking()->IsReadyToOverApproximateWeakClosure() ||
- (!incremental_marking()->weak_closure_was_overapproximated() &&
- mark_compact_collector_.marking_deque()->IsEmpty()))) {
- OverApproximateWeakClosure(comment);
- } else if (incremental_marking()->IsComplete() ||
- (mark_compact_collector_.marking_deque()->IsEmpty())) {
- CollectAllGarbage(kNoGCFlags, comment);
- }
-}
-
-
bool Heap::TryFinalizeIdleIncrementalMarking(
double idle_time_in_ms, size_t size_of_objects,
size_t final_incremental_mark_compact_speed_in_bytes_per_ms) {
diff --git a/deps/v8/src/heap/heap.h b/deps/v8/src/heap/heap.h
index 38166439ea..4c9e3ad144 100644
--- a/deps/v8/src/heap/heap.h
+++ b/deps/v8/src/heap/heap.h
@@ -852,8 +852,6 @@ class Heap {
intptr_t step_size_in_bytes, double deadline_in_ms,
IncrementalMarking::StepActions step_actions);
- void FinalizeIncrementalMarkingIfComplete(const char* comment);
-
inline void increment_scan_on_scavenge_pages() {
scan_on_scavenge_pages_++;
if (FLAG_gc_verbose) {
@@ -1644,8 +1642,6 @@ class Heap {
bool HasHighFragmentation();
bool HasHighFragmentation(intptr_t used, intptr_t committed);
- bool ShouldOptimizeForMemoryUsage() { return optimize_for_memory_usage_; }
-
protected:
// Methods made available to tests.
diff --git a/deps/v8/src/heap/memory-reducer.cc b/deps/v8/src/heap/memory-reducer.cc
index e226f09a04..df827bae29 100644
--- a/deps/v8/src/heap/memory-reducer.cc
+++ b/deps/v8/src/heap/memory-reducer.cc
@@ -44,35 +44,12 @@ void MemoryReducer::NotifyTimer(const Event& event) {
if (state_.action == kRun) {
DCHECK(heap()->incremental_marking()->IsStopped());
DCHECK(FLAG_incremental_marking);
+ heap()->StartIdleIncrementalMarking();
if (FLAG_trace_gc_verbose) {
PrintIsolate(heap()->isolate(), "Memory reducer: started GC #%d\n",
state_.started_gcs);
}
- if (heap()->ShouldOptimizeForMemoryUsage()) {
- // Do full GC if memory usage has higher priority than latency. This is
- // important for background tabs that do not send idle notifications.
- heap()->CollectAllGarbage(Heap::kReduceMemoryFootprintMask,
- "memory reducer");
- } else {
- heap()->StartIdleIncrementalMarking();
- }
} else if (state_.action == kWait) {
- if (!heap()->incremental_marking()->IsStopped() &&
- heap()->ShouldOptimizeForMemoryUsage()) {
- // Make progress with pending incremental marking if memory usage has
- // higher priority than latency. This is important for background tabs
- // that do not send idle notifications.
- const int kIncrementalMarkingDelayMs = 500;
- double deadline = heap()->MonotonicallyIncreasingTimeInMs() +
- kIncrementalMarkingDelayMs;
- heap()->AdvanceIncrementalMarking(
- 0, deadline, i::IncrementalMarking::StepActions(
- i::IncrementalMarking::NO_GC_VIA_STACK_GUARD,
- i::IncrementalMarking::FORCE_MARKING,
- i::IncrementalMarking::FORCE_COMPLETION));
- heap()->FinalizeIncrementalMarkingIfComplete(
- "Memory reducer: finalize incremental marking");
- }
// Re-schedule the timer.
ScheduleTimer(state_.next_gc_start_ms - event.time_ms);
if (FLAG_trace_gc_verbose) {
diff --git a/deps/v8/src/preparser.h b/deps/v8/src/preparser.h
index 9ebc132d92..d9ef1ea31e 100644
--- a/deps/v8/src/preparser.h
+++ b/deps/v8/src/preparser.h
@@ -2939,6 +2939,7 @@ ParserBase<Traits>::ParseConditionalExpression(bool accept_IN,
ExpressionT expression =
this->ParseBinaryExpression(4, accept_IN, classifier, CHECK_OK);
if (peek() != Token::CONDITIONAL) return expression;
+ ArrowFormalParametersUnexpectedToken(classifier);
BindingPatternUnexpectedToken(classifier);
Consume(Token::CONDITIONAL);
// In parsing the first assignment expression in conditional
@@ -2964,6 +2965,7 @@ ParserBase<Traits>::ParseBinaryExpression(int prec, bool accept_IN,
// prec1 >= 4
while (Precedence(peek(), accept_IN) == prec1) {
BindingPatternUnexpectedToken(classifier);
+ ArrowFormalParametersUnexpectedToken(classifier);
Token::Value op = Next();
Scanner::Location op_location = scanner()->location();
int pos = position();
@@ -3026,6 +3028,7 @@ ParserBase<Traits>::ParseUnaryExpression(ExpressionClassifier* classifier,
Token::Value op = peek();
if (Token::IsUnaryOp(op)) {
BindingPatternUnexpectedToken(classifier);
+ ArrowFormalParametersUnexpectedToken(classifier);
op = Next();
int pos = position();
@@ -3048,6 +3051,7 @@ ParserBase<Traits>::ParseUnaryExpression(ExpressionClassifier* classifier,
return this->BuildUnaryExpression(expression, op, pos, factory());
} else if (Token::IsCountOp(op)) {
BindingPatternUnexpectedToken(classifier);
+ ArrowFormalParametersUnexpectedToken(classifier);
op = Next();
Scanner::Location lhs_location = scanner()->peek_location();
ExpressionT expression = this->ParseUnaryExpression(classifier, CHECK_OK);
@@ -3080,6 +3084,7 @@ ParserBase<Traits>::ParsePostfixExpression(ExpressionClassifier* classifier,
if (!scanner()->HasAnyLineTerminatorBeforeNext() &&
Token::IsCountOp(peek())) {
BindingPatternUnexpectedToken(classifier);
+ ArrowFormalParametersUnexpectedToken(classifier);
expression = this->CheckAndRewriteReferenceExpression(
expression, lhs_location, MessageTemplate::kInvalidLhsInPostfixOp,
@@ -3111,6 +3116,7 @@ ParserBase<Traits>::ParseLeftHandSideExpression(
switch (peek()) {
case Token::LBRACK: {
BindingPatternUnexpectedToken(classifier);
+ ArrowFormalParametersUnexpectedToken(classifier);
Consume(Token::LBRACK);
int pos = position();
ExpressionT index = ParseExpression(true, classifier, CHECK_OK);
@@ -3121,6 +3127,7 @@ ParserBase<Traits>::ParseLeftHandSideExpression(
case Token::LPAREN: {
BindingPatternUnexpectedToken(classifier);
+ ArrowFormalParametersUnexpectedToken(classifier);
if (is_strong(language_mode()) && this->IsIdentifier(result) &&
this->IsEval(this->AsIdentifier(result))) {
@@ -3172,6 +3179,7 @@ ParserBase<Traits>::ParseLeftHandSideExpression(
case Token::PERIOD: {
BindingPatternUnexpectedToken(classifier);
+ ArrowFormalParametersUnexpectedToken(classifier);
Consume(Token::PERIOD);
int pos = position();
IdentifierT name = ParseIdentifierName(CHECK_OK);
@@ -3184,6 +3192,7 @@ ParserBase<Traits>::ParseLeftHandSideExpression(
case Token::TEMPLATE_SPAN:
case Token::TEMPLATE_TAIL: {
BindingPatternUnexpectedToken(classifier);
+ ArrowFormalParametersUnexpectedToken(classifier);
result = ParseTemplateLiteral(result, position(), classifier, CHECK_OK);
break;
}
@@ -3221,6 +3230,7 @@ ParserBase<Traits>::ParseMemberWithNewPrefixesExpression(
if (peek() == Token::NEW) {
BindingPatternUnexpectedToken(classifier);
+ ArrowFormalParametersUnexpectedToken(classifier);
Consume(Token::NEW);
int new_pos = position();
ExpressionT result = this->EmptyExpression();
@@ -3274,6 +3284,7 @@ ParserBase<Traits>::ParseMemberExpression(ExpressionClassifier* classifier,
ExpressionT result = this->EmptyExpression();
if (peek() == Token::FUNCTION) {
BindingPatternUnexpectedToken(classifier);
+ ArrowFormalParametersUnexpectedToken(classifier);
Consume(Token::FUNCTION);
int function_token_position = position();
@@ -3523,6 +3534,7 @@ ParserBase<Traits>::ParseMemberExpressionContinuation(
switch (peek()) {
case Token::LBRACK: {
BindingPatternUnexpectedToken(classifier);
+ ArrowFormalParametersUnexpectedToken(classifier);
Consume(Token::LBRACK);
int pos = position();
@@ -3536,6 +3548,7 @@ ParserBase<Traits>::ParseMemberExpressionContinuation(
}
case Token::PERIOD: {
BindingPatternUnexpectedToken(classifier);
+ ArrowFormalParametersUnexpectedToken(classifier);
Consume(Token::PERIOD);
int pos = position();
@@ -3550,6 +3563,7 @@ ParserBase<Traits>::ParseMemberExpressionContinuation(
case Token::TEMPLATE_SPAN:
case Token::TEMPLATE_TAIL: {
BindingPatternUnexpectedToken(classifier);
+ ArrowFormalParametersUnexpectedToken(classifier);
int pos;
if (scanner()->current_token() == Token::IDENTIFIER) {
pos = position();
diff --git a/deps/v8/src/startup-data-util.cc b/deps/v8/src/startup-data-util.cc
index 1b2f7ed7e9..92c4b5b3e9 100644
--- a/deps/v8/src/startup-data-util.cc
+++ b/deps/v8/src/startup-data-util.cc
@@ -8,66 +8,41 @@
#include <string.h>
#include "src/base/logging.h"
+#include "src/base/platform/platform.h"
namespace v8 {
+namespace internal {
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
-StartupDataHandler::StartupDataHandler(const char* exec_path,
- const char* natives_blob,
- const char* snapshot_blob) {
- // If we have (at least one) explicitly given blob, use those.
- // If not, use the default blob locations next to the d8 binary.
- if (natives_blob || snapshot_blob) {
- LoadFromFiles(natives_blob, snapshot_blob);
- } else {
- char* natives;
- char* snapshot;
- LoadFromFiles(RelativePath(&natives, exec_path, "natives_blob.bin"),
- RelativePath(&snapshot, exec_path, "snapshot_blob.bin"));
+namespace {
- free(natives);
- free(snapshot);
- }
-}
+v8::StartupData g_natives;
+v8::StartupData g_snapshot;
-StartupDataHandler::~StartupDataHandler() {
- delete[] natives_.data;
- delete[] snapshot_.data;
+void ClearStartupData(v8::StartupData* data) {
+ data->data = nullptr;
+ data->raw_size = 0;
}
-char* StartupDataHandler::RelativePath(char** buffer, const char* exec_path,
- const char* name) {
- DCHECK(exec_path);
- const char* last_slash = strrchr(exec_path, '/');
- if (last_slash) {
- int after_slash = static_cast<int>(last_slash - exec_path + 1);
- int name_length = static_cast<int>(strlen(name));
- *buffer = reinterpret_cast<char*>(calloc(after_slash + name_length + 1, 1));
- strncpy(*buffer, exec_path, after_slash);
- strncat(*buffer, name, name_length);
- } else {
- *buffer = strdup(name);
- }
- return *buffer;
+void DeleteStartupData(v8::StartupData* data) {
+ delete[] data->data;
+ ClearStartupData(data);
}
-void StartupDataHandler::LoadFromFiles(const char* natives_blob,
- const char* snapshot_blob) {
- Load(natives_blob, &natives_, v8::V8::SetNativesDataBlob);
- Load(snapshot_blob, &snapshot_, v8::V8::SetSnapshotDataBlob);
+void FreeStartupData() {
+ DeleteStartupData(&g_natives);
+ DeleteStartupData(&g_snapshot);
}
-void StartupDataHandler::Load(const char* blob_file,
- v8::StartupData* startup_data,
- void (*setter_fn)(v8::StartupData*)) {
- startup_data->data = NULL;
- startup_data->raw_size = 0;
+void Load(const char* blob_file, v8::StartupData* startup_data,
+ void (*setter_fn)(v8::StartupData*)) {
+ ClearStartupData(startup_data);
if (!blob_file) return;
@@ -86,6 +61,57 @@ void StartupDataHandler::Load(const char* blob_file,
if (startup_data->raw_size == read_size) (*setter_fn)(startup_data);
}
+
+void LoadFromFiles(const char* natives_blob, const char* snapshot_blob) {
+ Load(natives_blob, &g_natives, v8::V8::SetNativesDataBlob);
+ Load(snapshot_blob, &g_snapshot, v8::V8::SetSnapshotDataBlob);
+
+ atexit(&FreeStartupData);
+}
+
+
+char* RelativePath(char** buffer, const char* exec_path, const char* name) {
+ DCHECK(exec_path);
+ int path_separator = static_cast<int>(strlen(exec_path)) - 1;
+ while (path_separator >= 0 &&
+ !base::OS::isDirectorySeparator(exec_path[path_separator])) {
+ path_separator--;
+ }
+ if (path_separator >= 0) {
+ int name_length = static_cast<int>(strlen(name));
+ *buffer =
+ reinterpret_cast<char*>(calloc(path_separator + name_length + 2, 1));
+ *buffer[0] = '\0';
+ strncat(*buffer, exec_path, path_separator + 1);
+ strncat(*buffer, name, name_length);
+ } else {
+ *buffer = strdup(name);
+ }
+ return *buffer;
+}
+
+} // namespace
#endif // V8_USE_EXTERNAL_STARTUP_DATA
+
+void InitializeExternalStartupData(const char* directory_path) {
+#ifdef V8_USE_EXTERNAL_STARTUP_DATA
+ char* natives;
+ char* snapshot;
+ LoadFromFiles(RelativePath(&natives, directory_path, "natives_blob.bin"),
+ RelativePath(&snapshot, directory_path, "snapshot_blob.bin"));
+ free(natives);
+ free(snapshot);
+#endif // V8_USE_EXTERNAL_STARTUP_DATA
+}
+
+
+void InitializeExternalStartupData(const char* natives_blob,
+ const char* snapshot_blob) {
+#ifdef V8_USE_EXTERNAL_STARTUP_DATA
+ LoadFromFiles(natives_blob, snapshot_blob);
+#endif // V8_USE_EXTERNAL_STARTUP_DATA
+}
+
+} // namespace internal
} // namespace v8
diff --git a/deps/v8/src/startup-data-util.h b/deps/v8/src/startup-data-util.h
index 79b4171343..7cb51e362a 100644
--- a/deps/v8/src/startup-data-util.h
+++ b/deps/v8/src/startup-data-util.h
@@ -9,43 +9,21 @@
#include "include/v8.h"
namespace v8 {
+namespace internal {
-#ifdef V8_USE_EXTERNAL_STARTUP_DATA
-// Helper class to load the startup data files from disk.
+// Helper functions to load external startup data.
//
// This is meant as a convenience for stand-alone binaries like d8, cctest,
// unittest. A V8 embedder would likely either handle startup data on their
// own or just disable the feature if they don't want to handle it at all,
-// while tools like cctest need to work in either configuration. Hence this is
-// not meant for inclusion in the general v8 library.
-class StartupDataHandler {
- public:
- // Load startup data, and call the v8::V8::Set*DataBlob API functions.
- //
- // natives_blob and snapshot_blob will be loaded realitive to exec_path,
- // which would usually be the equivalent of argv[0].
- StartupDataHandler(const char* exec_path, const char* natives_blob,
- const char* snapshot_blob);
- ~StartupDataHandler();
-
- private:
- static char* RelativePath(char** buffer, const char* exec_path,
- const char* name);
-
- void LoadFromFiles(const char* natives_blob, const char* snapshot_blob);
-
- void Load(const char* blob_file, v8::StartupData* startup_data,
- void (*setter_fn)(v8::StartupData*));
-
- v8::StartupData natives_;
- v8::StartupData snapshot_;
-
- // Disallow copy & assign.
- StartupDataHandler(const StartupDataHandler& other);
- void operator=(const StartupDataHandler& other);
-};
-#endif // V8_USE_EXTERNAL_STARTUP_DATA
+// while tools like cctest need to work in either configuration.
+void InitializeExternalStartupData(const char* directory_path);
+
+void InitializeExternalStartupData(const char* natives_blob,
+ const char* snapshot_blob);
+
+} // namespace internal
} // namespace v8
#endif // V8_STARTUP_DATA_UTIL_H_
diff --git a/deps/v8/test/cctest/cctest.cc b/deps/v8/test/cctest/cctest.cc
index b5771ff655..851096ddce 100644
--- a/deps/v8/test/cctest/cctest.cc
+++ b/deps/v8/test/cctest/cctest.cc
@@ -34,10 +34,6 @@
#include "test/cctest/profiler-extension.h"
#include "test/cctest/trace-extension.h"
-#ifdef V8_USE_EXTERNAL_STARTUP_DATA
-#include "src/startup-data-util.h"
-#endif // V8_USE_EXTERNAL_STARTUP_DATA
-
#if V8_OS_WIN
#include <windows.h> // NOLINT
#if V8_CC_MSVC
@@ -173,9 +169,7 @@ int main(int argc, char* argv[]) {
v8::V8::InitializePlatform(platform);
v8::internal::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
v8::V8::Initialize();
-#ifdef V8_USE_EXTERNAL_STARTUP_DATA
- v8::StartupDataHandler startup_data(argv[0], NULL, NULL);
-#endif
+ v8::V8::InitializeExternalStartupData(argv[0]);
CcTestArrayBufferAllocator array_buffer_allocator;
CcTest::set_array_buffer_allocator(&array_buffer_allocator);
diff --git a/deps/v8/test/cctest/cctest.gyp b/deps/v8/test/cctest/cctest.gyp
index bcbbe7b226..8f0c58d38e 100644
--- a/deps/v8/test/cctest/cctest.gyp
+++ b/deps/v8/test/cctest/cctest.gyp
@@ -163,8 +163,6 @@
'test-weakmaps.cc',
'test-weaksets.cc',
'trace-extension.cc',
- '../../src/startup-data-util.h',
- '../../src/startup-data-util.cc'
],
'conditions': [
['v8_target_arch=="ia32"', {
diff --git a/deps/v8/test/cctest/test-parsing.cc b/deps/v8/test/cctest/test-parsing.cc
index cbb79b16da..cfb43911aa 100644
--- a/deps/v8/test/cctest/test-parsing.cc
+++ b/deps/v8/test/cctest/test-parsing.cc
@@ -3516,6 +3516,67 @@ TEST(UseConstLegacyCount) {
}
+TEST(ErrorsArrowFormalParameters) {
+ const char* context_data[][2] = {
+ { "()", "=>{}" },
+ { "()", "=>{};" },
+ { "var x = ()", "=>{}" },
+ { "var x = ()", "=>{};" },
+
+ { "a", "=>{}" },
+ { "a", "=>{};" },
+ { "var x = a", "=>{}" },
+ { "var x = a", "=>{};" },
+
+ { "(a)", "=>{}" },
+ { "(a)", "=>{};" },
+ { "var x = (a)", "=>{}" },
+ { "var x = (a)", "=>{};" },
+
+ { "(...a)", "=>{}" },
+ { "(...a)", "=>{};" },
+ { "var x = (...a)", "=>{}" },
+ { "var x = (...a)", "=>{};" },
+
+ { "(a,b)", "=>{}" },
+ { "(a,b)", "=>{};" },
+ { "var x = (a,b)", "=>{}" },
+ { "var x = (a,b)", "=>{};" },
+
+ { "(a,...b)", "=>{}" },
+ { "(a,...b)", "=>{};" },
+ { "var x = (a,...b)", "=>{}" },
+ { "var x = (a,...b)", "=>{};" },
+
+ { nullptr, nullptr }
+ };
+ const char* assignment_expression_suffix_data[] = {
+ "?c:d=>{}",
+ "=c=>{}",
+ "()",
+ "(c)",
+ "[1]",
+ "[c]",
+ ".c",
+ "-c",
+ "+c",
+ "c++",
+ "`c`",
+ "`${c}`",
+ "`template-head${c}`",
+ "`${c}template-tail`",
+ "`template-head${c}template-tail`",
+ "`${c}template-tail`",
+ nullptr
+ };
+
+ static const ParserFlag always_flags[] = { kAllowHarmonyArrowFunctions,
+ kAllowHarmonyRestParameters };
+ RunParserSyncTest(context_data, assignment_expression_suffix_data, kError,
+ NULL, 0, always_flags, arraysize(always_flags));
+}
+
+
TEST(ErrorsArrowFunctions) {
// Tests that parser and preparser generate the same kind of errors
// on invalid arrow function syntax.
diff --git a/deps/v8/test/unittests/run-all-unittests.cc b/deps/v8/test/unittests/run-all-unittests.cc
index 08d265624b..0b7f65e08e 100644
--- a/deps/v8/test/unittests/run-all-unittests.cc
+++ b/deps/v8/test/unittests/run-all-unittests.cc
@@ -7,10 +7,6 @@
#include "src/base/compiler-specific.h"
#include "testing/gmock/include/gmock/gmock.h"
-#ifdef V8_USE_EXTERNAL_STARTUP_DATA
-#include "src/startup-data-util.h"
-#endif // V8_USE_EXTERNAL_STARTUP_DATA
-
namespace {
class DefaultPlatformEnvironment final : public ::testing::Environment {
@@ -45,8 +41,6 @@ int main(int argc, char** argv) {
testing::InitGoogleMock(&argc, argv);
testing::AddGlobalTestEnvironment(new DefaultPlatformEnvironment);
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
-#ifdef V8_USE_EXTERNAL_STARTUP_DATA
- v8::StartupDataHandler startup_data(argv[0], NULL, NULL);
-#endif
+ v8::V8::InitializeExternalStartupData(argv[0]);
return RUN_ALL_TESTS();
}
diff --git a/deps/v8/test/unittests/unittests.gyp b/deps/v8/test/unittests/unittests.gyp
index 00658b3fda..9698fb760d 100644
--- a/deps/v8/test/unittests/unittests.gyp
+++ b/deps/v8/test/unittests/unittests.gyp
@@ -94,8 +94,6 @@
'run-all-unittests.cc',
'test-utils.h',
'test-utils.cc',
- '../../src/startup-data-util.h',
- '../../src/startup-data-util.cc'
],
'conditions': [
['v8_target_arch=="arm"', {
diff --git a/deps/v8/tools/gyp/v8.gyp b/deps/v8/tools/gyp/v8.gyp
index a77acfa109..400991c43f 100644
--- a/deps/v8/tools/gyp/v8.gyp
+++ b/deps/v8/tools/gyp/v8.gyp
@@ -910,6 +910,8 @@
'../../src/snapshot/snapshot-source-sink.h',
'../../src/splay-tree.h',
'../../src/splay-tree-inl.h',
+ '../../src/startup-data-util.cc',
+ '../../src/startup-data-util.h',
'../../src/string-builder.cc',
'../../src/string-builder.h',
'../../src/string-search.cc',
diff --git a/deps/v8/tools/parser-shell.cc b/deps/v8/tools/parser-shell.cc
index ead7777022..da874595de 100644
--- a/deps/v8/tools/parser-shell.cc
+++ b/deps/v8/tools/parser-shell.cc
@@ -146,6 +146,8 @@ int main(int argc, char* argv[]) {
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;