Commit 5ccc719a authored by krasin's avatar krasin Committed by Commit bot

Fix unused lambda captures.

Clang just got more strict about unused lambda captures,
and that requires us to clean all places with this issue
across all the Chromium code base. This CL fixes all such
cases in V8.

BUG=chromium:681136

Review-Url: https://codereview.chromium.org/2646553002
Cr-Commit-Position: refs/heads/master@{#42523}
parent 4e565c68
...@@ -318,7 +318,7 @@ void Builtins::Generate_FastArrayPush(compiler::CodeAssemblerState* state) { ...@@ -318,7 +318,7 @@ void Builtins::Generate_FastArrayPush(compiler::CodeAssemblerState* state) {
assembler.Bind(&default_label); assembler.Bind(&default_label);
{ {
args.ForEach( args.ForEach(
[&assembler, receiver, context, &arg_index](Node* arg) { [&assembler, receiver, context](Node* arg) {
Node* length = assembler.LoadJSArrayLength(receiver); Node* length = assembler.LoadJSArrayLength(receiver);
assembler.CallRuntime(Runtime::kSetProperty, context, receiver, assembler.CallRuntime(Runtime::kSetProperty, context, receiver,
length, arg, assembler.SmiConstant(STRICT)); length, arg, assembler.SmiConstant(STRICT));
......
...@@ -1841,7 +1841,7 @@ void GetPropertyStub::GenerateAssembly( ...@@ -1841,7 +1841,7 @@ void GetPropertyStub::GenerateAssembly(
}; };
CodeStubAssembler::LookupInHolder lookup_element_in_holder = CodeStubAssembler::LookupInHolder lookup_element_in_holder =
[&assembler, context, &var_result, &end]( [&assembler](
Node* receiver, Node* holder, Node* holder_map, Node* receiver, Node* holder, Node* holder_map,
Node* holder_instance_type, Node* index, Label* next_holder, Node* holder_instance_type, Node* index, Label* next_holder,
Label* if_bailout) { Label* if_bailout) {
......
...@@ -3676,7 +3676,7 @@ class PointerUpdateJobTraits { ...@@ -3676,7 +3676,7 @@ class PointerUpdateJobTraits {
private: private:
static void UpdateUntypedPointers(Heap* heap, MemoryChunk* chunk) { static void UpdateUntypedPointers(Heap* heap, MemoryChunk* chunk) {
if (direction == OLD_TO_NEW) { if (direction == OLD_TO_NEW) {
RememberedSet<OLD_TO_NEW>::Iterate(chunk, [heap, chunk](Address slot) { RememberedSet<OLD_TO_NEW>::Iterate(chunk, [heap](Address slot) {
return CheckAndUpdateOldToNewSlot(heap, slot); return CheckAndUpdateOldToNewSlot(heap, slot);
}); });
} else { } else {
......
...@@ -780,7 +780,7 @@ void Page::ResetFreeListStatistics() { ...@@ -780,7 +780,7 @@ void Page::ResetFreeListStatistics() {
size_t Page::AvailableInFreeList() { size_t Page::AvailableInFreeList() {
size_t sum = 0; size_t sum = 0;
ForAllFreeListCategories([this, &sum](FreeListCategory* category) { ForAllFreeListCategories([&sum](FreeListCategory* category) {
sum += category->available(); sum += category->available();
}); });
return sum; return sum;
...@@ -2636,7 +2636,7 @@ HeapObject* FreeList::Allocate(size_t size_in_bytes) { ...@@ -2636,7 +2636,7 @@ HeapObject* FreeList::Allocate(size_t size_in_bytes) {
size_t FreeList::EvictFreeListItems(Page* page) { size_t FreeList::EvictFreeListItems(Page* page) {
size_t sum = 0; size_t sum = 0;
page->ForAllFreeListCategories( page->ForAllFreeListCategories(
[this, &sum, page](FreeListCategory* category) { [this, &sum](FreeListCategory* category) {
DCHECK_EQ(this, category->owner()); DCHECK_EQ(this, category->owner());
sum += category->available(); sum += category->available();
RemoveCategory(category); RemoveCategory(category);
......
...@@ -150,8 +150,11 @@ TEST(SlotSet, RemoveRange) { ...@@ -150,8 +150,11 @@ TEST(SlotSet, RemoveRange) {
TEST(TypedSlotSet, Iterate) { TEST(TypedSlotSet, Iterate) {
TypedSlotSet set(0); TypedSlotSet set(0);
const int kDelta = 10000001; // These two constants must be static as a workaround
const int kHostDelta = 50001; // for a MSVC++ bug about lambda captures, see the discussion at
// https://social.msdn.microsoft.com/Forums/SqlServer/4abf18bd-4ae4-4c72-ba3e-3b13e7909d5f
static const int kDelta = 10000001;
static const int kHostDelta = 50001;
int added = 0; int added = 0;
uint32_t j = 0; uint32_t j = 0;
for (uint32_t i = 0; i < TypedSlotSet::kMaxOffset; for (uint32_t i = 0; i < TypedSlotSet::kMaxOffset;
...@@ -162,7 +165,7 @@ TEST(TypedSlotSet, Iterate) { ...@@ -162,7 +165,7 @@ TEST(TypedSlotSet, Iterate) {
} }
int iterated = 0; int iterated = 0;
set.Iterate( set.Iterate(
[&iterated, kDelta, kHostDelta](SlotType type, Address host_addr, [&iterated](SlotType type, Address host_addr,
Address addr) { Address addr) {
uint32_t i = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(addr)); uint32_t i = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(addr));
uint32_t j = uint32_t j =
......
...@@ -1178,7 +1178,7 @@ TEST_F(ValueSerializerTest, RoundTripArrayWithTrickyGetters) { ...@@ -1178,7 +1178,7 @@ TEST_F(ValueSerializerTest, RoundTripArrayWithTrickyGetters) {
TEST_F(ValueSerializerTest, DecodeSparseArrayVersion0) { TEST_F(ValueSerializerTest, DecodeSparseArrayVersion0) {
// Empty (sparse) array. // Empty (sparse) array.
DecodeTestForVersion0({0x40, 0x00, 0x00, 0x00}, DecodeTestForVersion0({0x40, 0x00, 0x00, 0x00},
[this](Local<Value> value) { [](Local<Value> value) {
ASSERT_TRUE(value->IsArray()); ASSERT_TRUE(value->IsArray());
ASSERT_EQ(0u, Array::Cast(*value)->Length()); ASSERT_EQ(0u, Array::Cast(*value)->Length());
}); });
...@@ -1210,16 +1210,16 @@ TEST_F(ValueSerializerTest, DecodeSparseArrayVersion0) { ...@@ -1210,16 +1210,16 @@ TEST_F(ValueSerializerTest, DecodeSparseArrayVersion0) {
} }
TEST_F(ValueSerializerTest, RoundTripDate) { TEST_F(ValueSerializerTest, RoundTripDate) {
RoundTripTest("new Date(1e6)", [this](Local<Value> value) { RoundTripTest("new Date(1e6)", [](Local<Value> value) {
ASSERT_TRUE(value->IsDate()); ASSERT_TRUE(value->IsDate());
EXPECT_EQ(1e6, Date::Cast(*value)->ValueOf()); EXPECT_EQ(1e6, Date::Cast(*value)->ValueOf());
EXPECT_TRUE("Object.getPrototypeOf(result) === Date.prototype"); EXPECT_TRUE("Object.getPrototypeOf(result) === Date.prototype");
}); });
RoundTripTest("new Date(Date.UTC(1867, 6, 1))", [this](Local<Value> value) { RoundTripTest("new Date(Date.UTC(1867, 6, 1))", [](Local<Value> value) {
ASSERT_TRUE(value->IsDate()); ASSERT_TRUE(value->IsDate());
EXPECT_TRUE("result.toISOString() === '1867-07-01T00:00:00.000Z'"); EXPECT_TRUE("result.toISOString() === '1867-07-01T00:00:00.000Z'");
}); });
RoundTripTest("new Date(NaN)", [this](Local<Value> value) { RoundTripTest("new Date(NaN)", [](Local<Value> value) {
ASSERT_TRUE(value->IsDate()); ASSERT_TRUE(value->IsDate());
EXPECT_TRUE(std::isnan(Date::Cast(*value)->ValueOf())); EXPECT_TRUE(std::isnan(Date::Cast(*value)->ValueOf()));
}); });
...@@ -1235,7 +1235,7 @@ TEST_F(ValueSerializerTest, DecodeDate) { ...@@ -1235,7 +1235,7 @@ TEST_F(ValueSerializerTest, DecodeDate) {
#if defined(V8_TARGET_LITTLE_ENDIAN) #if defined(V8_TARGET_LITTLE_ENDIAN)
DecodeTest({0xff, 0x09, 0x3f, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x80, 0x84, DecodeTest({0xff, 0x09, 0x3f, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x80, 0x84,
0x2e, 0x41, 0x00}, 0x2e, 0x41, 0x00},
[this](Local<Value> value) { [](Local<Value> value) {
ASSERT_TRUE(value->IsDate()); ASSERT_TRUE(value->IsDate());
EXPECT_EQ(1e6, Date::Cast(*value)->ValueOf()); EXPECT_EQ(1e6, Date::Cast(*value)->ValueOf());
EXPECT_TRUE("Object.getPrototypeOf(result) === Date.prototype"); EXPECT_TRUE("Object.getPrototypeOf(result) === Date.prototype");
...@@ -1243,13 +1243,13 @@ TEST_F(ValueSerializerTest, DecodeDate) { ...@@ -1243,13 +1243,13 @@ TEST_F(ValueSerializerTest, DecodeDate) {
DecodeTest( DecodeTest(
{0xff, 0x09, 0x3f, 0x00, 0x44, 0x00, 0x00, 0x20, 0x45, 0x27, 0x89, 0x87, {0xff, 0x09, 0x3f, 0x00, 0x44, 0x00, 0x00, 0x20, 0x45, 0x27, 0x89, 0x87,
0xc2, 0x00}, 0xc2, 0x00},
[this](Local<Value> value) { [](Local<Value> value) {
ASSERT_TRUE(value->IsDate()); ASSERT_TRUE(value->IsDate());
EXPECT_TRUE("result.toISOString() === '1867-07-01T00:00:00.000Z'"); EXPECT_TRUE("result.toISOString() === '1867-07-01T00:00:00.000Z'");
}); });
DecodeTest({0xff, 0x09, 0x3f, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, DecodeTest({0xff, 0x09, 0x3f, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xf8, 0x7f, 0x00}, 0xf8, 0x7f, 0x00},
[this](Local<Value> value) { [](Local<Value> value) {
ASSERT_TRUE(value->IsDate()); ASSERT_TRUE(value->IsDate());
EXPECT_TRUE(std::isnan(Date::Cast(*value)->ValueOf())); EXPECT_TRUE(std::isnan(Date::Cast(*value)->ValueOf()));
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment