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

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

Issue 70983002: Fixes issue 14742. Dart API may allocate objects without calling the constructor, this messes up th… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "include/dart_mirrors_api.h" 6 #include "include/dart_mirrors_api.h"
7 #include "include/dart_native_api.h" 7 #include "include/dart_native_api.h"
8 8
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "vm/bigint_operations.h" 10 #include "vm/bigint_operations.h"
(...skipping 2942 matching lines...) Expand 10 before | Expand all | Expand 10 after
2953 DARTSCOPE(isolate); 2953 DARTSCOPE(isolate);
2954 CHECK_CALLBACK_STATE(isolate); 2954 CHECK_CALLBACK_STATE(isolate);
2955 2955
2956 const Type& type_obj = Api::UnwrapTypeHandle(isolate, type); 2956 const Type& type_obj = Api::UnwrapTypeHandle(isolate, type);
2957 // Get the class to instantiate. 2957 // Get the class to instantiate.
2958 if (type_obj.IsNull()) { 2958 if (type_obj.IsNull()) {
2959 RETURN_TYPE_ERROR(isolate, type, Type); 2959 RETURN_TYPE_ERROR(isolate, type, Type);
2960 } 2960 }
2961 const Class& cls = Class::Handle(isolate, type_obj.type_class()); 2961 const Class& cls = Class::Handle(isolate, type_obj.type_class());
2962 2962
2963 // Mark all fields as nullable.
2964 Class& iterate_cls = Class::Handle(isolate, cls.raw());
2965 Field& field = Field::Handle(isolate);
2966 Array& fields = Array::Handle(isolate);
2967 while (!iterate_cls.IsNull()) {
2968 fields = iterate_cls.fields();
2969 iterate_cls = iterate_cls.SuperClass();
2970 for (int field_num = 0; field_num < fields.Length(); field_num++) {
2971 field ^= fields.At(field_num);
2972 if (field.is_static()) {
2973 continue;
2974 }
2975 field.UpdateGuardedCidAndLength(Object::null_object());
2976 }
2977 }
2963 // Allocate an object for the given class. 2978 // Allocate an object for the given class.
2964 return Api::NewHandle(isolate, Instance::New(cls)); 2979 return Api::NewHandle(isolate, Instance::New(cls));
2965 } 2980 }
2966 2981
2967 2982
2968 static Dart_Handle SetupArguments(Isolate* isolate, 2983 static Dart_Handle SetupArguments(Isolate* isolate,
2969 int num_args, 2984 int num_args,
2970 Dart_Handle* arguments, 2985 Dart_Handle* arguments,
2971 int extra_args, 2986 int extra_args,
2972 Array* args) { 2987 Array* args) {
(...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after
4428 } 4443 }
4429 { 4444 {
4430 NoGCScope no_gc; 4445 NoGCScope no_gc;
4431 RawObject* raw_obj = obj.raw(); 4446 RawObject* raw_obj = obj.raw();
4432 isolate->heap()->SetPeer(raw_obj, peer); 4447 isolate->heap()->SetPeer(raw_obj, peer);
4433 } 4448 }
4434 return Api::Success(); 4449 return Api::Success();
4435 } 4450 }
4436 4451
4437 } // namespace dart 4452 } // 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