Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: upgrade v8 to 4.1.0.21 #952

Merged
merged 3 commits into from
Feb 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions deps/v8/src/flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ uint32_t FlagList::Hash() {
for (size_t i = 0; i < num_flags; ++i) {
Flag* current = &flags[i];
if (!current->IsDefault()) {
modified_args_as_string << i;
modified_args_as_string << *current;
}
}
Expand Down
4 changes: 2 additions & 2 deletions deps/v8/src/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ function SetUpGenerators() {
%AddNamedProperty(GeneratorObjectPrototype, symbolIterator,
GeneratorObjectIterator, DONT_ENUM | DONT_DELETE | READ_ONLY);
%AddNamedProperty(GeneratorObjectPrototype, "constructor",
GeneratorFunctionPrototype, DONT_ENUM | DONT_DELETE | READ_ONLY);
GeneratorFunctionPrototype, DONT_ENUM | READ_ONLY);
%AddNamedProperty(GeneratorObjectPrototype,
symbolToStringTag, "Generator", DONT_ENUM | READ_ONLY);
%InternalSetPrototype(GeneratorFunctionPrototype, $Function.prototype);
%AddNamedProperty(GeneratorFunctionPrototype,
symbolToStringTag, "GeneratorFunction", DONT_ENUM | READ_ONLY);
%SetCode(GeneratorFunctionPrototype, GeneratorFunctionPrototypeConstructor);
%AddNamedProperty(GeneratorFunctionPrototype, "constructor",
GeneratorFunction, DONT_ENUM | DONT_DELETE | READ_ONLY);
GeneratorFunction, DONT_ENUM | READ_ONLY);
%InternalSetPrototype(GeneratorFunction, $Function);
%SetCode(GeneratorFunction, GeneratorFunctionConstructor);
}
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ namespace internal {

// Determine whether double field unboxing feature is enabled.
#if (V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64)
#define V8_DOUBLE_FIELDS_UNBOXING 1
#define V8_DOUBLE_FIELDS_UNBOXING 0
#else
#define V8_DOUBLE_FIELDS_UNBOXING 0
#endif
Expand Down
5 changes: 5 additions & 0 deletions deps/v8/src/heap/mark-compact.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3052,6 +3052,11 @@ void MarkCompactCollector::EvacuatePages() {
// have an emergency page and the space still has room for that.
if (space->HasEmergencyMemory() && space->CanExpand()) {
EvacuateLiveObjectsFromPage(p);
// Unlink the page from the list of pages here. We must not iterate
// over that page later (e.g. when scan on scavenge pages are
// processed). The page itself will be freed later and is still
// reachable from the evacuation candidates list.
p->Unlink();
} else {
// Without room for expansion evacuation is not guaranteed to succeed.
// Pessimistically abandon unevacuated pages.
Expand Down
7 changes: 6 additions & 1 deletion deps/v8/src/heap/spaces.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,12 @@ void PagedSpace::ReleasePage(Page* page) {
allocation_info_.set_limit(NULL);
}

page->Unlink();
// If page is still in a list, unlink it from that list.
if (page->next_chunk() != NULL) {
DCHECK(page->prev_chunk() != NULL);
page->Unlink();
}

if (page->IsFlagSet(MemoryChunk::CONTAINS_ONLY_DATA)) {
heap()->isolate()->memory_allocator()->Free(page);
} else {
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/runtime/runtime-regexp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ void CompiledReplacement::Apply(ReplacementStringBuilder* builder,
}


void FindOneByteStringIndices(Vector<const uint8_t> subject, char pattern,
void FindOneByteStringIndices(Vector<const uint8_t> subject, uint8_t pattern,
ZoneList<int>* indices, unsigned int limit,
Zone* zone) {
DCHECK(limit > 0);
Expand Down
65 changes: 56 additions & 9 deletions deps/v8/src/serialize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2054,6 +2054,10 @@ void Serializer::Pad() {
for (unsigned i = 0; i < sizeof(int32_t) - 1; i++) {
sink_->Put(kNop, "Padding");
}
// Pad up to pointer size for checksum.
while (!IsAligned(sink_->Position(), kPointerAlignment)) {
sink_->Put(kNop, "Padding");
}
}


Expand Down Expand Up @@ -2394,6 +2398,41 @@ Vector<const byte> SnapshotData::Payload() const {
}


class Checksum {
public:
explicit Checksum(Vector<const byte> payload) {
// Fletcher's checksum. Modified to reduce 64-bit sums to 32-bit.
uintptr_t a = 1;
uintptr_t b = 0;
const uintptr_t* cur = reinterpret_cast<const uintptr_t*>(payload.start());
DCHECK(IsAligned(payload.length(), kIntptrSize));
const uintptr_t* end = cur + payload.length() / kIntptrSize;
while (cur < end) {
// Unsigned overflow expected and intended.
a += *cur++;
b += a;
}
#if V8_HOST_ARCH_64_BIT
a ^= a >> 32;
b ^= b >> 32;
#endif // V8_HOST_ARCH_64_BIT
a_ = static_cast<uint32_t>(a);
b_ = static_cast<uint32_t>(b);
}

bool Check(uint32_t a, uint32_t b) const { return a == a_ && b == b_; }

uint32_t a() const { return a_; }
uint32_t b() const { return b_; }

private:
uint32_t a_;
uint32_t b_;

DISALLOW_COPY_AND_ASSIGN(Checksum);
};


SerializedCodeData::SerializedCodeData(const List<byte>& payload,
const CodeSerializer& cs) {
DisallowHeapAllocation no_gc;
Expand All @@ -2412,12 +2451,20 @@ SerializedCodeData::SerializedCodeData(const List<byte>& payload,
AllocateData(size);

// Set header values.
SetHeaderValue(kCheckSumOffset, CheckSum(cs.source()));
SetHeaderValue(kVersionHashOffset, Version::Hash());
SetHeaderValue(kSourceHashOffset, SourceHash(cs.source()));
SetHeaderValue(kCpuFeaturesOffset,
static_cast<uint32_t>(CpuFeatures::SupportedFeatures()));
SetHeaderValue(kFlagHashOffset, FlagList::Hash());
SetHeaderValue(kNumInternalizedStringsOffset, cs.num_internalized_strings());
SetHeaderValue(kReservationsOffset, reservations.length());
SetHeaderValue(kNumCodeStubKeysOffset, num_stub_keys);
SetHeaderValue(kPayloadLengthOffset, payload.length());

Checksum checksum(payload.ToConstVector());
SetHeaderValue(kChecksum1Offset, checksum.a());
SetHeaderValue(kChecksum2Offset, checksum.b());

// Copy reservation chunk sizes.
CopyBytes(data_ + kHeaderSize, reinterpret_cast<byte*>(reservations.begin()),
reservation_size);
Expand All @@ -2432,14 +2479,14 @@ SerializedCodeData::SerializedCodeData(const List<byte>& payload,
}


bool SerializedCodeData::IsSane(String* source) {
return GetHeaderValue(kCheckSumOffset) == CheckSum(source) &&
Payload().length() >= SharedFunctionInfo::kSize;
}


int SerializedCodeData::CheckSum(String* string) {
return Version::Hash() ^ string->length();
bool SerializedCodeData::IsSane(String* source) const {
return GetHeaderValue(kVersionHashOffset) == Version::Hash() &&
GetHeaderValue(kSourceHashOffset) == SourceHash(source) &&
GetHeaderValue(kCpuFeaturesOffset) ==
static_cast<uint32_t>(CpuFeatures::SupportedFeatures()) &&
GetHeaderValue(kFlagHashOffset) == FlagList::Hash() &&
Checksum(Payload()).Check(GetHeaderValue(kChecksum1Offset),
GetHeaderValue(kChecksum2Offset));
}


Expand Down
44 changes: 28 additions & 16 deletions deps/v8/src/serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -481,12 +481,14 @@ class SerializedData {
class IsLastChunkBits : public BitField<bool, 31, 1> {};

protected:
void SetHeaderValue(int offset, int value) {
reinterpret_cast<int*>(data_)[offset] = value;
void SetHeaderValue(int offset, uint32_t value) {
memcpy(reinterpret_cast<uint32_t*>(data_) + offset, &value, sizeof(value));
}

int GetHeaderValue(int offset) const {
return reinterpret_cast<const int*>(data_)[offset];
uint32_t GetHeaderValue(int offset) const {
uint32_t value;
memcpy(&value, reinterpret_cast<int*>(data_) + offset, sizeof(value));
return value;
}

void AllocateData(int size);
Expand Down Expand Up @@ -920,22 +922,32 @@ class SerializedCodeData : public SerializedData {
explicit SerializedCodeData(ScriptData* data)
: SerializedData(const_cast<byte*>(data->data()), data->length()) {}

bool IsSane(String* source);
bool IsSane(String* source) const;

int CheckSum(String* source);
static uint32_t SourceHash(String* source) { return source->length(); }

// The data header consists of int-sized entries:
// [0] version hash
// [1] number of internalized strings
// [2] number of code stub keys
// [3] number of reservation size entries
// [4] payload length
static const int kCheckSumOffset = 0;
static const int kNumInternalizedStringsOffset = 1;
static const int kReservationsOffset = 2;
static const int kNumCodeStubKeysOffset = 3;
static const int kPayloadLengthOffset = 4;
static const int kHeaderSize = (kPayloadLengthOffset + 1) * kIntSize;
// [1] source hash
// [2] cpu features
// [3] flag hash
// [4] number of internalized strings
// [5] number of code stub keys
// [6] number of reservation size entries
// [7] payload length
// [8] checksum 1
// [9] checksum 2
static const int kVersionHashOffset = 0;
static const int kSourceHashOffset = 1;
static const int kCpuFeaturesOffset = 2;
static const int kFlagHashOffset = 3;
static const int kNumInternalizedStringsOffset = 4;
static const int kReservationsOffset = 5;
static const int kNumCodeStubKeysOffset = 6;
static const int kPayloadLengthOffset = 7;
static const int kChecksum1Offset = 8;
static const int kChecksum2Offset = 9;
static const int kHeaderSize = (kChecksum2Offset + 1) * kIntSize;
};
} } // namespace v8::internal

Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/version.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#define MAJOR_VERSION 4
#define MINOR_VERSION 1
#define BUILD_NUMBER 0
#define PATCH_LEVEL 14
#define PATCH_LEVEL 21
// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
#define IS_CANDIDATE_VERSION 0
Expand Down
5 changes: 3 additions & 2 deletions deps/v8/src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ class Version {
static int GetBuild() { return build_; }
static int GetPatch() { return patch_; }
static bool IsCandidate() { return candidate_; }
static int Hash() {
return static_cast<int>(base::hash_combine(major_, minor_, build_, patch_));
static uint32_t Hash() {
return static_cast<uint32_t>(
base::hash_combine(major_, minor_, build_, patch_));
}

// Calculate the V8 version string.
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/test/cctest/test-api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24540,7 +24540,7 @@ TEST(StreamingUtf8ScriptWithMultipleMultibyteCharactersSomeSplit2) {


void TestInvalidCacheData(v8::ScriptCompiler::CompileOptions option) {
const char* garbage = "garbage garbage garbage garbage.";
const char* garbage = "garbage garbage garbage garbage garbage garbage";
const uint8_t* data = reinterpret_cast<const uint8_t*>(garbage);
int length = 16;
v8::ScriptCompiler::CachedData* cached_data =
Expand Down
50 changes: 50 additions & 0 deletions deps/v8/test/cctest/test-serialize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,56 @@ TEST(SerializeToplevelIsolates) {
}


TEST(SerializeToplevelFlagChange) {
FLAG_serialize_toplevel = true;

const char* source = "function f() { return 'abc'; }; f() + 'def'";
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);

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(
isolate1, &source, v8::ScriptCompiler::kProduceCodeCache);
const v8::ScriptCompiler::CachedData* data = source.GetCachedData();
CHECK(data);
// 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();
CHECK(result->ToString(isolate1)->Equals(v8_str("abcdef")));
}
isolate1->Dispose();

v8::Isolate* isolate2 = v8::Isolate::New();
FLAG_allow_natives_syntax = true; // Flag change should trigger cache reject.
{
v8::Isolate::Scope iscope(isolate2);
v8::HandleScope scope(isolate2);
v8::Local<v8::Context> context = v8::Context::New(isolate2);
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::ScriptCompiler::CompileUnbound(isolate2, &source,
v8::ScriptCompiler::kConsumeCodeCache);
CHECK(cache->rejected);
}
isolate2->Dispose();
}


TEST(SerializeWithHarmonyScoping) {
FLAG_serialize_toplevel = true;
FLAG_harmony_scoping = true;
Expand Down
15 changes: 15 additions & 0 deletions deps/v8/test/mjsunit/es6/regress/regress-3902.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

function* g() {}
assertTrue(Object.getOwnPropertyDescriptor(g.__proto__, "constructor").configurable);
assertTrue(Object.getOwnPropertyDescriptor(g.prototype.__proto__, "constructor").configurable);

function FakeGeneratorFunctionConstructor() {}
Object.defineProperty(g.__proto__, "constructor", {value: FakeGeneratorFunctionConstructor});
assertSame(g.__proto__.constructor, FakeGeneratorFunctionConstructor);

function FakeGeneratorObjectConstructor() {}
Object.defineProperty(g.prototype.__proto__, "constructor", {value: FakeGeneratorObjectConstructor});
assertSame(g.prototype.__proto__.constructor, FakeGeneratorObjectConstructor);
41 changes: 41 additions & 0 deletions deps/v8/test/mjsunit/regress/regress-430201.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright 2010 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * 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.

// Flags: --allow-natives-syntax --expose-gc

var array_1 = [];

%SetFlags("--stress-compaction");
for (var a = 0; a < 10000; a++) { array_1[a * 100] = 0; }

gc();
gc();

var array_2 = [];
for (var i = 0; i < 321361; i++) {
array_2[i] = String.fromCharCode(i)[0];
}