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

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

Issue 174393004: Add Dart_GetNativeFieldsOfArgument to get all the native fields of a dart (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 10 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
« runtime/include/dart_api.h ('K') | « runtime/vm/dart_api_impl_test.cc ('k') | 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 #ifndef VM_OBJECT_H_ 5 #ifndef VM_OBJECT_H_
6 #define VM_OBJECT_H_ 6 #define VM_OBJECT_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/utils.h" 10 #include "platform/utils.h"
(...skipping 3969 matching lines...) Expand 10 before | Expand all | Expand 10 after
3980 Error* bound_error) const; 3980 Error* bound_error) const;
3981 3981
3982 // Check whether this instance is identical to the argument according to the 3982 // Check whether this instance is identical to the argument according to the
3983 // specification of dare:core's identical(). 3983 // specification of dare:core's identical().
3984 bool IsIdenticalTo(const Instance& other) const; 3984 bool IsIdenticalTo(const Instance& other) const;
3985 3985
3986 bool IsValidNativeIndex(int index) const { 3986 bool IsValidNativeIndex(int index) const {
3987 return ((index >= 0) && (index < clazz()->ptr()->num_native_fields_)); 3987 return ((index >= 0) && (index < clazz()->ptr()->num_native_fields_));
3988 } 3988 }
3989 3989
3990 inline intptr_t GetNativeField(Isolate* isolate, int index) const; 3990 inline intptr_t GetNativeField(int index) const;
3991 inline void GetNativeFields(uint16_t num_fields,
3992 intptr_t* field_values) const;
3993
3994 uint16_t NumNativeFields() const {
3995 return clazz()->ptr()->num_native_fields_;
3996 }
3997
3991 void SetNativeField(int index, intptr_t value) const; 3998 void SetNativeField(int index, intptr_t value) const;
3992 3999
3993 // Returns true if the instance is a closure object. 4000 // Returns true if the instance is a closure object.
3994 bool IsClosure() const; 4001 bool IsClosure() const;
3995 4002
3996 // If the instance is a callable object, i.e. a closure or the instance of a 4003 // If the instance is a callable object, i.e. a closure or the instance of a
3997 // class implementing a 'call' method, return true and set the function 4004 // class implementing a 'call' method, return true and set the function
3998 // (if not NULL) to call and the context (if not NULL) to pass to the 4005 // (if not NULL) to call and the context (if not NULL) to pass to the
3999 // function. 4006 // function.
4000 bool IsCallable(Function* function, Context* context) const; 4007 bool IsCallable(Function* function, Context* context) const;
(...skipping 2565 matching lines...) Expand 10 before | Expand all | Expand 10 after
6566 ASSERT(kWordSize != 0); 6573 ASSERT(kWordSize != 0);
6567 raw_ptr()->value_ = Smi::New(value_in_bytes / kWordSize); 6574 raw_ptr()->value_ = Smi::New(value_in_bytes / kWordSize);
6568 } 6575 }
6569 6576
6570 6577
6571 void Context::SetAt(intptr_t index, const Instance& value) const { 6578 void Context::SetAt(intptr_t index, const Instance& value) const {
6572 StorePointer(InstanceAddr(index), value.raw()); 6579 StorePointer(InstanceAddr(index), value.raw());
6573 } 6580 }
6574 6581
6575 6582
6576 intptr_t Instance::GetNativeField(Isolate* isolate, int index) const { 6583 intptr_t Instance::GetNativeField(int index) const {
6577 ASSERT(IsValidNativeIndex(index)); 6584 ASSERT(IsValidNativeIndex(index));
6578 NoGCScope no_gc; 6585 NoGCScope no_gc;
6579 RawTypedData* native_fields = 6586 RawTypedData* native_fields =
6580 reinterpret_cast<RawTypedData*>(*NativeFieldsAddr()); 6587 reinterpret_cast<RawTypedData*>(*NativeFieldsAddr());
6581 if (native_fields == TypedData::null()) { 6588 if (native_fields == TypedData::null()) {
6582 return 0; 6589 return 0;
6583 } 6590 }
6584 return reinterpret_cast<intptr_t*>(native_fields->ptr()->data_)[index]; 6591 return reinterpret_cast<intptr_t*>(native_fields->ptr()->data_)[index];
6585 } 6592 }
6586 6593
6587 6594
6595 void Instance::GetNativeFields(uint16_t num_fields,
6596 intptr_t* field_values) const {
6597 NoGCScope no_gc;
6598 ASSERT(num_fields == NumNativeFields());
6599 ASSERT(field_values != NULL);
6600 RawTypedData* native_fields =
6601 reinterpret_cast<RawTypedData*>(*NativeFieldsAddr());
6602 if (native_fields == TypedData::null()) {
6603 for (intptr_t i = 0; i < num_fields; i++) {
6604 field_values[i] = 0;
6605 }
6606 }
6607 intptr_t* fields = reinterpret_cast<intptr_t*>(native_fields->ptr()->data_);
6608 for (intptr_t i = 0; i < num_fields; i++) {
6609 field_values[i] = fields[i];
6610 }
6611 }
6612
6613
6588 bool String::Equals(const String& str) const { 6614 bool String::Equals(const String& str) const {
6589 if (raw() == str.raw()) { 6615 if (raw() == str.raw()) {
6590 return true; // Both handles point to the same raw instance. 6616 return true; // Both handles point to the same raw instance.
6591 } 6617 }
6592 if (str.IsNull()) { 6618 if (str.IsNull()) {
6593 return false; 6619 return false;
6594 } 6620 }
6595 return Equals(str, 0, str.Length()); 6621 return Equals(str, 0, str.Length());
6596 } 6622 }
6597 6623
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
6630 6656
6631 6657
6632 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 6658 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
6633 intptr_t index) { 6659 intptr_t index) {
6634 return array.At((index * kEntryLength) + kTargetFunctionIndex); 6660 return array.At((index * kEntryLength) + kTargetFunctionIndex);
6635 } 6661 }
6636 6662
6637 } // namespace dart 6663 } // namespace dart
6638 6664
6639 #endif // VM_OBJECT_H_ 6665 #endif // VM_OBJECT_H_
OLDNEW
« runtime/include/dart_api.h ('K') | « runtime/vm/dart_api_impl_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698