Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(517)

Unified Diff: runtime/lib/array.cc

Issue 8678025: Fix crashes when going to natives. Throw an exception instead. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/lib/byte_buffer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/array.cc
===================================================================
--- runtime/lib/array.cc (revision 1815)
+++ runtime/lib/array.cc (working copy)
@@ -16,17 +16,10 @@
DEFINE_NATIVE_ENTRY(ObjectArray_allocate, 2) {
const TypeArguments& type_arguments =
TypeArguments::CheckedHandle(arguments->At(0));
- const Instance& length_instance = Instance::CheckedHandle(arguments->At(1));
- if (!length_instance.IsSmi()) {
- GrowableArray<const Object*> args;
- args.Add(&length_instance);
- Exceptions::ThrowByType(Exceptions::kIllegalArgument, args);
- }
- Smi& length = Smi::Handle();
- length ^= length_instance.raw();
ASSERT(type_arguments.IsNull() ||
(type_arguments.IsInstantiated() && (type_arguments.Length() == 1)));
- if (length.IsNull() || (length.Value() < 0)) {
+ GET_NATIVE_ARGUMENT(Smi, length, arguments->At(1));
+ if (length.Value() < 0) {
GrowableArray<const Object*> args;
args.Add(&length);
Exceptions::ThrowByType(Exceptions::kIllegalArgument, args);
@@ -39,19 +32,7 @@
DEFINE_NATIVE_ENTRY(ObjectArray_getIndexed, 2) {
const Array& array = Array::CheckedHandle(arguments->At(0));
- const Instance& index_instance = Instance::CheckedHandle(arguments->At(1));
- if (!index_instance.IsSmi()) {
- GrowableArray<const Object*> args;
- args.Add(&index_instance);
- Exceptions::ThrowByType(Exceptions::kIllegalArgument, args);
- }
- Smi& index = Smi::Handle();
- index ^= index_instance.raw();
- if (array.IsNull() || index.IsNull()) {
- // TODO(asiva): Need to handle error cases.
- UNIMPLEMENTED();
- return;
- }
+ GET_NATIVE_ARGUMENT(Smi, index, arguments->At(1));
if ((index.Value() < 0) || (index.Value() >= array.Length())) {
GrowableArray<const Object*> arguments;
arguments.Add(&index);
@@ -64,20 +45,8 @@
DEFINE_NATIVE_ENTRY(ObjectArray_setIndexed, 3) {
const Array& array = Array::CheckedHandle(arguments->At(0));
- const Instance& index_instance = Instance::CheckedHandle(arguments->At(1));
- if (!index_instance.IsSmi()) {
- GrowableArray<const Object*> args;
- args.Add(&index_instance);
- Exceptions::ThrowByType(Exceptions::kIllegalArgument, args);
- }
- Smi& index = Smi::Handle();
- index ^= index_instance.raw();
+ GET_NATIVE_ARGUMENT(Smi, index, arguments->At(1));
const Instance& value = Instance::CheckedHandle(arguments->At(2));
- if (array.IsNull() || index.IsNull()) {
- // TODO(asiva): Need to handle error cases.
- UNIMPLEMENTED();
- return;
- }
if ((index.Value() < 0) || (index.Value() >= array.Length())) {
GrowableArray<const Object*> arguments;
arguments.Add(&index);
@@ -89,11 +58,6 @@
DEFINE_NATIVE_ENTRY(ObjectArray_getLength, 1) {
const Array& array = Array::CheckedHandle(arguments->At(0));
- if (array.IsNull()) {
- // TODO(asiva): Need to handle error cases.
- UNIMPLEMENTED();
- return;
- }
const Smi& length = Smi::Handle(Smi::New(array.Length()));
arguments->SetReturn(length);
}
@@ -102,15 +66,10 @@
// ObjectArray src, int srcStart, int dstStart, int count.
DEFINE_NATIVE_ENTRY(ObjectArray_copyFromObjectArray, 5) {
const Array& dest = Array::CheckedHandle(arguments->At(0));
- const Array& source = Array::CheckedHandle(arguments->At(1));
- const Smi& src_start = Smi::CheckedHandle(arguments->At(2));
- const Smi& dst_start = Smi::CheckedHandle(arguments->At(3));
- const Smi& count = Smi::CheckedHandle(arguments->At(4));
- if (dest.IsNull() || source.IsNull() || src_start.IsNull() ||
- dst_start.IsNull() || count.IsNull()) {
- GrowableArray<const Object*> args;
- Exceptions::ThrowByType(Exceptions::kIllegalArgument, args);
- }
+ GET_NATIVE_ARGUMENT(Array, source, arguments->At(1));
+ GET_NATIVE_ARGUMENT(Smi, src_start, arguments->At(2));
+ GET_NATIVE_ARGUMENT(Smi, dst_start, arguments->At(3));
+ GET_NATIVE_ARGUMENT(Smi, count, arguments->At(4));
intptr_t icount = count.Value();
if (icount < 0) {
GrowableArray<const Object*> args;
« no previous file with comments | « no previous file | runtime/lib/byte_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698