Commit ef950973 authored by kbr@chromium.org's avatar kbr@chromium.org

Stop throwing exceptions for out-of-range accesses to CanvasArrays.

This is per resolution in the WebGL working group to make these types
match the WebIDL IndexSetter and IndexGetter semantics, which are
still being defined but will very likely not throw.

Review URL: http://codereview.chromium.org/328007

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3117 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 6f1d641f
......@@ -363,14 +363,6 @@ Handle<Object> Factory::NewRangeError(Handle<String> message) {
}
Handle<Object> Factory::NewIndexError(uint32_t index) {
Handle<Object> indexHandle = Handle<Object>(Heap::NumberFromUint32(index));
return NewRangeError("invalid_array_index",
HandleVector<Object>(&indexHandle,
1));
}
Handle<Object> Factory::NewSyntaxError(const char* type, Handle<JSArray> args) {
return NewError("MakeSyntaxError", type, args);
}
......
......@@ -252,8 +252,6 @@ class Factory : public AllStatic {
Vector< Handle<Object> > args);
static Handle<Object> NewRangeError(Handle<String> message);
static Handle<Object> NewIndexError(uint32_t index);
static Handle<Object> NewSyntaxError(const char* type, Handle<JSArray> args);
static Handle<Object> NewSyntaxError(Handle<String> message);
......
......@@ -159,7 +159,6 @@ function FormatMessage(message) {
reduce_no_initial: "Reduce of empty array with no initial value",
// RangeError
invalid_array_length: "Invalid array length",
invalid_array_index: "Invalid array index %0", // Currently for CanvasArray types only
stack_overflow: "Maximum call stack size exceeded",
apply_overflow: "Function.prototype.apply cannot support %0 arguments",
// SyntaxError
......
......@@ -6050,7 +6050,7 @@ Object* JSObject::GetElementWithReceiver(JSObject* receiver, uint32_t index) {
int8_t value = array->get(index);
return Smi::FromInt(value);
}
return Top::Throw(*Factory::NewIndexError(index));
break;
}
case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: {
ExternalUnsignedByteArray* array =
......@@ -6059,7 +6059,7 @@ Object* JSObject::GetElementWithReceiver(JSObject* receiver, uint32_t index) {
uint8_t value = array->get(index);
return Smi::FromInt(value);
}
return Top::Throw(*Factory::NewIndexError(index));
break;
}
case EXTERNAL_SHORT_ELEMENTS: {
ExternalShortArray* array = ExternalShortArray::cast(elements());
......@@ -6067,7 +6067,7 @@ Object* JSObject::GetElementWithReceiver(JSObject* receiver, uint32_t index) {
int16_t value = array->get(index);
return Smi::FromInt(value);
}
return Top::Throw(*Factory::NewIndexError(index));
break;
}
case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: {
ExternalUnsignedShortArray* array =
......@@ -6076,7 +6076,7 @@ Object* JSObject::GetElementWithReceiver(JSObject* receiver, uint32_t index) {
uint16_t value = array->get(index);
return Smi::FromInt(value);
}
return Top::Throw(*Factory::NewIndexError(index));
break;
}
case EXTERNAL_INT_ELEMENTS: {
ExternalIntArray* array = ExternalIntArray::cast(elements());
......@@ -6084,7 +6084,7 @@ Object* JSObject::GetElementWithReceiver(JSObject* receiver, uint32_t index) {
int32_t value = array->get(index);
return Heap::NumberFromInt32(value);
}
return Top::Throw(*Factory::NewIndexError(index));
break;
}
case EXTERNAL_UNSIGNED_INT_ELEMENTS: {
ExternalUnsignedIntArray* array =
......@@ -6093,7 +6093,7 @@ Object* JSObject::GetElementWithReceiver(JSObject* receiver, uint32_t index) {
uint32_t value = array->get(index);
return Heap::NumberFromUint32(value);
}
return Top::Throw(*Factory::NewIndexError(index));
break;
}
case EXTERNAL_FLOAT_ELEMENTS: {
ExternalFloatArray* array = ExternalFloatArray::cast(elements());
......@@ -6101,7 +6101,7 @@ Object* JSObject::GetElementWithReceiver(JSObject* receiver, uint32_t index) {
float value = array->get(index);
return Heap::AllocateHeapNumber(value);
}
return Top::Throw(*Factory::NewIndexError(index));
break;
}
case DICTIONARY_ELEMENTS: {
NumberDictionary* dictionary = element_dictionary();
......@@ -7320,8 +7320,6 @@ static Object* ExternalArrayIntSetter(ExternalArrayClass* receiver,
ASSERT(value->IsUndefined());
}
receiver->set(index, cast_value);
} else {
return Top::Throw(*Factory::NewIndexError(index));
}
return Heap::NumberFromInt32(cast_value);
}
......@@ -7372,8 +7370,6 @@ Object* ExternalUnsignedIntArray::SetValue(uint32_t index, Object* value) {
ASSERT(value->IsUndefined());
}
set(index, cast_value);
} else {
return Top::Throw(*Factory::NewIndexError(index));
}
return Heap::NumberFromUint32(cast_value);
}
......@@ -7394,8 +7390,6 @@ Object* ExternalFloatArray::SetValue(uint32_t index, Object* value) {
ASSERT(value->IsUndefined());
}
set(index, cast_value);
} else {
return Top::Throw(*Factory::NewIndexError(index));
}
return Heap::AllocateHeapNumber(cast_value);
}
......
......@@ -8196,7 +8196,7 @@ static void ExternalArrayTestHelper(v8::ExternalArrayType array_type,
i::Heap::CollectAllGarbage(false); // Force GC to trigger verification.
CHECK_EQ(28, result->Int32Value());
// Check out-of-range loads.
// Make sure out-of-range loads do not throw.
i::OS::SNPrintF(test_buf,
"var caught_exception = false;"
"try {"
......@@ -8207,9 +8207,9 @@ static void ExternalArrayTestHelper(v8::ExternalArrayType array_type,
"caught_exception;",
kElementCount);
result = CompileRun(test_buf.start());
CHECK_EQ(true, result->BooleanValue());
CHECK_EQ(false, result->BooleanValue());
// Check out-of-range stores.
// Make sure out-of-range stores do not throw.
i::OS::SNPrintF(test_buf,
"var caught_exception = false;"
"try {"
......@@ -8220,7 +8220,7 @@ static void ExternalArrayTestHelper(v8::ExternalArrayType array_type,
"caught_exception;",
kElementCount);
result = CompileRun(test_buf.start());
CHECK_EQ(true, result->BooleanValue());
CHECK_EQ(false, result->BooleanValue());
// Check other boundary conditions, values and operations.
result = CompileRun("for (var i = 0; i < 8; i++) {"
......
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