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

Side by Side Diff: runtime/vm/object.cc

Issue 9549008: Fix Issue 1844: Throw exception instead of crashing if the size of allocated array is too large (or… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/bootstrap.h" 10 #include "vm/bootstrap.h"
(...skipping 7875 matching lines...) Expand 10 before | Expand all | Expand 10 after
7886 7886
7887 RawArray* Array::New(intptr_t len, Heap::Space space) { 7887 RawArray* Array::New(intptr_t len, Heap::Space space) {
7888 ObjectStore* object_store = Isolate::Current()->object_store(); 7888 ObjectStore* object_store = Isolate::Current()->object_store();
7889 Class& cls = Class::Handle(object_store->array_class()); 7889 Class& cls = Class::Handle(object_store->array_class());
7890 return New(cls, len, space); 7890 return New(cls, len, space);
7891 } 7891 }
7892 7892
7893 7893
7894 RawArray* Array::New(const Class& cls, intptr_t len, Heap::Space space) { 7894 RawArray* Array::New(const Class& cls, intptr_t len, Heap::Space space) {
7895 if ((len < 0) || (len > kMaxArrayElements)) { 7895 if ((len < 0) || (len > kMaxArrayElements)) {
7896 // TODO(iposva): Should we throw an illegal parameter exception? 7896 // TODO(srdjan): Verify that illegal argument is the right thing to throw.
7897 UNIMPLEMENTED(); 7897 GrowableArray<const Object*> args;
7898 return null(); 7898 args.Add(&Smi::Handle(Smi::New(len)));
7899 Exceptions::ThrowByType(Exceptions::kIllegalArgument, args);
7899 } 7900 }
7900 Array& result = Array::Handle(); 7901 Array& result = Array::Handle();
7901 { 7902 {
7902 RawObject* raw = Object::Allocate(cls, 7903 RawObject* raw = Object::Allocate(cls,
7903 Array::InstanceSize(len), 7904 Array::InstanceSize(len),
7904 space); 7905 space);
7905 NoGCScope no_gc; 7906 NoGCScope no_gc;
7906 result ^= raw; 7907 result ^= raw;
7907 result.SetLength(len); 7908 result.SetLength(len);
7908 } 7909 }
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
8505 result.set_num_args_tested(num_args_tested); 8506 result.set_num_args_tested(num_args_tested);
8506 // Number of array elements in one test entry (num_args_tested + 1) 8507 // Number of array elements in one test entry (num_args_tested + 1)
8507 intptr_t len = num_args_tested + 1; 8508 intptr_t len = num_args_tested + 1;
8508 // IC data array must be null terminated (sentinel entry). 8509 // IC data array must be null terminated (sentinel entry).
8509 Array& ic_data = Array::Handle(Array::New(len, Heap::kOld)); 8510 Array& ic_data = Array::Handle(Array::New(len, Heap::kOld));
8510 result.set_ic_data(ic_data); 8511 result.set_ic_data(ic_data);
8511 return result.raw(); 8512 return result.raw();
8512 } 8513 }
8513 8514
8514 } // namespace dart 8515 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698