Skip to content

Commit 63f41fc

Browse files
mlippautzCommit bot
authored andcommitted
Remove unused isolate parameter from NumberToSize and TryNumberToSize
BUG= Review-Url: https://codereview.chromium.org/2225013002 Cr-Commit-Position: refs/heads/master@{#38449}
1 parent ad8e0e2 commit 63f41fc

14 files changed

Lines changed: 100 additions & 113 deletions

src/api.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6927,10 +6927,9 @@ Local<ArrayBuffer> v8::ArrayBufferView::Buffer() {
69276927

69286928
size_t v8::ArrayBufferView::CopyContents(void* dest, size_t byte_length) {
69296929
i::Handle<i::JSArrayBufferView> self = Utils::OpenHandle(this);
6930-
i::Isolate* isolate = self->GetIsolate();
6931-
size_t byte_offset = i::NumberToSize(isolate, self->byte_offset());
6930+
size_t byte_offset = i::NumberToSize(self->byte_offset());
69326931
size_t bytes_to_copy =
6933-
i::Min(byte_length, i::NumberToSize(isolate, self->byte_length()));
6932+
i::Min(byte_length, i::NumberToSize(self->byte_length()));
69346933
if (bytes_to_copy) {
69356934
i::DisallowHeapAllocation no_gc;
69366935
i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(self->buffer()));

src/builtins/builtins-arraybuffer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ BUILTIN(ArrayBufferConstructor_ConstructStub) {
4141
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
4242
JSObject::New(target, new_target));
4343
size_t byte_length;
44-
if (!TryNumberToSize(isolate, *number_length, &byte_length)) {
44+
if (!TryNumberToSize(*number_length, &byte_length)) {
4545
THROW_NEW_ERROR_RETURN_FAILURE(
4646
isolate, NewRangeError(MessageTemplate::kInvalidArrayBufferLength));
4747
}

src/conversions-inl.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ int64_t NumberToInt64(Object* number) {
139139
return static_cast<int64_t>(number->Number());
140140
}
141141

142-
bool TryNumberToSize(Isolate* isolate, Object* number, size_t* result) {
142+
bool TryNumberToSize(Object* number, size_t* result) {
143143
// Do not create handles in this function! Don't use SealHandleScope because
144144
// the function can be used concurrently.
145145
if (number->IsSmi()) {
@@ -163,10 +163,9 @@ bool TryNumberToSize(Isolate* isolate, Object* number, size_t* result) {
163163
}
164164
}
165165

166-
167-
size_t NumberToSize(Isolate* isolate, Object* number) {
166+
size_t NumberToSize(Object* number) {
168167
size_t result = 0;
169-
bool is_valid = TryNumberToSize(isolate, number, &result);
168+
bool is_valid = TryNumberToSize(number, &result);
170169
CHECK(is_valid);
171170
return result;
172171
}

src/conversions.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,10 @@ inline int64_t NumberToInt64(Object* number);
175175
double StringToDouble(UnicodeCache* unicode_cache, Handle<String> string,
176176
int flags, double empty_string_val = 0.0);
177177

178-
179-
inline bool TryNumberToSize(Isolate* isolate, Object* number, size_t* result);
180-
178+
inline bool TryNumberToSize(Object* number, size_t* result);
181179

182180
// Converts a number into size_t.
183-
inline size_t NumberToSize(Isolate* isolate, Object* number);
184-
181+
inline size_t NumberToSize(Object* number);
185182

186183
// returns DoubleToString(StringToDouble(string)) == string
187184
bool IsSpecialIndex(UnicodeCache* unicode_cache, String* string);

src/futex-emulation.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void FutexWaitList::RemoveNode(FutexWaitListNode* node) {
7575
Object* FutexEmulation::Wait(Isolate* isolate,
7676
Handle<JSArrayBuffer> array_buffer, size_t addr,
7777
int32_t value, double rel_timeout_ms) {
78-
DCHECK(addr < NumberToSize(isolate, array_buffer->byte_length()));
78+
DCHECK(addr < NumberToSize(array_buffer->byte_length()));
7979

8080
void* backing_store = array_buffer->backing_store();
8181
int32_t* p =
@@ -191,7 +191,7 @@ Object* FutexEmulation::Wait(Isolate* isolate,
191191
Object* FutexEmulation::Wake(Isolate* isolate,
192192
Handle<JSArrayBuffer> array_buffer, size_t addr,
193193
int num_waiters_to_wake) {
194-
DCHECK(addr < NumberToSize(isolate, array_buffer->byte_length()));
194+
DCHECK(addr < NumberToSize(array_buffer->byte_length()));
195195

196196
int waiters_woken = 0;
197197
void* backing_store = array_buffer->backing_store();
@@ -216,7 +216,7 @@ Object* FutexEmulation::Wake(Isolate* isolate,
216216
Object* FutexEmulation::NumWaitersForTesting(Isolate* isolate,
217217
Handle<JSArrayBuffer> array_buffer,
218218
size_t addr) {
219-
DCHECK(addr < NumberToSize(isolate, array_buffer->byte_length()));
219+
DCHECK(addr < NumberToSize(array_buffer->byte_length()));
220220
void* backing_store = array_buffer->backing_store();
221221

222222
base::LockGuard<base::Mutex> lock_guard(mutex_.Pointer());

src/heap/array-buffer-tracker-inl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ void ArrayBufferTracker::RegisterNew(Heap* heap, JSArrayBuffer* buffer) {
1414
void* data = buffer->backing_store();
1515
if (!data) return;
1616

17-
size_t length = NumberToSize(heap->isolate(), buffer->byte_length());
17+
size_t length = NumberToSize(buffer->byte_length());
1818
Page* page = Page::FromAddress(buffer->address());
1919
{
2020
base::LockGuard<base::Mutex> guard(page->mutex());

src/profiler/heap-snapshot-generator.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,7 @@ void V8HeapExplorer::ExtractJSArrayBufferReferences(
15211521
// Setup a reference to a native memory backing_store object.
15221522
if (!buffer->backing_store())
15231523
return;
1524-
size_t data_size = NumberToSize(heap_->isolate(), buffer->byte_length());
1524+
size_t data_size = NumberToSize(buffer->byte_length());
15251525
JSArrayBufferDataEntryAllocator allocator(data_size, this);
15261526
HeapEntry* data_entry =
15271527
filler_->FindOrAddEntry(buffer->backing_store(), &allocator);

src/runtime/runtime-atomics.cc

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,10 @@ RUNTIME_FUNCTION(Runtime_AtomicsCompareExchange) {
355355
CONVERT_NUMBER_ARG_HANDLE_CHECKED(oldobj, 2);
356356
CONVERT_NUMBER_ARG_HANDLE_CHECKED(newobj, 3);
357357
CHECK(sta->GetBuffer()->is_shared());
358-
CHECK_LT(index, NumberToSize(isolate, sta->length()));
358+
CHECK_LT(index, NumberToSize(sta->length()));
359359

360360
uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
361-
NumberToSize(isolate, sta->byte_offset());
361+
NumberToSize(sta->byte_offset());
362362

363363
switch (sta->type()) {
364364
#define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \
@@ -388,10 +388,10 @@ RUNTIME_FUNCTION(Runtime_AtomicsAdd) {
388388
CONVERT_SIZE_ARG_CHECKED(index, 1);
389389
CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2);
390390
CHECK(sta->GetBuffer()->is_shared());
391-
CHECK_LT(index, NumberToSize(isolate, sta->length()));
391+
CHECK_LT(index, NumberToSize(sta->length()));
392392

393393
uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
394-
NumberToSize(isolate, sta->byte_offset());
394+
NumberToSize(sta->byte_offset());
395395

396396
switch (sta->type()) {
397397
#define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \
@@ -420,10 +420,10 @@ RUNTIME_FUNCTION(Runtime_AtomicsSub) {
420420
CONVERT_SIZE_ARG_CHECKED(index, 1);
421421
CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2);
422422
CHECK(sta->GetBuffer()->is_shared());
423-
CHECK_LT(index, NumberToSize(isolate, sta->length()));
423+
CHECK_LT(index, NumberToSize(sta->length()));
424424

425425
uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
426-
NumberToSize(isolate, sta->byte_offset());
426+
NumberToSize(sta->byte_offset());
427427

428428
switch (sta->type()) {
429429
#define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \
@@ -452,10 +452,10 @@ RUNTIME_FUNCTION(Runtime_AtomicsAnd) {
452452
CONVERT_SIZE_ARG_CHECKED(index, 1);
453453
CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2);
454454
CHECK(sta->GetBuffer()->is_shared());
455-
CHECK_LT(index, NumberToSize(isolate, sta->length()));
455+
CHECK_LT(index, NumberToSize(sta->length()));
456456

457457
uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
458-
NumberToSize(isolate, sta->byte_offset());
458+
NumberToSize(sta->byte_offset());
459459

460460
switch (sta->type()) {
461461
#define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \
@@ -484,10 +484,10 @@ RUNTIME_FUNCTION(Runtime_AtomicsOr) {
484484
CONVERT_SIZE_ARG_CHECKED(index, 1);
485485
CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2);
486486
CHECK(sta->GetBuffer()->is_shared());
487-
CHECK_LT(index, NumberToSize(isolate, sta->length()));
487+
CHECK_LT(index, NumberToSize(sta->length()));
488488

489489
uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
490-
NumberToSize(isolate, sta->byte_offset());
490+
NumberToSize(sta->byte_offset());
491491

492492
switch (sta->type()) {
493493
#define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \
@@ -516,10 +516,10 @@ RUNTIME_FUNCTION(Runtime_AtomicsXor) {
516516
CONVERT_SIZE_ARG_CHECKED(index, 1);
517517
CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2);
518518
CHECK(sta->GetBuffer()->is_shared());
519-
CHECK_LT(index, NumberToSize(isolate, sta->length()));
519+
CHECK_LT(index, NumberToSize(sta->length()));
520520

521521
uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
522-
NumberToSize(isolate, sta->byte_offset());
522+
NumberToSize(sta->byte_offset());
523523

524524
switch (sta->type()) {
525525
#define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \
@@ -548,10 +548,10 @@ RUNTIME_FUNCTION(Runtime_AtomicsExchange) {
548548
CONVERT_SIZE_ARG_CHECKED(index, 1);
549549
CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2);
550550
CHECK(sta->GetBuffer()->is_shared());
551-
CHECK_LT(index, NumberToSize(isolate, sta->length()));
551+
CHECK_LT(index, NumberToSize(sta->length()));
552552

553553
uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
554-
NumberToSize(isolate, sta->byte_offset());
554+
NumberToSize(sta->byte_offset());
555555

556556
switch (sta->type()) {
557557
#define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \

src/runtime/runtime-futex.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ RUNTIME_FUNCTION(Runtime_AtomicsWait) {
2525
CONVERT_INT32_ARG_CHECKED(value, 2);
2626
CONVERT_DOUBLE_ARG_CHECKED(timeout, 3);
2727
CHECK(sta->GetBuffer()->is_shared());
28-
CHECK_LT(index, NumberToSize(isolate, sta->length()));
28+
CHECK_LT(index, NumberToSize(sta->length()));
2929
CHECK_EQ(sta->type(), kExternalInt32Array);
3030
CHECK(timeout == V8_INFINITY || !std::isnan(timeout));
3131

3232
Handle<JSArrayBuffer> array_buffer = sta->GetBuffer();
33-
size_t addr = (index << 2) + NumberToSize(isolate, sta->byte_offset());
33+
size_t addr = (index << 2) + NumberToSize(sta->byte_offset());
3434

3535
return FutexEmulation::Wait(isolate, array_buffer, addr, value, timeout);
3636
}
@@ -42,11 +42,11 @@ RUNTIME_FUNCTION(Runtime_AtomicsWake) {
4242
CONVERT_SIZE_ARG_CHECKED(index, 1);
4343
CONVERT_INT32_ARG_CHECKED(count, 2);
4444
CHECK(sta->GetBuffer()->is_shared());
45-
CHECK_LT(index, NumberToSize(isolate, sta->length()));
45+
CHECK_LT(index, NumberToSize(sta->length()));
4646
CHECK_EQ(sta->type(), kExternalInt32Array);
4747

4848
Handle<JSArrayBuffer> array_buffer = sta->GetBuffer();
49-
size_t addr = (index << 2) + NumberToSize(isolate, sta->byte_offset());
49+
size_t addr = (index << 2) + NumberToSize(sta->byte_offset());
5050

5151
return FutexEmulation::Wake(isolate, array_buffer, addr, count);
5252
}
@@ -57,11 +57,11 @@ RUNTIME_FUNCTION(Runtime_AtomicsNumWaitersForTesting) {
5757
CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0);
5858
CONVERT_SIZE_ARG_CHECKED(index, 1);
5959
CHECK(sta->GetBuffer()->is_shared());
60-
CHECK_LT(index, NumberToSize(isolate, sta->length()));
60+
CHECK_LT(index, NumberToSize(sta->length()));
6161
CHECK_EQ(sta->type(), kExternalInt32Array);
6262

6363
Handle<JSArrayBuffer> array_buffer = sta->GetBuffer();
64-
size_t addr = (index << 2) + NumberToSize(isolate, sta->byte_offset());
64+
size_t addr = (index << 2) + NumberToSize(sta->byte_offset());
6565

6666
return FutexEmulation::NumWaitersForTesting(isolate, array_buffer, addr);
6767
}

src/runtime/runtime-simd.cc

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -894,47 +894,47 @@ SIMD_FROM_BITS_TYPES(SIMD_FROM_BITS_FUNCTION)
894894

895895
// Common Load and Store Functions
896896

897-
#define SIMD_LOAD(type, lane_type, lane_count, count, result) \
898-
static const int kLaneCount = lane_count; \
899-
DCHECK(args.length() == 2); \
900-
CONVERT_SIMD_ARG_HANDLE_THROW(JSTypedArray, tarray, 0); \
901-
SIMD_COERCE_INDEX(index, 1); \
902-
size_t bpe = tarray->element_size(); \
903-
uint32_t bytes = count * sizeof(lane_type); \
904-
size_t byte_length = NumberToSize(isolate, tarray->byte_length()); \
905-
if (index < 0 || index * bpe + bytes > byte_length) { \
906-
THROW_NEW_ERROR_RETURN_FAILURE( \
907-
isolate, NewRangeError(MessageTemplate::kInvalidSimdIndex)); \
908-
} \
909-
size_t tarray_offset = NumberToSize(isolate, tarray->byte_offset()); \
910-
uint8_t* tarray_base = \
911-
static_cast<uint8_t*>(tarray->GetBuffer()->backing_store()) + \
912-
tarray_offset; \
913-
lane_type lanes[kLaneCount] = {0}; \
914-
memcpy(lanes, tarray_base + index * bpe, bytes); \
897+
#define SIMD_LOAD(type, lane_type, lane_count, count, result) \
898+
static const int kLaneCount = lane_count; \
899+
DCHECK(args.length() == 2); \
900+
CONVERT_SIMD_ARG_HANDLE_THROW(JSTypedArray, tarray, 0); \
901+
SIMD_COERCE_INDEX(index, 1); \
902+
size_t bpe = tarray->element_size(); \
903+
uint32_t bytes = count * sizeof(lane_type); \
904+
size_t byte_length = NumberToSize(tarray->byte_length()); \
905+
if (index < 0 || index * bpe + bytes > byte_length) { \
906+
THROW_NEW_ERROR_RETURN_FAILURE( \
907+
isolate, NewRangeError(MessageTemplate::kInvalidSimdIndex)); \
908+
} \
909+
size_t tarray_offset = NumberToSize(tarray->byte_offset()); \
910+
uint8_t* tarray_base = \
911+
static_cast<uint8_t*>(tarray->GetBuffer()->backing_store()) + \
912+
tarray_offset; \
913+
lane_type lanes[kLaneCount] = {0}; \
914+
memcpy(lanes, tarray_base + index * bpe, bytes); \
915915
Handle<type> result = isolate->factory()->New##type(lanes);
916916

917-
#define SIMD_STORE(type, lane_type, lane_count, count, a) \
918-
static const int kLaneCount = lane_count; \
919-
DCHECK(args.length() == 3); \
920-
CONVERT_SIMD_ARG_HANDLE_THROW(JSTypedArray, tarray, 0); \
921-
CONVERT_SIMD_ARG_HANDLE_THROW(type, a, 2); \
922-
SIMD_COERCE_INDEX(index, 1); \
923-
size_t bpe = tarray->element_size(); \
924-
uint32_t bytes = count * sizeof(lane_type); \
925-
size_t byte_length = NumberToSize(isolate, tarray->byte_length()); \
926-
if (index < 0 || byte_length < index * bpe + bytes) { \
927-
THROW_NEW_ERROR_RETURN_FAILURE( \
928-
isolate, NewRangeError(MessageTemplate::kInvalidSimdIndex)); \
929-
} \
930-
size_t tarray_offset = NumberToSize(isolate, tarray->byte_offset()); \
931-
uint8_t* tarray_base = \
932-
static_cast<uint8_t*>(tarray->GetBuffer()->backing_store()) + \
933-
tarray_offset; \
934-
lane_type lanes[kLaneCount]; \
935-
for (int i = 0; i < kLaneCount; i++) { \
936-
lanes[i] = a->get_lane(i); \
937-
} \
917+
#define SIMD_STORE(type, lane_type, lane_count, count, a) \
918+
static const int kLaneCount = lane_count; \
919+
DCHECK(args.length() == 3); \
920+
CONVERT_SIMD_ARG_HANDLE_THROW(JSTypedArray, tarray, 0); \
921+
CONVERT_SIMD_ARG_HANDLE_THROW(type, a, 2); \
922+
SIMD_COERCE_INDEX(index, 1); \
923+
size_t bpe = tarray->element_size(); \
924+
uint32_t bytes = count * sizeof(lane_type); \
925+
size_t byte_length = NumberToSize(tarray->byte_length()); \
926+
if (index < 0 || byte_length < index * bpe + bytes) { \
927+
THROW_NEW_ERROR_RETURN_FAILURE( \
928+
isolate, NewRangeError(MessageTemplate::kInvalidSimdIndex)); \
929+
} \
930+
size_t tarray_offset = NumberToSize(tarray->byte_offset()); \
931+
uint8_t* tarray_base = \
932+
static_cast<uint8_t*>(tarray->GetBuffer()->backing_store()) + \
933+
tarray_offset; \
934+
lane_type lanes[kLaneCount]; \
935+
for (int i = 0; i < kLaneCount; i++) { \
936+
lanes[i] = a->get_lane(i); \
937+
} \
938938
memcpy(tarray_base + index * bpe, lanes, bytes);
939939

940940
#define SIMD_LOAD_FUNCTION(type, lane_type, lane_count) \

0 commit comments

Comments
 (0)