Skip to content

Commit

Permalink
deps: patch V8 to 7.0.276.38
Browse files Browse the repository at this point in the history
Refs: v8/v8@7.0.276.36...7.0.276.38

PR-URL: #24271
Reviewed-By: Ali Ijaz Sheikh <[email protected]>
Reviewed-By: Matheus Marchini <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
targos authored and BridgeAR committed Nov 13, 2018
1 parent 2b48c71 commit 9cefbba
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 82 deletions.
2 changes: 1 addition & 1 deletion deps/v8/include/v8-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define V8_MAJOR_VERSION 7
#define V8_MINOR_VERSION 0
#define V8_BUILD_NUMBER 276
#define V8_PATCH_LEVEL 36
#define V8_PATCH_LEVEL 38

// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
Expand Down
58 changes: 32 additions & 26 deletions deps/v8/src/wasm/module-compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2329,12 +2329,6 @@ void AsyncCompileJob::CancelPendingForegroundTask() {
pending_foreground_task_ = nullptr;
}

template <typename Step, typename... Args>
void AsyncCompileJob::DoSync(Args&&... args) {
NextStep<Step>(std::forward<Args>(args)...);
StartForegroundTask();
}

void AsyncCompileJob::StartBackgroundTask() {
auto task = base::make_unique<CompileTask>(this, false);

Expand All @@ -2347,6 +2341,18 @@ void AsyncCompileJob::StartBackgroundTask() {
}
}

template <typename Step, typename... Args>
void AsyncCompileJob::DoSync(Args&&... args) {
NextStep<Step>(std::forward<Args>(args)...);
StartForegroundTask();
}

template <typename Step, typename... Args>
void AsyncCompileJob::DoImmediately(Args&&... args) {
NextStep<Step>(std::forward<Args>(args)...);
ExecuteForegroundTaskImmediately();
}

template <typename Step, typename... Args>
void AsyncCompileJob::DoAsync(Args&&... args) {
NextStep<Step>(std::forward<Args>(args)...);
Expand Down Expand Up @@ -2686,11 +2692,10 @@ bool AsyncStreamingProcessor::ProcessCodeSectionHeader(size_t functions_count,
FinishAsyncCompileJobWithError(decoder_.FinishDecoding(false));
return false;
}
job_->NextStep<AsyncCompileJob::PrepareAndStartCompile>(
decoder_.shared_module(), false);
// Execute the PrepareAndStartCompile step immediately and not in a separate
// task.
job_->ExecuteForegroundTaskImmediately();
job_->DoImmediately<AsyncCompileJob::PrepareAndStartCompile>(
decoder_.shared_module(), false);

job_->native_module_->compilation_state()->SetNumberOfFunctionsToCompile(
functions_count);
Expand Down Expand Up @@ -2734,25 +2739,26 @@ void AsyncStreamingProcessor::OnFinishedChunk() {
// Finish the processing of the stream.
void AsyncStreamingProcessor::OnFinishedStream(OwnedVector<uint8_t> bytes) {
TRACE_STREAMING("Finish stream...\n");
if (job_->native_module_) {
job_->wire_bytes_ = ModuleWireBytes(bytes.as_vector());
job_->native_module_->set_wire_bytes(std::move(bytes));
}
ModuleResult result = decoder_.FinishDecoding(false);
DCHECK(result.ok());
if (job_->DecrementAndCheckFinisherCount()) {
if (job_->native_module_ == nullptr) {
// We are processing a WebAssembly module without code section. We need to
// prepare compilation first before we can finish it.
// {PrepareAndStartCompile} will call {FinishCompile} by itself if there
// is no code section.
job_->DoSync<AsyncCompileJob::PrepareAndStartCompile>(result.val, true);
} else {
HandleScope scope(job_->isolate_);
SaveContext saved_context(job_->isolate_);
job_->isolate_->set_context(*job_->native_context_);
job_->FinishCompile();
}
bool needs_finish = job_->DecrementAndCheckFinisherCount();
if (job_->native_module_ == nullptr) {
// We are processing a WebAssembly module without code section. We need to
// prepare compilation first before we can finish it.
// {PrepareAndStartCompile} will call {FinishCompile} by itself if there
// is no code section.
DCHECK(needs_finish);
needs_finish = false;
job_->DoImmediately<AsyncCompileJob::PrepareAndStartCompile>(result.val,
true);
}
job_->wire_bytes_ = ModuleWireBytes(bytes.as_vector());
job_->native_module_->set_wire_bytes(std::move(bytes));
if (needs_finish) {
HandleScope scope(job_->isolate_);
SaveContext saved_context(job_->isolate_);
job_->isolate_->set_context(*job_->native_context_);
job_->FinishCompile();
}
}

Expand Down
4 changes: 4 additions & 0 deletions deps/v8/src/wasm/module-compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ class AsyncCompileJob {
template <typename Step, typename... Args>
void DoSync(Args&&... args);

// Switches to the compilation step {Step} and immediately executes that step.
template <typename Step, typename... Args>
void DoImmediately(Args&&... args);

// Switches to the compilation step {Step} and starts a background task to
// execute it.
template <typename Step, typename... Args>
Expand Down
15 changes: 15 additions & 0 deletions deps/v8/test/mjsunit/regress/regress-897366.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2018 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.

// Flags: --gc-interval=100

let xs = [];
for (let i = 0; i < 205; ++i) {
xs.push(i);
}
xs.sort((a, b) => {
xs.shift();
xs[xs.length] = -246;
return a - b;
});
7 changes: 7 additions & 0 deletions deps/v8/test/mjsunit/wasm/async-compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,10 @@ assertPromiseResult(async function badFunctionInTheMiddle() {
let buffer = builder.toBuffer();
await assertCompileError(buffer);
}());

assertPromiseResult(async function importWithoutCode() {
// Regression test for https://crbug.com/898310.
let builder = new WasmModuleBuilder();
builder.addImport('m', 'q', kSig_i_i);
await builder.asyncInstantiate({'m': {'q': i => i}});
}());
97 changes: 42 additions & 55 deletions deps/v8/third_party/v8/builtins/array-sort.tq
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ module array {
assert(i >= 0);
assert(i == stack_size - 2 || i == stack_size - 3);

const elements: HeapObject = ReloadElements(sortState);
let elements: HeapObject = ReloadElements(sortState);
const Load: LoadFn = GetLoadFn(sortState);

const pending_runs: FixedArray =
Expand Down Expand Up @@ -859,6 +859,7 @@ module array {
const k: Smi = CallGallopRight(
context, sortState, Load, key_right, base_a, length_a, 0, False)
otherwise Bailout;
elements = ReloadElements(sortState);
assert(k >= 0);

base_a = base_a + k;
Expand All @@ -874,6 +875,7 @@ module array {
length_b = CallGallopLeft(
context, sortState, Load, key_left, base_b, length_b, length_b - 1,
False) otherwise Bailout;
elements = ReloadElements(sortState);
assert(length_b >= 0);
if (length_b == 0) return kSuccess;

Expand All @@ -893,6 +895,12 @@ module array {
}
}

macro LoadElementsOrTempArray(
useTempArray: Boolean, sortState: FixedArray): HeapObject {
return useTempArray == True ? GetTempArray(sortState) :
ReloadElements(sortState);
}

// Locates the proper position of key in a sorted array; if the array contains
// an element equal to key, return the position immediately to the left of
// the leftmost equal element. (GallopRight does the same except returns the
Expand All @@ -916,25 +924,17 @@ module array {
assert(length > 0 && base >= 0);
assert(0 <= hint && hint < length);

// We cannot leave a pointer to elements on the stack (see comment at
// ReloadElements). For this reason we pass a flag whether to reload
// and which array to use.
let elements: HeapObject = useTempArray == True ? GetTempArray(sortState) :
ReloadElements(sortState);

let last_ofs: Smi = 0;
let offset: Smi = 1;

try {
const base_hint_element: Object =
CallLoad(context, sortState, Load, elements, base + hint)
const base_hint_element: Object = CallLoad(
context, sortState, Load,
LoadElementsOrTempArray(useTempArray, sortState), base + hint)
otherwise Bailout;
let order: Number =
CallCompareFn(context, sortState, base_hint_element, key)
otherwise Bailout;
if (useTempArray == False) {
elements = ReloadElements(sortState);
}

if (order < 0) {
// a[base + hint] < key: gallop right, until
Expand All @@ -943,14 +943,13 @@ module array {
// a[base + length - 1] is highest.
let max_ofs: Smi = length - hint;
while (offset < max_ofs) {
const offset_element: Object =
CallLoad(context, sortState, Load, elements, base + hint + offset)
const offset_element: Object = CallLoad(
context, sortState, Load,
LoadElementsOrTempArray(useTempArray, sortState),
base + hint + offset)
otherwise Bailout;
order = CallCompareFn(context, sortState, offset_element, key)
otherwise Bailout;
if (useTempArray == False) {
elements = ReloadElements(sortState);
}

// a[base + hint + offset] >= key? Break.
if (order >= 0) break;
Expand All @@ -975,14 +974,13 @@ module array {
// a[base + hint] is lowest.
let max_ofs: Smi = hint + 1;
while (offset < max_ofs) {
const offset_element: Object =
CallLoad(context, sortState, Load, elements, base + hint - offset)
const offset_element: Object = CallLoad(
context, sortState, Load,
LoadElementsOrTempArray(useTempArray, sortState),
base + hint - offset)
otherwise Bailout;
order = CallCompareFn(context, sortState, offset_element, key)
otherwise Bailout;
if (useTempArray == False) {
elements = ReloadElements(sortState);
}

if (order < 0) break;

Expand Down Expand Up @@ -1011,14 +1009,12 @@ module array {
while (last_ofs < offset) {
const m: Smi = last_ofs + ((offset - last_ofs) >>> 1);

const base_m_element: Object =
CallLoad(context, sortState, Load, elements, base + m)
const base_m_element: Object = CallLoad(
context, sortState, Load,
LoadElementsOrTempArray(useTempArray, sortState), base + m)
otherwise Bailout;
order = CallCompareFn(context, sortState, base_m_element, key)
otherwise Bailout;
if (useTempArray == False) {
elements = ReloadElements(sortState);
}

if (order < 0) {
last_ofs = m + 1; // a[base + m] < key.
Expand Down Expand Up @@ -1051,25 +1047,17 @@ module array {
assert(length > 0 && base >= 0);
assert(0 <= hint && hint < length);

// We cannot leave a pointer to elements on the stack (see comment at
// ReloadElements). For this reason we pass a flag whether to reload
// and which array to use.
let elements: HeapObject = useTempArray == True ? GetTempArray(sortState) :
ReloadElements(sortState);

let last_ofs: Smi = 0;
let offset: Smi = 1;

try {
const base_hint_element: Object =
CallLoad(context, sortState, Load, elements, base + hint)
const base_hint_element: Object = CallLoad(
context, sortState, Load,
LoadElementsOrTempArray(useTempArray, sortState), base + hint)
otherwise Bailout;
let order: Number =
CallCompareFn(context, sortState, key, base_hint_element)
otherwise Bailout;
if (useTempArray == False) {
elements = ReloadElements(sortState);
}

if (order < 0) {
// key < a[base + hint]: gallop left, until
Expand All @@ -1078,14 +1066,13 @@ module array {
// a[base + hint] is lowest.
let max_ofs: Smi = hint + 1;
while (offset < max_ofs) {
const offset_element: Object =
CallLoad(context, sortState, Load, elements, base + hint - offset)
const offset_element: Object = CallLoad(
context, sortState, Load,
LoadElementsOrTempArray(useTempArray, sortState),
base + hint - offset)
otherwise Bailout;
order = CallCompareFn(context, sortState, key, offset_element)
otherwise Bailout;
if (useTempArray == False) {
elements = ReloadElements(sortState);
}

if (order >= 0) break;

Expand All @@ -1109,14 +1096,13 @@ module array {
// a[base + length - 1] is highest.
let max_ofs: Smi = length - hint;
while (offset < max_ofs) {
const offset_element: Object =
CallLoad(context, sortState, Load, elements, base + hint + offset)
const offset_element: Object = CallLoad(
context, sortState, Load,
LoadElementsOrTempArray(useTempArray, sortState),
base + hint + offset)
otherwise Bailout;
order = CallCompareFn(context, sortState, key, offset_element)
otherwise Bailout;
if (useTempArray == False) {
elements = ReloadElements(sortState);
}

// a[base + hint + ofs] <= key.
if (order < 0) break;
Expand Down Expand Up @@ -1144,14 +1130,12 @@ module array {
while (last_ofs < offset) {
const m: Smi = last_ofs + ((offset - last_ofs) >>> 1);

const base_m_element: Object =
CallLoad(context, sortState, Load, elements, base + m)
const base_m_element: Object = CallLoad(
context, sortState, Load,
LoadElementsOrTempArray(useTempArray, sortState), base + m)
otherwise Bailout;
order = CallCompareFn(context, sortState, key, base_m_element)
otherwise Bailout;
if (useTempArray == False) {
elements = ReloadElements(sortState);
}

if (order < 0) {
offset = m; // key < a[base + m].
Expand Down Expand Up @@ -1288,6 +1272,7 @@ module array {
nof_wins_a = CallGallopRight(
context, sortState, Load<TempArrayElements>, key_right,
cursor_temp, length_a, 0, True) otherwise Bailout;
elements = ReloadElements(sortState);
assert(nof_wins_a >= 0);

if (nof_wins_a > 0) {
Expand All @@ -1313,6 +1298,7 @@ module array {
context, sortState, LoadF, temp_array[cursor_temp], cursor_b,
length_b, 0, False)
otherwise Bailout;
elements = ReloadElements(sortState);
assert(nof_wins_b >= 0);
if (nof_wins_b > 0) {
CallCopyWithinSortArray(
Expand Down Expand Up @@ -1461,6 +1447,7 @@ module array {
context, sortState, LoadF, temp_array[cursor_temp], baseA,
length_a, length_a - 1, False)
otherwise Bailout;
elements = ReloadElements(sortState);
assert(k >= 0);
nof_wins_a = length_a - k;

Expand All @@ -1487,6 +1474,7 @@ module array {
k = CallGallopLeft(
context, sortState, Load<TempArrayElements>, key, 0, length_b,
length_b - 1, True) otherwise Bailout;
elements = ReloadElements(sortState);
assert(k >= 0);
nof_wins_b = length_b - k;

Expand Down Expand Up @@ -1743,8 +1731,7 @@ module array {
// 2. Let obj be ? ToObject(this value).
const obj: JSReceiver = ToObject(context, receiver);

const sort_state: FixedArray =
AllocateZeroedFixedArray(kSortStateSize);
const sort_state: FixedArray = AllocateZeroedFixedArray(kSortStateSize);
FillFixedArrayWithSmiZero(sort_state, SmiTag(kSortStateSize));

sort_state[kReceiverIdx] = obj;
Expand Down

0 comments on commit 9cefbba

Please sign in to comment.