Commit 63f41fcd authored by mlippautz's avatar mlippautz Committed by Commit bot

Remove unused isolate parameter from NumberToSize and TryNumberToSize

BUG=

Review-Url: https://codereview.chromium.org/2225013002
Cr-Commit-Position: refs/heads/master@{#38449}
parent ad8e0e25
......@@ -6927,10 +6927,9 @@ Local<ArrayBuffer> v8::ArrayBufferView::Buffer() {
size_t v8::ArrayBufferView::CopyContents(void* dest, size_t byte_length) {
i::Handle<i::JSArrayBufferView> self = Utils::OpenHandle(this);
i::Isolate* isolate = self->GetIsolate();
size_t byte_offset = i::NumberToSize(isolate, self->byte_offset());
size_t byte_offset = i::NumberToSize(self->byte_offset());
size_t bytes_to_copy =
i::Min(byte_length, i::NumberToSize(isolate, self->byte_length()));
i::Min(byte_length, i::NumberToSize(self->byte_length()));
if (bytes_to_copy) {
i::DisallowHeapAllocation no_gc;
i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(self->buffer()));
......
......@@ -41,7 +41,7 @@ BUILTIN(ArrayBufferConstructor_ConstructStub) {
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
JSObject::New(target, new_target));
size_t byte_length;
if (!TryNumberToSize(isolate, *number_length, &byte_length)) {
if (!TryNumberToSize(*number_length, &byte_length)) {
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewRangeError(MessageTemplate::kInvalidArrayBufferLength));
}
......
......@@ -139,7 +139,7 @@ int64_t NumberToInt64(Object* number) {
return static_cast<int64_t>(number->Number());
}
bool TryNumberToSize(Isolate* isolate, Object* number, size_t* result) {
bool TryNumberToSize(Object* number, size_t* result) {
// Do not create handles in this function! Don't use SealHandleScope because
// the function can be used concurrently.
if (number->IsSmi()) {
......@@ -163,10 +163,9 @@ bool TryNumberToSize(Isolate* isolate, Object* number, size_t* result) {
}
}
size_t NumberToSize(Isolate* isolate, Object* number) {
size_t NumberToSize(Object* number) {
size_t result = 0;
bool is_valid = TryNumberToSize(isolate, number, &result);
bool is_valid = TryNumberToSize(number, &result);
CHECK(is_valid);
return result;
}
......
......@@ -175,13 +175,10 @@ inline int64_t NumberToInt64(Object* number);
double StringToDouble(UnicodeCache* unicode_cache, Handle<String> string,
int flags, double empty_string_val = 0.0);
inline bool TryNumberToSize(Isolate* isolate, Object* number, size_t* result);
inline bool TryNumberToSize(Object* number, size_t* result);
// Converts a number into size_t.
inline size_t NumberToSize(Isolate* isolate, Object* number);
inline size_t NumberToSize(Object* number);
// returns DoubleToString(StringToDouble(string)) == string
bool IsSpecialIndex(UnicodeCache* unicode_cache, String* string);
......
......@@ -75,7 +75,7 @@ void FutexWaitList::RemoveNode(FutexWaitListNode* node) {
Object* FutexEmulation::Wait(Isolate* isolate,
Handle<JSArrayBuffer> array_buffer, size_t addr,
int32_t value, double rel_timeout_ms) {
DCHECK(addr < NumberToSize(isolate, array_buffer->byte_length()));
DCHECK(addr < NumberToSize(array_buffer->byte_length()));
void* backing_store = array_buffer->backing_store();
int32_t* p =
......@@ -191,7 +191,7 @@ Object* FutexEmulation::Wait(Isolate* isolate,
Object* FutexEmulation::Wake(Isolate* isolate,
Handle<JSArrayBuffer> array_buffer, size_t addr,
int num_waiters_to_wake) {
DCHECK(addr < NumberToSize(isolate, array_buffer->byte_length()));
DCHECK(addr < NumberToSize(array_buffer->byte_length()));
int waiters_woken = 0;
void* backing_store = array_buffer->backing_store();
......@@ -216,7 +216,7 @@ Object* FutexEmulation::Wake(Isolate* isolate,
Object* FutexEmulation::NumWaitersForTesting(Isolate* isolate,
Handle<JSArrayBuffer> array_buffer,
size_t addr) {
DCHECK(addr < NumberToSize(isolate, array_buffer->byte_length()));
DCHECK(addr < NumberToSize(array_buffer->byte_length()));
void* backing_store = array_buffer->backing_store();
base::LockGuard<base::Mutex> lock_guard(mutex_.Pointer());
......
......@@ -14,7 +14,7 @@ void ArrayBufferTracker::RegisterNew(Heap* heap, JSArrayBuffer* buffer) {
void* data = buffer->backing_store();
if (!data) return;
size_t length = NumberToSize(heap->isolate(), buffer->byte_length());
size_t length = NumberToSize(buffer->byte_length());
Page* page = Page::FromAddress(buffer->address());
{
base::LockGuard<base::Mutex> guard(page->mutex());
......
......@@ -1521,7 +1521,7 @@ void V8HeapExplorer::ExtractJSArrayBufferReferences(
// Setup a reference to a native memory backing_store object.
if (!buffer->backing_store())
return;
size_t data_size = NumberToSize(heap_->isolate(), buffer->byte_length());
size_t data_size = NumberToSize(buffer->byte_length());
JSArrayBufferDataEntryAllocator allocator(data_size, this);
HeapEntry* data_entry =
filler_->FindOrAddEntry(buffer->backing_store(), &allocator);
......
......@@ -355,10 +355,10 @@ RUNTIME_FUNCTION(Runtime_AtomicsCompareExchange) {
CONVERT_NUMBER_ARG_HANDLE_CHECKED(oldobj, 2);
CONVERT_NUMBER_ARG_HANDLE_CHECKED(newobj, 3);
CHECK(sta->GetBuffer()->is_shared());
CHECK_LT(index, NumberToSize(isolate, sta->length()));
CHECK_LT(index, NumberToSize(sta->length()));
uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
NumberToSize(isolate, sta->byte_offset());
NumberToSize(sta->byte_offset());
switch (sta->type()) {
#define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \
......@@ -388,10 +388,10 @@ RUNTIME_FUNCTION(Runtime_AtomicsAdd) {
CONVERT_SIZE_ARG_CHECKED(index, 1);
CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2);
CHECK(sta->GetBuffer()->is_shared());
CHECK_LT(index, NumberToSize(isolate, sta->length()));
CHECK_LT(index, NumberToSize(sta->length()));
uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
NumberToSize(isolate, sta->byte_offset());
NumberToSize(sta->byte_offset());
switch (sta->type()) {
#define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \
......@@ -420,10 +420,10 @@ RUNTIME_FUNCTION(Runtime_AtomicsSub) {
CONVERT_SIZE_ARG_CHECKED(index, 1);
CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2);
CHECK(sta->GetBuffer()->is_shared());
CHECK_LT(index, NumberToSize(isolate, sta->length()));
CHECK_LT(index, NumberToSize(sta->length()));
uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
NumberToSize(isolate, sta->byte_offset());
NumberToSize(sta->byte_offset());
switch (sta->type()) {
#define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \
......@@ -452,10 +452,10 @@ RUNTIME_FUNCTION(Runtime_AtomicsAnd) {
CONVERT_SIZE_ARG_CHECKED(index, 1);
CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2);
CHECK(sta->GetBuffer()->is_shared());
CHECK_LT(index, NumberToSize(isolate, sta->length()));
CHECK_LT(index, NumberToSize(sta->length()));
uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
NumberToSize(isolate, sta->byte_offset());
NumberToSize(sta->byte_offset());
switch (sta->type()) {
#define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \
......@@ -484,10 +484,10 @@ RUNTIME_FUNCTION(Runtime_AtomicsOr) {
CONVERT_SIZE_ARG_CHECKED(index, 1);
CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2);
CHECK(sta->GetBuffer()->is_shared());
CHECK_LT(index, NumberToSize(isolate, sta->length()));
CHECK_LT(index, NumberToSize(sta->length()));
uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
NumberToSize(isolate, sta->byte_offset());
NumberToSize(sta->byte_offset());
switch (sta->type()) {
#define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \
......@@ -516,10 +516,10 @@ RUNTIME_FUNCTION(Runtime_AtomicsXor) {
CONVERT_SIZE_ARG_CHECKED(index, 1);
CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2);
CHECK(sta->GetBuffer()->is_shared());
CHECK_LT(index, NumberToSize(isolate, sta->length()));
CHECK_LT(index, NumberToSize(sta->length()));
uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
NumberToSize(isolate, sta->byte_offset());
NumberToSize(sta->byte_offset());
switch (sta->type()) {
#define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \
......@@ -548,10 +548,10 @@ RUNTIME_FUNCTION(Runtime_AtomicsExchange) {
CONVERT_SIZE_ARG_CHECKED(index, 1);
CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2);
CHECK(sta->GetBuffer()->is_shared());
CHECK_LT(index, NumberToSize(isolate, sta->length()));
CHECK_LT(index, NumberToSize(sta->length()));
uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
NumberToSize(isolate, sta->byte_offset());
NumberToSize(sta->byte_offset());
switch (sta->type()) {
#define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \
......
......@@ -25,12 +25,12 @@ RUNTIME_FUNCTION(Runtime_AtomicsWait) {
CONVERT_INT32_ARG_CHECKED(value, 2);
CONVERT_DOUBLE_ARG_CHECKED(timeout, 3);
CHECK(sta->GetBuffer()->is_shared());
CHECK_LT(index, NumberToSize(isolate, sta->length()));
CHECK_LT(index, NumberToSize(sta->length()));
CHECK_EQ(sta->type(), kExternalInt32Array);
CHECK(timeout == V8_INFINITY || !std::isnan(timeout));
Handle<JSArrayBuffer> array_buffer = sta->GetBuffer();
size_t addr = (index << 2) + NumberToSize(isolate, sta->byte_offset());
size_t addr = (index << 2) + NumberToSize(sta->byte_offset());
return FutexEmulation::Wait(isolate, array_buffer, addr, value, timeout);
}
......@@ -42,11 +42,11 @@ RUNTIME_FUNCTION(Runtime_AtomicsWake) {
CONVERT_SIZE_ARG_CHECKED(index, 1);
CONVERT_INT32_ARG_CHECKED(count, 2);
CHECK(sta->GetBuffer()->is_shared());
CHECK_LT(index, NumberToSize(isolate, sta->length()));
CHECK_LT(index, NumberToSize(sta->length()));
CHECK_EQ(sta->type(), kExternalInt32Array);
Handle<JSArrayBuffer> array_buffer = sta->GetBuffer();
size_t addr = (index << 2) + NumberToSize(isolate, sta->byte_offset());
size_t addr = (index << 2) + NumberToSize(sta->byte_offset());
return FutexEmulation::Wake(isolate, array_buffer, addr, count);
}
......@@ -57,11 +57,11 @@ RUNTIME_FUNCTION(Runtime_AtomicsNumWaitersForTesting) {
CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0);
CONVERT_SIZE_ARG_CHECKED(index, 1);
CHECK(sta->GetBuffer()->is_shared());
CHECK_LT(index, NumberToSize(isolate, sta->length()));
CHECK_LT(index, NumberToSize(sta->length()));
CHECK_EQ(sta->type(), kExternalInt32Array);
Handle<JSArrayBuffer> array_buffer = sta->GetBuffer();
size_t addr = (index << 2) + NumberToSize(isolate, sta->byte_offset());
size_t addr = (index << 2) + NumberToSize(sta->byte_offset());
return FutexEmulation::NumWaitersForTesting(isolate, array_buffer, addr);
}
......
......@@ -894,47 +894,47 @@ SIMD_FROM_BITS_TYPES(SIMD_FROM_BITS_FUNCTION)
// Common Load and Store Functions
#define SIMD_LOAD(type, lane_type, lane_count, count, result) \
static const int kLaneCount = lane_count; \
DCHECK(args.length() == 2); \
CONVERT_SIMD_ARG_HANDLE_THROW(JSTypedArray, tarray, 0); \
SIMD_COERCE_INDEX(index, 1); \
size_t bpe = tarray->element_size(); \
uint32_t bytes = count * sizeof(lane_type); \
size_t byte_length = NumberToSize(isolate, tarray->byte_length()); \
if (index < 0 || index * bpe + bytes > byte_length) { \
THROW_NEW_ERROR_RETURN_FAILURE( \
isolate, NewRangeError(MessageTemplate::kInvalidSimdIndex)); \
} \
size_t tarray_offset = NumberToSize(isolate, tarray->byte_offset()); \
uint8_t* tarray_base = \
static_cast<uint8_t*>(tarray->GetBuffer()->backing_store()) + \
tarray_offset; \
lane_type lanes[kLaneCount] = {0}; \
memcpy(lanes, tarray_base + index * bpe, bytes); \
#define SIMD_LOAD(type, lane_type, lane_count, count, result) \
static const int kLaneCount = lane_count; \
DCHECK(args.length() == 2); \
CONVERT_SIMD_ARG_HANDLE_THROW(JSTypedArray, tarray, 0); \
SIMD_COERCE_INDEX(index, 1); \
size_t bpe = tarray->element_size(); \
uint32_t bytes = count * sizeof(lane_type); \
size_t byte_length = NumberToSize(tarray->byte_length()); \
if (index < 0 || index * bpe + bytes > byte_length) { \
THROW_NEW_ERROR_RETURN_FAILURE( \
isolate, NewRangeError(MessageTemplate::kInvalidSimdIndex)); \
} \
size_t tarray_offset = NumberToSize(tarray->byte_offset()); \
uint8_t* tarray_base = \
static_cast<uint8_t*>(tarray->GetBuffer()->backing_store()) + \
tarray_offset; \
lane_type lanes[kLaneCount] = {0}; \
memcpy(lanes, tarray_base + index * bpe, bytes); \
Handle<type> result = isolate->factory()->New##type(lanes);
#define SIMD_STORE(type, lane_type, lane_count, count, a) \
static const int kLaneCount = lane_count; \
DCHECK(args.length() == 3); \
CONVERT_SIMD_ARG_HANDLE_THROW(JSTypedArray, tarray, 0); \
CONVERT_SIMD_ARG_HANDLE_THROW(type, a, 2); \
SIMD_COERCE_INDEX(index, 1); \
size_t bpe = tarray->element_size(); \
uint32_t bytes = count * sizeof(lane_type); \
size_t byte_length = NumberToSize(isolate, tarray->byte_length()); \
if (index < 0 || byte_length < index * bpe + bytes) { \
THROW_NEW_ERROR_RETURN_FAILURE( \
isolate, NewRangeError(MessageTemplate::kInvalidSimdIndex)); \
} \
size_t tarray_offset = NumberToSize(isolate, tarray->byte_offset()); \
uint8_t* tarray_base = \
static_cast<uint8_t*>(tarray->GetBuffer()->backing_store()) + \
tarray_offset; \
lane_type lanes[kLaneCount]; \
for (int i = 0; i < kLaneCount; i++) { \
lanes[i] = a->get_lane(i); \
} \
#define SIMD_STORE(type, lane_type, lane_count, count, a) \
static const int kLaneCount = lane_count; \
DCHECK(args.length() == 3); \
CONVERT_SIMD_ARG_HANDLE_THROW(JSTypedArray, tarray, 0); \
CONVERT_SIMD_ARG_HANDLE_THROW(type, a, 2); \
SIMD_COERCE_INDEX(index, 1); \
size_t bpe = tarray->element_size(); \
uint32_t bytes = count * sizeof(lane_type); \
size_t byte_length = NumberToSize(tarray->byte_length()); \
if (index < 0 || byte_length < index * bpe + bytes) { \
THROW_NEW_ERROR_RETURN_FAILURE( \
isolate, NewRangeError(MessageTemplate::kInvalidSimdIndex)); \
} \
size_t tarray_offset = NumberToSize(tarray->byte_offset()); \
uint8_t* tarray_base = \
static_cast<uint8_t*>(tarray->GetBuffer()->backing_store()) + \
tarray_offset; \
lane_type lanes[kLaneCount]; \
for (int i = 0; i < kLaneCount; i++) { \
lanes[i] = a->get_lane(i); \
} \
memcpy(tarray_base + index * bpe, lanes, bytes);
#define SIMD_LOAD_FUNCTION(type, lane_type, lane_count) \
......
......@@ -399,7 +399,7 @@ RUNTIME_FUNCTION(Runtime_StringBuilderConcat) {
CONVERT_ARG_HANDLE_CHECKED(String, special, 2);
size_t actual_array_length = 0;
CHECK(TryNumberToSize(isolate, array->length(), &actual_array_length));
CHECK(TryNumberToSize(array->length(), &actual_array_length));
CHECK(array_length >= 0);
CHECK(static_cast<size_t>(array_length) <= actual_array_length);
......
......@@ -38,13 +38,13 @@ RUNTIME_FUNCTION(Runtime_ArrayBufferSliceImpl) {
CHECK(!source.is_identical_to(target));
size_t start = 0, target_length = 0;
CHECK(TryNumberToSize(isolate, *first, &start));
CHECK(TryNumberToSize(isolate, *new_length, &target_length));
CHECK(NumberToSize(isolate, target->byte_length()) >= target_length);
CHECK(TryNumberToSize(*first, &start));
CHECK(TryNumberToSize(*new_length, &target_length));
CHECK(NumberToSize(target->byte_length()) >= target_length);
if (target_length == 0) return isolate->heap()->undefined_value();
size_t source_byte_length = NumberToSize(isolate, source->byte_length());
size_t source_byte_length = NumberToSize(source->byte_length());
CHECK(start <= source_byte_length);
CHECK(source_byte_length - start >= target_length);
uint8_t* source_data = reinterpret_cast<uint8_t*>(source->backing_store());
......@@ -66,7 +66,7 @@ RUNTIME_FUNCTION(Runtime_ArrayBufferNeuter) {
CHECK(!array_buffer->is_shared());
DCHECK(!array_buffer->is_external());
void* backing_store = array_buffer->backing_store();
size_t byte_length = NumberToSize(isolate, array_buffer->byte_length());
size_t byte_length = NumberToSize(array_buffer->byte_length());
array_buffer->set_is_external(true);
isolate->heap()->UnregisterArrayBuffer(*array_buffer);
array_buffer->Neuter();
......@@ -117,13 +117,12 @@ RUNTIME_FUNCTION(Runtime_TypedArrayInitialize) {
size_t byte_offset = 0;
size_t byte_length = 0;
CHECK(TryNumberToSize(isolate, *byte_offset_object, &byte_offset));
CHECK(TryNumberToSize(isolate, *byte_length_object, &byte_length));
CHECK(TryNumberToSize(*byte_offset_object, &byte_offset));
CHECK(TryNumberToSize(*byte_length_object, &byte_length));
if (maybe_buffer->IsJSArrayBuffer()) {
Handle<JSArrayBuffer> buffer = Handle<JSArrayBuffer>::cast(maybe_buffer);
size_t array_buffer_byte_length =
NumberToSize(isolate, buffer->byte_length());
size_t array_buffer_byte_length = NumberToSize(buffer->byte_length());
CHECK(byte_offset <= array_buffer_byte_length);
CHECK(array_buffer_byte_length - byte_offset >= byte_length);
} else {
......@@ -204,7 +203,7 @@ RUNTIME_FUNCTION(Runtime_TypedArrayInitializeFromArrayLike) {
length_obj = handle(JSTypedArray::cast(*source)->length(), isolate);
length = JSTypedArray::cast(*source)->length_value();
} else {
CHECK(TryNumberToSize(isolate, *length_obj, &length));
CHECK(TryNumberToSize(*length_obj, &length));
}
if ((length > static_cast<unsigned>(Smi::kMaxValue)) ||
......@@ -261,8 +260,7 @@ RUNTIME_FUNCTION(Runtime_TypedArrayInitializeFromArrayLike) {
if (typed_array->type() == holder->type()) {
uint8_t* backing_store =
static_cast<uint8_t*>(typed_array->GetBuffer()->backing_store());
size_t source_byte_offset =
NumberToSize(isolate, typed_array->byte_offset());
size_t source_byte_offset = NumberToSize(typed_array->byte_offset());
memcpy(buffer->backing_store(), backing_store + source_byte_offset,
byte_length);
return isolate->heap()->true_value();
......@@ -328,19 +326,19 @@ RUNTIME_FUNCTION(Runtime_TypedArraySetFastCases) {
Handle<JSTypedArray> target(JSTypedArray::cast(*target_obj));
Handle<JSTypedArray> source(JSTypedArray::cast(*source_obj));
size_t offset = 0;
CHECK(TryNumberToSize(isolate, *offset_obj, &offset));
CHECK(TryNumberToSize(*offset_obj, &offset));
size_t target_length = target->length_value();
size_t source_length = source->length_value();
size_t target_byte_length = NumberToSize(isolate, target->byte_length());
size_t source_byte_length = NumberToSize(isolate, source->byte_length());
size_t target_byte_length = NumberToSize(target->byte_length());
size_t source_byte_length = NumberToSize(source->byte_length());
if (offset > target_length || offset + source_length > target_length ||
offset + source_length < offset) { // overflow
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewRangeError(MessageTemplate::kTypedArraySetSourceTooLarge));
}
size_t target_offset = NumberToSize(isolate, target->byte_offset());
size_t source_offset = NumberToSize(isolate, source->byte_offset());
size_t target_offset = NumberToSize(target->byte_offset());
size_t source_offset = NumberToSize(source->byte_offset());
uint8_t* target_base =
static_cast<uint8_t*>(target->GetBuffer()->backing_store()) +
target_offset;
......@@ -454,15 +452,13 @@ inline static bool DataViewGetValue(Isolate* isolate,
Handle<Object> byte_offset_obj,
bool is_little_endian, T* result) {
size_t byte_offset = 0;
if (!TryNumberToSize(isolate, *byte_offset_obj, &byte_offset)) {
if (!TryNumberToSize(*byte_offset_obj, &byte_offset)) {
return false;
}
Handle<JSArrayBuffer> buffer(JSArrayBuffer::cast(data_view->buffer()));
size_t data_view_byte_offset =
NumberToSize(isolate, data_view->byte_offset());
size_t data_view_byte_length =
NumberToSize(isolate, data_view->byte_length());
size_t data_view_byte_offset = NumberToSize(data_view->byte_offset());
size_t data_view_byte_length = NumberToSize(data_view->byte_length());
if (byte_offset + sizeof(T) > data_view_byte_length ||
byte_offset + sizeof(T) < byte_offset) { // overflow
return false;
......@@ -475,8 +471,7 @@ inline static bool DataViewGetValue(Isolate* isolate,
Value value;
size_t buffer_offset = data_view_byte_offset + byte_offset;
DCHECK(NumberToSize(isolate, buffer->byte_length()) >=
buffer_offset + sizeof(T));
DCHECK(NumberToSize(buffer->byte_length()) >= buffer_offset + sizeof(T));
uint8_t* source =
static_cast<uint8_t*>(buffer->backing_store()) + buffer_offset;
if (NeedToFlipBytes(is_little_endian)) {
......@@ -494,15 +489,13 @@ static bool DataViewSetValue(Isolate* isolate, Handle<JSDataView> data_view,
Handle<Object> byte_offset_obj,
bool is_little_endian, T data) {
size_t byte_offset = 0;
if (!TryNumberToSize(isolate, *byte_offset_obj, &byte_offset)) {
if (!TryNumberToSize(*byte_offset_obj, &byte_offset)) {
return false;
}
Handle<JSArrayBuffer> buffer(JSArrayBuffer::cast(data_view->buffer()));
size_t data_view_byte_offset =
NumberToSize(isolate, data_view->byte_offset());
size_t data_view_byte_length =
NumberToSize(isolate, data_view->byte_length());
size_t data_view_byte_offset = NumberToSize(data_view->byte_offset());
size_t data_view_byte_length = NumberToSize(data_view->byte_length());
if (byte_offset + sizeof(T) > data_view_byte_length ||
byte_offset + sizeof(T) < byte_offset) { // overflow
return false;
......@@ -516,8 +509,7 @@ static bool DataViewSetValue(Isolate* isolate, Handle<JSDataView> data_view,
Value value;
value.data = data;
size_t buffer_offset = data_view_byte_offset + byte_offset;
DCHECK(NumberToSize(isolate, buffer->byte_length()) >=
buffer_offset + sizeof(T));
DCHECK(NumberToSize(buffer->byte_length()) >= buffer_offset + sizeof(T));
uint8_t* target =
static_cast<uint8_t*>(buffer->backing_store()) + buffer_offset;
if (NeedToFlipBytes(is_little_endian)) {
......
......@@ -51,7 +51,7 @@ namespace internal {
CHECK(args[index]->IsNumber()); \
Handle<Object> name##_object = args.at<Object>(index); \
size_t name = 0; \
CHECK(TryNumberToSize(isolate, *name##_object, &name));
CHECK(TryNumberToSize(*name##_object, &name));
// Call the specified converter on the object *comand store the result in
// a variable of the specified type with the given name. If the
......
......@@ -413,7 +413,7 @@ TEST(NoHandlesForTryNumberToSize) {
{
SealHandleScope no_handles(isolate);
Smi* smi = Smi::FromInt(1);
CHECK(TryNumberToSize(isolate, smi, &result));
CHECK(TryNumberToSize(smi, &result));
CHECK_EQ(result, 1);
}
result = 0;
......@@ -422,14 +422,14 @@ TEST(NoHandlesForTryNumberToSize) {
Handle<HeapNumber> heap_number1 = isolate->factory()->NewHeapNumber(2.0);
{
SealHandleScope no_handles(isolate);
CHECK(TryNumberToSize(isolate, *heap_number1, &result));
CHECK(TryNumberToSize(*heap_number1, &result));
CHECK_EQ(result, 2);
}
Handle<HeapNumber> heap_number2 = isolate->factory()->NewHeapNumber(
static_cast<double>(std::numeric_limits<size_t>::max()) + 10000.0);
{
SealHandleScope no_handles(isolate);
CHECK(!TryNumberToSize(isolate, *heap_number2, &result));
CHECK(!TryNumberToSize(*heap_number2, &result));
}
}
}
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