Skip to content

Commit

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

PR-URL: nodejs#21192
Reviewed-By: Ali Ijaz Sheikh <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
targos committed Jun 10, 2018
1 parent 0454725 commit 473e36d
Show file tree
Hide file tree
Showing 6 changed files with 255 additions and 17 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 6
#define V8_MINOR_VERSION 7
#define V8_BUILD_NUMBER 288
#define V8_PATCH_LEVEL 44
#define V8_PATCH_LEVEL 45

// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
Expand Down
13 changes: 11 additions & 2 deletions deps/v8/include/v8.h
Original file line number Diff line number Diff line change
Expand Up @@ -9071,6 +9071,7 @@ class Internals {
static const int kNodeStateIsWeakValue = 2;
static const int kNodeStateIsPendingValue = 3;
static const int kNodeStateIsNearDeathValue = 4;
static const int kNodeIsIndependentShift = 3;
static const int kNodeIsActiveShift = 4;

static const int kFirstNonstringType = 0x80;
Expand Down Expand Up @@ -9294,7 +9295,10 @@ void Persistent<T, M>::Copy(const Persistent<S, M2>& that) {

template <class T>
bool PersistentBase<T>::IsIndependent() const {
return true;
typedef internal::Internals I;
if (this->IsEmpty()) return false;
return I::GetNodeFlag(reinterpret_cast<internal::Object**>(this->val_),
I::kNodeIsIndependentShift);
}

template <class T>
Expand Down Expand Up @@ -9383,7 +9387,12 @@ void PersistentBase<T>::RegisterExternalReference(Isolate* isolate) const {
}

template <class T>
void PersistentBase<T>::MarkIndependent() {}
void PersistentBase<T>::MarkIndependent() {
typedef internal::Internals I;
if (this->IsEmpty()) return;
I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_), true,
I::kNodeIsIndependentShift);
}

template <class T>
void PersistentBase<T>::MarkActive() {
Expand Down
55 changes: 42 additions & 13 deletions deps/v8/src/global-handles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class GlobalHandles::Node {
STATIC_ASSERT(WEAK == Internals::kNodeStateIsWeakValue);
STATIC_ASSERT(PENDING == Internals::kNodeStateIsPendingValue);
STATIC_ASSERT(NEAR_DEATH == Internals::kNodeStateIsNearDeathValue);
STATIC_ASSERT(static_cast<int>(IsIndependent::kShift) ==
Internals::kNodeIsIndependentShift);
STATIC_ASSERT(static_cast<int>(IsActive::kShift) ==
Internals::kNodeIsActiveShift);
}
Expand All @@ -52,6 +54,7 @@ class GlobalHandles::Node {
object_ = reinterpret_cast<Object*>(kGlobalHandleZapValue);
class_id_ = v8::HeapProfiler::kPersistentHandleNoClassId;
index_ = 0;
set_independent(false);
set_active(false);
set_in_new_space_list(false);
data_.next_free = nullptr;
Expand All @@ -73,6 +76,7 @@ class GlobalHandles::Node {
DCHECK(state() == FREE);
object_ = object;
class_id_ = v8::HeapProfiler::kPersistentHandleNoClassId;
set_independent(false);
set_active(false);
set_state(NORMAL);
data_.parameter = nullptr;
Expand All @@ -92,6 +96,7 @@ class GlobalHandles::Node {
// Zap the values for eager trapping.
object_ = reinterpret_cast<Object*>(kGlobalHandleZapValue);
class_id_ = v8::HeapProfiler::kPersistentHandleNoClassId;
set_independent(false);
set_active(false);
weak_callback_ = nullptr;
DecreaseBlockUses();
Expand Down Expand Up @@ -119,6 +124,9 @@ class GlobalHandles::Node {
flags_ = NodeState::update(flags_, state);
}

bool is_independent() { return IsIndependent::decode(flags_); }
void set_independent(bool v) { flags_ = IsIndependent::update(flags_, v); }

bool is_active() {
return IsActive::decode(flags_);
}
Expand Down Expand Up @@ -183,6 +191,12 @@ class GlobalHandles::Node {
set_state(PENDING);
}

// Independent flag accessors.
void MarkIndependent() {
DCHECK(IsInUse());
set_independent(true);
}

// Callback parameter accessors.
void set_parameter(void* parameter) {
DCHECK(IsInUse());
Expand Down Expand Up @@ -330,7 +344,7 @@ class GlobalHandles::Node {
// Placed first to avoid offset computation.
Object* object_;

// Next word stores class_id, index, and state.
// Next word stores class_id, index, state, and independent.
// Note: the most aligned fields should go first.

// Wrapper class ID.
Expand All @@ -339,7 +353,10 @@ class GlobalHandles::Node {
// Index in the containing handle block.
uint8_t index_;

// This stores three flags (independent, partially_dependent and
// in_new_space_list) and a State.
class NodeState : public BitField<State, 0, 3> {};
class IsIndependent : public BitField<bool, 3, 1> {};
// The following two fields are mutually exclusive
class IsActive : public BitField<bool, 4, 1> {};
class IsInNewSpaceList : public BitField<bool, 5, 1> {};
Expand Down Expand Up @@ -591,6 +608,14 @@ void GlobalHandles::AnnotateStrongRetainer(Object** location,
Node::FromLocation(location)->AnnotateStrongRetainer(label);
}

void GlobalHandles::MarkIndependent(Object** location) {
Node::FromLocation(location)->MarkIndependent();
}

bool GlobalHandles::IsIndependent(Object** location) {
return Node::FromLocation(location)->is_independent();
}

bool GlobalHandles::IsNearDeath(Object** location) {
return Node::FromLocation(location)->IsNearDeath();
}
Expand Down Expand Up @@ -647,7 +672,8 @@ void GlobalHandles::IdentifyWeakHandles(WeakSlotCallback should_reset_handle) {
void GlobalHandles::IterateNewSpaceStrongAndDependentRoots(RootVisitor* v) {
for (Node* node : new_space_nodes_) {
if (node->IsStrongRetainer() ||
(node->IsWeakRetainer() && node->is_active())) {
(node->IsWeakRetainer() && !node->is_independent() &&
node->is_active())) {
v->VisitRootPointer(Root::kGlobalHandles, node->label(),
node->location());
}
Expand All @@ -662,7 +688,8 @@ void GlobalHandles::IterateNewSpaceStrongAndDependentRootsAndIdentifyUnmodified(
node->set_active(true);
}
if (node->IsStrongRetainer() ||
(node->IsWeakRetainer() && node->is_active())) {
(node->IsWeakRetainer() && !node->is_independent() &&
node->is_active())) {
v->VisitRootPointer(Root::kGlobalHandles, node->label(),
node->location());
}
Expand All @@ -682,8 +709,8 @@ void GlobalHandles::MarkNewSpaceWeakUnmodifiedObjectsPending(
WeakSlotCallbackWithHeap is_dead) {
for (Node* node : new_space_nodes_) {
DCHECK(node->is_in_new_space_list());
if (node->IsWeak() && is_dead(isolate_->heap(), node->location())) {
DCHECK(!node->is_active());
if ((node->is_independent() || !node->is_active()) && node->IsWeak() &&
is_dead(isolate_->heap(), node->location())) {
if (!node->IsPhantomCallback() && !node->IsPhantomResetHandle()) {
node->MarkPending();
}
Expand All @@ -695,8 +722,8 @@ void GlobalHandles::IterateNewSpaceWeakUnmodifiedRootsForFinalizers(
RootVisitor* v) {
for (Node* node : new_space_nodes_) {
DCHECK(node->is_in_new_space_list());
if (!node->is_active() && node->IsWeakRetainer() &&
(node->state() == Node::PENDING)) {
if ((node->is_independent() || !node->is_active()) &&
node->IsWeakRetainer() && (node->state() == Node::PENDING)) {
DCHECK(!node->IsPhantomCallback());
DCHECK(!node->IsPhantomResetHandle());
// Finalizers need to survive.
Expand All @@ -710,8 +737,8 @@ void GlobalHandles::IterateNewSpaceWeakUnmodifiedRootsForPhantomHandles(
RootVisitor* v, WeakSlotCallbackWithHeap should_reset_handle) {
for (Node* node : new_space_nodes_) {
DCHECK(node->is_in_new_space_list());
if (!node->is_active() && node->IsWeakRetainer() &&
(node->state() != Node::PENDING)) {
if ((node->is_independent() || !node->is_active()) &&
node->IsWeakRetainer() && (node->state() != Node::PENDING)) {
DCHECK(node->IsPhantomResetHandle() || node->IsPhantomCallback());
if (should_reset_handle(isolate_->heap(), node->location())) {
if (node->IsPhantomResetHandle()) {
Expand Down Expand Up @@ -757,12 +784,15 @@ int GlobalHandles::PostScavengeProcessing(
// the freed_nodes.
continue;
}

// Active nodes are kept alive, so no further processing is requires.
if (node->is_active()) {
// Skip dependent or unmodified handles. Their weak callbacks might expect
// to be
// called between two global garbage collection callbacks which
// are not called for minor collections.
if (!node->is_independent() && (node->is_active())) {
node->set_active(false);
continue;
}
node->set_active(false);

if (node->PostGarbageCollectionProcessing(isolate_)) {
if (initial_post_gc_processing_count != post_gc_processing_count_) {
Expand All @@ -773,7 +803,6 @@ int GlobalHandles::PostScavengeProcessing(
return freed_nodes;
}
}

if (!node->IsRetainer()) {
freed_nodes++;
}
Expand Down
8 changes: 7 additions & 1 deletion deps/v8/src/global-handles.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ class GlobalHandles {
// Clear the weakness of a global handle.
static void* ClearWeakness(Object** location);

// Mark the reference to this object independent.
static void MarkIndependent(Object** location);

static bool IsIndependent(Object** location);

// Tells whether global handle is near death.
static bool IsNearDeath(Object** location);

Expand Down Expand Up @@ -155,7 +160,8 @@ class GlobalHandles {
void MarkNewSpaceWeakUnmodifiedObjectsPending(
WeakSlotCallbackWithHeap is_dead);

// Iterates over weak unmodified handles. See the note above.
// Iterates over weak independent or unmodified handles.
// See the note above.
void IterateNewSpaceWeakUnmodifiedRootsForFinalizers(RootVisitor* v);
void IterateNewSpaceWeakUnmodifiedRootsForPhantomHandles(
RootVisitor* v, WeakSlotCallbackWithHeap should_reset_handle);
Expand Down
1 change: 1 addition & 0 deletions deps/v8/src/profiler/sampling-heap-profiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ void SamplingHeapProfiler::SampleObject(Address soon_object, size_t size) {
Sample* sample = new Sample(size, node, loc, this);
samples_.emplace(sample);
sample->global.SetWeak(sample, OnWeakCallback, WeakCallbackType::kParameter);
sample->global.MarkIndependent();
}

void SamplingHeapProfiler::OnWeakCallback(
Expand Down
Loading

0 comments on commit 473e36d

Please sign in to comment.