Skip to content

Commit d0e4d4e

Browse files
committed
deps: patch V8 to 6.4.388.42
PR-URL: #18578 Refs: v8/v8@6.4.388.41...6.4.388.42 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent af5632e commit d0e4d4e

File tree

5 files changed

+77
-6
lines changed

5 files changed

+77
-6
lines changed

deps/v8/include/v8-version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#define V8_MAJOR_VERSION 6
1212
#define V8_MINOR_VERSION 4
1313
#define V8_BUILD_NUMBER 388
14-
#define V8_PATCH_LEVEL 41
14+
#define V8_PATCH_LEVEL 42
1515

1616
// Use 1 for candidates and 0 otherwise.
1717
// (Boolean macro values are not supported by all preprocessors.)

deps/v8/src/frames.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,15 @@ JSFunction* JavaScriptFrame::function() const {
10131013
return JSFunction::cast(function_slot_object());
10141014
}
10151015

1016+
Object* JavaScriptFrame::unchecked_function() const {
1017+
// During deoptimization of an optimized function, we may have yet to
1018+
// materialize some closures on the stack. The arguments marker object
1019+
// marks this case.
1020+
DCHECK(function_slot_object()->IsJSFunction() ||
1021+
isolate()->heap()->arguments_marker() == function_slot_object());
1022+
return function_slot_object();
1023+
}
1024+
10161025
Object* JavaScriptFrame::receiver() const { return GetParameter(-1); }
10171026

10181027
Object* JavaScriptFrame::context() const {

deps/v8/src/frames.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,7 @@ class JavaScriptFrame : public StandardFrame {
684684

685685
// Accessors.
686686
virtual JSFunction* function() const;
687+
Object* unchecked_function() const;
687688
Object* receiver() const override;
688689
Object* context() const override;
689690
Script* script() const override;

deps/v8/src/profiler/sampling-heap-profiler.cc

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,21 @@ SamplingHeapProfiler::AllocationNode* SamplingHeapProfiler::AddStack() {
157157
std::vector<SharedFunctionInfo*> stack;
158158
JavaScriptFrameIterator it(isolate_);
159159
int frames_captured = 0;
160+
bool found_arguments_marker_frames = false;
160161
while (!it.done() && frames_captured < stack_depth_) {
161162
JavaScriptFrame* frame = it.frame();
162-
SharedFunctionInfo* shared = frame->function()->shared();
163-
stack.push_back(shared);
164-
165-
frames_captured++;
163+
// If we are materializing objects during deoptimization, inlined
164+
// closures may not yet be materialized, and this includes the
165+
// closure on the stack. Skip over any such frames (they'll be
166+
// in the top frames of the stack). The allocations made in this
167+
// sensitive moment belong to the formerly optimized frame anyway.
168+
if (frame->unchecked_function()->IsJSFunction()) {
169+
SharedFunctionInfo* shared = frame->function()->shared();
170+
stack.push_back(shared);
171+
frames_captured++;
172+
} else {
173+
found_arguments_marker_frames = true;
174+
}
166175
it.Advance();
167176
}
168177

@@ -209,6 +218,12 @@ SamplingHeapProfiler::AllocationNode* SamplingHeapProfiler::AddStack() {
209218
}
210219
node = node->FindOrAddChildNode(name, script_id, shared->start_position());
211220
}
221+
222+
if (found_arguments_marker_frames) {
223+
node =
224+
node->FindOrAddChildNode("(deopt)", v8::UnboundScript::kNoScriptId, 0);
225+
}
226+
212227
return node;
213228
}
214229

deps/v8/test/cctest/test-heap-profiler.cc

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3083,7 +3083,7 @@ TEST(SamplingHeapProfilerPretenuredInlineAllocations) {
30833083
// Suppress randomness to avoid flakiness in tests.
30843084
v8::internal::FLAG_sampling_heap_profiler_suppress_randomness = true;
30853085

3086-
// Grow new space unitl maximum capacity reached.
3086+
// Grow new space until maximum capacity reached.
30873087
while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) {
30883088
CcTest::heap()->new_space()->Grow();
30893089
}
@@ -3138,3 +3138,49 @@ TEST(SamplingHeapProfilerPretenuredInlineAllocations) {
31383138

31393139
CHECK_GE(count, 8000);
31403140
}
3141+
3142+
TEST(SamplingHeapProfilerSampleDuringDeopt) {
3143+
i::FLAG_allow_natives_syntax = true;
3144+
3145+
v8::HandleScope scope(v8::Isolate::GetCurrent());
3146+
LocalContext env;
3147+
v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
3148+
3149+
// Suppress randomness to avoid flakiness in tests.
3150+
v8::internal::FLAG_sampling_heap_profiler_suppress_randomness = true;
3151+
3152+
// Small sample interval to force each object to be sampled.
3153+
heap_profiler->StartSamplingHeapProfiler(i::kPointerSize);
3154+
3155+
// Lazy deopt from runtime call from inlined callback function.
3156+
const char* source =
3157+
"var b = "
3158+
" [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25];"
3159+
"(function f() {"
3160+
" var result = 0;"
3161+
" var lazyDeopt = function(deopt) {"
3162+
" var callback = function(v,i,o) {"
3163+
" result += i;"
3164+
" if (i == 13 && deopt) {"
3165+
" %DeoptimizeNow();"
3166+
" }"
3167+
" return v;"
3168+
" };"
3169+
" b.map(callback);"
3170+
" };"
3171+
" lazyDeopt();"
3172+
" lazyDeopt();"
3173+
" %OptimizeFunctionOnNextCall(lazyDeopt);"
3174+
" lazyDeopt();"
3175+
" lazyDeopt(true);"
3176+
" lazyDeopt();"
3177+
"})();";
3178+
3179+
CompileRun(source);
3180+
// Should not crash.
3181+
3182+
std::unique_ptr<v8::AllocationProfile> profile(
3183+
heap_profiler->GetAllocationProfile());
3184+
CHECK(profile);
3185+
heap_profiler->StopSamplingHeapProfiler();
3186+
}

0 commit comments

Comments
 (0)