blob: 63f5b163f7547345c059eb81cf16a9e6de4933c3 [file] [log] [blame]
Carl Shapiro1fb86202011-06-27 17:43:13 -07001// Copyright 2011 Google Inc. All Rights Reserved.
2
3#ifndef ART_SRC_OBJECT_H_
4#define ART_SRC_OBJECT_H_
5
Brian Carlstrom578bbdc2011-07-21 14:07:47 -07006#include "constants.h"
7#include "casts.h"
Shih-wei Liao2fb97532011-08-11 16:17:23 -07008#include "dex_file.h"
Brian Carlstrom578bbdc2011-07-21 14:07:47 -07009#include "globals.h"
Brian Carlstroma40f9bc2011-07-26 21:26:07 -070010#include "heap.h"
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070011#include "logging.h"
12#include "macros.h"
13#include "offsets.h"
14#include "stringpiece.h"
15#include "monitor.h"
Carl Shapiro1fb86202011-06-27 17:43:13 -070016
17namespace art {
18
19class Array;
20class Class;
Brian Carlstrom7e49dca2011-07-22 18:07:34 -070021class DexCache;
Jesse Wilson35baaab2011-08-10 16:18:03 -040022class Field;
Carl Shapiro1fb86202011-06-27 17:43:13 -070023class InterfaceEntry;
24class Monitor;
25class Method;
Carl Shapiro3ee755d2011-06-28 12:11:04 -070026class Object;
Jesse Wilson46cdd4b2011-07-28 17:40:48 -040027class String;
Brian Carlstrom4a96b602011-07-26 16:40:23 -070028template<class T> class ObjectArray;
Jesse Wilsonfd687c52011-08-04 19:27:35 -070029template<class T> class PrimitiveArray;
Jesse Wilsonfd687c52011-08-04 19:27:35 -070030typedef PrimitiveArray<uint16_t> CharArray;
31typedef PrimitiveArray<uint32_t> IntArray;
32typedef PrimitiveArray<uint64_t> LongArray;
Carl Shapiro1fb86202011-06-27 17:43:13 -070033
Carl Shapiro3ee755d2011-06-28 12:11:04 -070034union JValue {
35 uint8_t z;
36 int8_t b;
37 uint16_t c;
38 int16_t s;
39 int32_t i;
40 int64_t j;
41 float f;
42 double d;
43 Object* l;
44};
45
Brian Carlstrombe977852011-07-19 14:54:54 -070046static const uint32_t kAccPublic = 0x0001; // class, field, method, ic
47static const uint32_t kAccPrivate = 0x0002; // field, method, ic
48static const uint32_t kAccProtected = 0x0004; // field, method, ic
49static const uint32_t kAccStatic = 0x0008; // field, method, ic
50static const uint32_t kAccFinal = 0x0010; // class, field, method, ic
51static const uint32_t kAccSynchronized = 0x0020; // method (only allowed on natives)
52static const uint32_t kAccSuper = 0x0020; // class (not used in Dalvik)
53static const uint32_t kAccVolatile = 0x0040; // field
54static const uint32_t kAccBridge = 0x0040; // method (1.5)
55static const uint32_t kAccTransient = 0x0080; // field
56static const uint32_t kAccVarargs = 0x0080; // method (1.5)
57static const uint32_t kAccNative = 0x0100; // method
58static const uint32_t kAccInterface = 0x0200; // class, ic
59static const uint32_t kAccAbstract = 0x0400; // class, method, ic
60static const uint32_t kAccStrict = 0x0800; // method
61static const uint32_t kAccSynthetic = 0x1000; // field, method, ic
62static const uint32_t kAccAnnotation = 0x2000; // class, ic (1.5)
63static const uint32_t kAccEnum = 0x4000; // class, field, ic (1.5)
Carl Shapiro3ee755d2011-06-28 12:11:04 -070064
Carl Shapiro0e5d75d2011-07-06 18:28:37 -070065static const uint32_t kAccMiranda = 0x8000; // method
66
Brian Carlstroma331b3c2011-07-18 17:47:56 -070067static const uint32_t kAccJavaFlagsMask = 0xffff; // bits set from Java sources (low 16)
68
Brian Carlstrombe977852011-07-19 14:54:54 -070069static const uint32_t kAccConstructor = 0x00010000; // method (Dalvik only)
70static const uint32_t kAccDeclaredSynchronized = 0x00020000; // method (Dalvik only)
Carl Shapiro3ee755d2011-06-28 12:11:04 -070071
Carl Shapiro0e5d75d2011-07-06 18:28:37 -070072/*
Brian Carlstroma331b3c2011-07-18 17:47:56 -070073 * Definitions for packing refOffsets in Class.
Carl Shapiro0e5d75d2011-07-06 18:28:37 -070074 */
75/*
76 * A magic value for refOffsets. Ignore the bits and walk the super
77 * chain when this is the value.
78 * [This is an unlikely "natural" value, since it would be 30 non-ref instance
79 * fields followed by 2 ref instance fields.]
80 */
81#define CLASS_WALK_SUPER ((unsigned int)(3))
82#define CLASS_SMALLEST_OFFSET (sizeof(struct Object))
83#define CLASS_BITS_PER_WORD (sizeof(unsigned long int) * 8)
84#define CLASS_OFFSET_ALIGNMENT 4
85#define CLASS_HIGH_BIT ((unsigned int)1 << (CLASS_BITS_PER_WORD - 1))
86/*
87 * Given an offset, return the bit number which would encode that offset.
88 * Local use only.
89 */
90#define _CLASS_BIT_NUMBER_FROM_OFFSET(byteOffset) \
91 (((unsigned int)(byteOffset) - CLASS_SMALLEST_OFFSET) / \
92 CLASS_OFFSET_ALIGNMENT)
93/*
94 * Is the given offset too large to be encoded?
95 */
96#define CLASS_CAN_ENCODE_OFFSET(byteOffset) \
97 (_CLASS_BIT_NUMBER_FROM_OFFSET(byteOffset) < CLASS_BITS_PER_WORD)
98/*
99 * Return a single bit, encoding the offset.
100 * Undefined if the offset is too large, as defined above.
101 */
102#define CLASS_BIT_FROM_OFFSET(byteOffset) \
103 (CLASS_HIGH_BIT >> _CLASS_BIT_NUMBER_FROM_OFFSET(byteOffset))
104/*
105 * Return an offset, given a bit number as returned from CLZ.
106 */
107#define CLASS_OFFSET_FROM_CLZ(rshift) \
Ian Rogersb033c752011-07-20 12:22:35 -0700108 ((static_cast<int>(rshift) * CLASS_OFFSET_ALIGNMENT) + CLASS_SMALLEST_OFFSET)
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700109
110
Carl Shapiro1fb86202011-06-27 17:43:13 -0700111class Object {
Carl Shapiro3ee755d2011-06-28 12:11:04 -0700112 public:
Brian Carlstromf7ed11a2011-08-09 17:55:51 -0700113 static bool InstanceOf(const Object* object, const Class* klass) {
114 if (object == NULL) {
115 return false;
116 }
117 return object->InstanceOf(klass);
118 }
Brian Carlstroma40f9bc2011-07-26 21:26:07 -0700119
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700120 Class* GetClass() const {
121 return klass_;
122 }
123
Brian Carlstromf7ed11a2011-08-09 17:55:51 -0700124 bool InstanceOf(const Class* klass) const;
125
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700126 void MonitorEnter() {
127 monitor_->Enter();
128 }
129
130 void MonitorExit() {
131 monitor_->Exit();
132 }
133
134 void Notify() {
135 monitor_->Notify();
136 }
137
138 void NotifyAll() {
139 monitor_->NotifyAll();
140 }
141
142 void Wait() {
143 monitor_->Wait();
144 }
145
146 void Wait(int64_t timeout) {
147 monitor_->Wait(timeout);
148 }
149
150 void Wait(int64_t timeout, int32_t nanos) {
151 monitor_->Wait(timeout, nanos);
152 }
153
Carl Shapiro69759ea2011-07-21 18:13:35 -0700154 const Object* GetFieldObject(size_t field_offset) const {
155 const byte* raw_addr = reinterpret_cast<const byte*>(this) + field_offset;
156 return *reinterpret_cast<Object* const*>(raw_addr);
157 }
158
159 Object* GetFieldObject(size_t field_offset) {
160 return const_cast<Object*>(GetFieldObject(field_offset));
161 }
162
163 void SetFieldObject(size_t offset, Object* new_value) {
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700164 byte* raw_addr = reinterpret_cast<byte*>(this) + offset;
165 *reinterpret_cast<Object**>(raw_addr) = new_value;
166 // TODO: write barrier
167 }
168
Carl Shapiro69759ea2011-07-21 18:13:35 -0700169 bool IsClass() const {
170 LOG(FATAL) << "Unimplemented";
171 return true;
172 }
173
174 Class* AsClass() {
175 return down_cast<Class*>(this);
176 }
177
178 const Class* AsClass() const {
179 return down_cast<const Class*>(this);
180 }
181
182 bool IsObjectArray() const {
183 LOG(FATAL) << "Unimplemented";
184 return true;
185 }
186
Brian Carlstrom4a96b602011-07-26 16:40:23 -0700187 const ObjectArray<Object>* AsObjectArray() const {
188 return down_cast<const ObjectArray<Object>*>(this);
Carl Shapiro69759ea2011-07-21 18:13:35 -0700189 }
190
191 bool IsReference() const {
192 LOG(FATAL) << "Unimplemented";
193 return true;
194 }
195
196 bool IsWeakReference() const {
197 LOG(FATAL) << "Unimplemented";
198 return true;
199 }
200
201 bool IsSoftReference() const {
202 LOG(FATAL) << "Unimplemented";
203 return true;
204 }
205
206 bool IsFinalizerReference() const {
207 LOG(FATAL) << "Unimplemented";
208 return true;
209 }
210
211 bool IsPhantomReference() const {
212 LOG(FATAL) << "Unimplemented";
213 return true;
214 }
215
216 bool IsArray() const {
217 LOG(FATAL) << "Unimplemented";
218 return true;
219 }
220
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700221 public:
Carl Shapiro1fb86202011-06-27 17:43:13 -0700222 Class* klass_;
Carl Shapiro69759ea2011-07-21 18:13:35 -0700223
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700224 Monitor* monitor_;
225
226 private:
Carl Shapirof88c9522011-08-06 15:47:38 -0700227 DISALLOW_IMPLICIT_CONSTRUCTORS(Object);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700228};
229
230class ObjectLock {
231 public:
Ian Rogersb033c752011-07-20 12:22:35 -0700232 explicit ObjectLock(Object* object) : obj_(object) {
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700233 CHECK(object != NULL);
234 obj_->MonitorEnter();
235 }
236
237 ~ObjectLock() {
238 obj_->MonitorExit();
239 }
240
241 void Wait(int64_t millis = 0) {
242 return obj_->Wait(millis);
243 }
244
245 void Notify() {
246 obj_->Notify();
247 }
248
249 void NotifyAll() {
250 obj_->NotifyAll();
251 }
252
253 private:
254 Object* obj_;
255 DISALLOW_COPY_AND_ASSIGN(ObjectLock);
Carl Shapiro1fb86202011-06-27 17:43:13 -0700256};
257
Jesse Wilson46cdd4b2011-07-28 17:40:48 -0400258class AccessibleObject : public Object {
259 private:
260 // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses".
261 uint32_t java_flag_;
262};
263
264class Field : public AccessibleObject {
Carl Shapiro3ee755d2011-06-28 12:11:04 -0700265 public:
Brian Carlstroma0808032011-07-18 00:39:23 -0700266 Class* GetDeclaringClass() const {
267 return declaring_class_;
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700268 }
269
Jesse Wilson14150742011-07-29 19:04:44 -0400270 const String* GetName() const {
Jesse Wilsonfd687c52011-08-04 19:27:35 -0700271 return name_;
272 }
273
274 bool IsStatic() const {
275 return (access_flags_ & kAccStatic) != 0;
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700276 }
277
278 char GetType() const { // TODO: return type
Brian Carlstrom74eb46a2011-08-02 20:10:14 -0700279 return GetDescriptor()[0];
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700280 }
281
Brian Carlstromae3ac012011-07-27 01:30:28 -0700282 const StringPiece& GetDescriptor() const {
Brian Carlstrom74eb46a2011-08-02 20:10:14 -0700283 DCHECK_NE(0, descriptor_.size());
Brian Carlstromae3ac012011-07-27 01:30:28 -0700284 return descriptor_;
Carl Shapiro5fafe2b2011-07-09 15:34:41 -0700285 }
286
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700287 uint32_t GetOffset() const {
288 return offset_;
289 }
290
291 void SetOffset(size_t num_bytes) {
292 offset_ = num_bytes;
293 }
294
Jesse Wilson35baaab2011-08-10 16:18:03 -0400295 // static field access
Jesse Wilson7833bd22011-08-09 18:31:44 -0400296 bool GetBoolean();
Jesse Wilson7833bd22011-08-09 18:31:44 -0400297 void SetBoolean(bool z);
Jesse Wilson7833bd22011-08-09 18:31:44 -0400298 int8_t GetByte();
Jesse Wilson7833bd22011-08-09 18:31:44 -0400299 void SetByte(int8_t b);
Jesse Wilson7833bd22011-08-09 18:31:44 -0400300 uint16_t GetChar();
Jesse Wilson7833bd22011-08-09 18:31:44 -0400301 void SetChar(uint16_t c);
Jesse Wilson7833bd22011-08-09 18:31:44 -0400302 uint16_t GetShort();
Jesse Wilson7833bd22011-08-09 18:31:44 -0400303 void SetShort(uint16_t s);
Jesse Wilson7833bd22011-08-09 18:31:44 -0400304 int32_t GetInt();
Jesse Wilson7833bd22011-08-09 18:31:44 -0400305 void SetInt(int32_t i);
Jesse Wilson7833bd22011-08-09 18:31:44 -0400306 int64_t GetLong();
Jesse Wilson7833bd22011-08-09 18:31:44 -0400307 void SetLong(int64_t j);
Jesse Wilson7833bd22011-08-09 18:31:44 -0400308 float GetFloat();
Jesse Wilson7833bd22011-08-09 18:31:44 -0400309 void SetFloat(float f);
Jesse Wilson7833bd22011-08-09 18:31:44 -0400310 double GetDouble();
Jesse Wilson7833bd22011-08-09 18:31:44 -0400311 void SetDouble(double d);
Jesse Wilson7833bd22011-08-09 18:31:44 -0400312 Object* GetObject();
Jesse Wilson7833bd22011-08-09 18:31:44 -0400313 const Object* GetObject() const;
Jesse Wilson7833bd22011-08-09 18:31:44 -0400314 void SetObject(Object* l);
Carl Shapiro5fafe2b2011-07-09 15:34:41 -0700315
Jesse Wilson35baaab2011-08-10 16:18:03 -0400316 public: // TODO: private
317 // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses".
318 // The class in which this field is declared.
319 Class* declaring_class_;
320 Object* generic_type_;
321 uint32_t generic_types_are_initialized_;
322 String* name_;
323 uint32_t offset_;
324 Class* type_;
325
326 // e.g. "I", "[C", "Landroid/os/Debug;"
327 StringPiece descriptor_;
328
329 uint32_t access_flags_;
330
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700331 private:
Jesse Wilson35baaab2011-08-10 16:18:03 -0400332 DISALLOW_IMPLICIT_CONSTRUCTORS(Field);
Carl Shapiro1fb86202011-06-27 17:43:13 -0700333};
334
Jesse Wilson46cdd4b2011-07-28 17:40:48 -0400335class Method : public AccessibleObject {
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700336 public:
Brian Carlstromae3ac012011-07-27 01:30:28 -0700337 // Returns the method name, e.g. "<init>" or "eatLunch"
Jesse Wilsonf7e85a52011-08-01 18:45:58 -0700338 const String* GetName() const {
Jesse Wilsonfd687c52011-08-04 19:27:35 -0700339 return name_;
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700340 }
341
Carl Shapiro419ec7b2011-08-03 14:48:33 -0700342 const String* GetDescriptor() const {
343 return descriptor_;
344 }
345
Brian Carlstroma0808032011-07-18 00:39:23 -0700346 Class* GetDeclaringClass() const {
347 return declaring_class_;
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700348 }
349
Ian Rogersb033c752011-07-20 12:22:35 -0700350 static MemberOffset ClassOffset() {
351 return MemberOffset(OFFSETOF_MEMBER(Method, klass_));
352 }
353
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700354 // Returns true if the method is declared public.
355 bool IsPublic() const {
356 return (access_flags_ & kAccPublic) != 0;
357 }
358
359 // Returns true if the method is declared private.
360 bool IsPrivate() const {
361 return (access_flags_ & kAccPrivate) != 0;
362 }
363
364 // Returns true if the method is declared static.
365 bool IsStatic() const {
366 return (access_flags_ & kAccStatic) != 0;
367 }
368
369 // Returns true if the method is declared synchronized.
370 bool IsSynchronized() const {
371 uint32_t synchonized = kAccSynchronized | kAccDeclaredSynchronized;
372 return (access_flags_ & synchonized) != 0;
373 }
374
375 // Returns true if the method is declared final.
376 bool IsFinal() const {
377 return (access_flags_ & kAccFinal) != 0;
378 }
379
380 // Returns true if the method is declared native.
381 bool IsNative() const {
382 return (access_flags_ & kAccNative) != 0;
383 }
384
385 // Returns true if the method is declared abstract.
386 bool IsAbstract() const {
387 return (access_flags_ & kAccAbstract) != 0;
388 }
389
390 bool IsSynthetic() const {
391 return (access_flags_ & kAccSynthetic) != 0;
392 }
393
394 // Number of argument registers required by the prototype.
395 uint32_t NumArgRegisters();
396
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700397 public: // TODO: private
Jesse Wilson46cdd4b2011-07-28 17:40:48 -0400398 // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses".
Jesse Wilson35baaab2011-08-10 16:18:03 -0400399 // the class we are a part of
400 Class* declaring_class_;
Jesse Wilson46cdd4b2011-07-28 17:40:48 -0400401 ObjectArray<Class>* java_exception_types_;
402 Object* java_formal_type_parameters_;
403 Object* java_generic_exception_types_;
404 Object* java_generic_parameter_types_;
405 Object* java_generic_return_type_;
406 Class* java_return_type_;
Jesse Wilsonfd687c52011-08-04 19:27:35 -0700407 String* name_;
Jesse Wilson46cdd4b2011-07-28 17:40:48 -0400408 ObjectArray<Class>* java_parameter_types_;
409 uint32_t java_generic_types_are_initialized_;
410 uint32_t java_slot_;
Brian Carlstroma7f4f482011-07-17 17:01:34 -0700411
Ian Rogersb033c752011-07-20 12:22:35 -0700412 bool IsReturnAReference() const {
413 return (shorty_[0] == 'L') || (shorty_[0] == '[');
414 }
415
416 bool IsReturnAFloatOrDouble() const {
417 return (shorty_[0] == 'F') || (shorty_[0] == 'D');
418 }
419
420 bool IsReturnAFloat() const {
421 return shorty_[0] == 'F';
422 }
423
424 bool IsReturnADouble() const {
425 return shorty_[0] == 'D';
426 }
427
428 bool IsReturnALong() const {
429 return shorty_[0] == 'J';
430 }
431
Ian Rogers45a76cb2011-07-21 22:00:15 -0700432 bool IsReturnVoid() const {
433 return shorty_[0] == 'V';
434 }
435
Ian Rogersb033c752011-07-20 12:22:35 -0700436 // The number of arguments that should be supplied to this method
437 size_t NumArgs() const {
438 return (IsStatic() ? 0 : 1) + shorty_.length() - 1;
439 }
440
441 // The number of reference arguments to this method including implicit this
442 // pointer
443 size_t NumReferenceArgs() const;
444
445 // The number of long or double arguments
446 size_t NumLongOrDoubleArgs() const;
447
448 // The number of reference arguments to this method before the given
449 // parameter index
450 size_t NumReferenceArgsBefore(unsigned int param) const;
451
452 // Is the given method parameter a reference?
453 bool IsParamAReference(unsigned int param) const;
454
455 // Is the given method parameter a long or double?
456 bool IsParamALongOrDouble(unsigned int param) const;
457
Ian Rogersdf20fe02011-07-20 20:34:16 -0700458 // Size in bytes of the given parameter
459 size_t ParamSize(unsigned int param) const;
460
461 // Size in bytes of the return value
462 size_t ReturnSize() const;
Ian Rogersb033c752011-07-20 12:22:35 -0700463
464 void SetCode(const void* code) {
465 code_ = code;
466 }
467
468 const void* GetCode() const {
469 return code_;
470 }
471
472 void RegisterNative(const void* native_method) {
473 native_method_ = native_method;
474 }
475
476 static MemberOffset NativeMethodOffset() {
477 return MemberOffset(OFFSETOF_MEMBER(Method, native_method_));
478 }
479
Carl Shapiro8860c0e2011-08-04 17:36:16 -0700480 bool HasSameNameAndDescriptor(const Method* that) const;
481
Ian Rogersb033c752011-07-20 12:22:35 -0700482 public: // TODO: private/const
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700483 // access flags; low 16 bits are defined by spec (could be uint16_t?)
484 uint32_t access_flags_;
485
486 // For concrete virtual methods, this is the offset of the method
487 // in "vtable".
488 //
489 // For abstract methods in an interface class, this is the offset
490 // of the method in "iftable[n]->methodIndexArray".
491 uint16_t method_index_;
492
493 // Method bounds; not needed for an abstract method.
494 //
495 // For a native method, we compute the size of the argument list, and
496 // set "insSize" and "registerSize" equal to it.
497 uint16_t num_registers_; // ins + locals
498 uint16_t num_outs_;
499 uint16_t num_ins_;
500
Carl Shapiro419ec7b2011-08-03 14:48:33 -0700501 // The method descriptor. This represents the parameters a method
502 // takes and value it returns. This string is a list of the type
503 // descriptors for the parameters enclosed in parenthesis followed
504 // by the return type descriptor. For example, for the method
505 //
506 // Object mymethod(int i, double d, Thread t)
507 //
508 // the method descriptor would be
509 //
510 // (IDLjava/lang/Thread;)Ljava/lang/Object;
511 String* descriptor_;
512
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700513 // Method prototype descriptor string (return and argument types).
514 uint32_t proto_idx_;
515
Shih-wei Liao2fb97532011-08-11 16:17:23 -0700516 // Offset to the CodeItem.
517 uint32_t code_off_;
518
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700519 // The short-form method descriptor string.
520 StringPiece shorty_;
521
Brian Carlstroma7f4f482011-07-17 17:01:34 -0700522 private:
Ian Rogersb033c752011-07-20 12:22:35 -0700523 // Compiled code associated with this method
524 const void* code_;
525
526 // Any native method registered with this method
527 const void* native_method_;
Carl Shapirof88c9522011-08-06 15:47:38 -0700528
529 DISALLOW_IMPLICIT_CONSTRUCTORS(Method);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700530};
531
Brian Carlstrom913af1b2011-07-23 21:41:13 -0700532class Array : public Object {
533 public:
Brian Carlstroma40f9bc2011-07-26 21:26:07 -0700534 static Array* Alloc(Class* array_class,
535 size_t component_count,
536 size_t component_size) {
537 size_t size = sizeof(Array) + component_count * component_size;
538 Array* array = down_cast<Array*>(Heap::AllocObject(array_class, size));
539 if (array != NULL) {
540 array->SetLength(component_count);
541 }
542 return array;
543 }
Carl Shapirof88c9522011-08-06 15:47:38 -0700544
Brian Carlstrom913af1b2011-07-23 21:41:13 -0700545 uint32_t GetLength() const {
546 return length_;
547 }
Carl Shapirof88c9522011-08-06 15:47:38 -0700548
Brian Carlstrom913af1b2011-07-23 21:41:13 -0700549 void SetLength(uint32_t length) {
550 length_ = length;
551 }
Brian Carlstrom913af1b2011-07-23 21:41:13 -0700552
553 private:
554 // The number of array elements.
555 uint32_t length_;
Jesse Wilsondf4189c2011-08-09 17:10:28 -0400556 // Padding to ensure the first member defined by a subclass begins on a 8-byte boundary
557 int32_t padding_;
Carl Shapirof88c9522011-08-06 15:47:38 -0700558
Carl Shapirof88c9522011-08-06 15:47:38 -0700559 DISALLOW_IMPLICIT_CONSTRUCTORS(Array);
Brian Carlstrom913af1b2011-07-23 21:41:13 -0700560};
561
Brian Carlstrom4a96b602011-07-26 16:40:23 -0700562template<class T>
Brian Carlstrom913af1b2011-07-23 21:41:13 -0700563class ObjectArray : public Array {
564 public:
Brian Carlstroma40f9bc2011-07-26 21:26:07 -0700565 static ObjectArray<T>* Alloc(Class* object_array_class,
566 size_t length) {
567 return down_cast<ObjectArray<T>*>(Array::Alloc(object_array_class,
568 length,
569 sizeof(uint32_t)));
570 }
571
Jesse Wilsonfd687c52011-08-04 19:27:35 -0700572 T* const * GetData() const {
573 return reinterpret_cast<T* const *>(&elements_);
574 }
Jesse Wilsondf4189c2011-08-09 17:10:28 -0400575
Jesse Wilsonfd687c52011-08-04 19:27:35 -0700576 T** GetData() {
577 return reinterpret_cast<T**>(&elements_);
578 }
Jesse Wilsondf4189c2011-08-09 17:10:28 -0400579
Brian Carlstroma40f9bc2011-07-26 21:26:07 -0700580 T* Get(uint32_t i) const {
Brian Carlstrom0b138b22011-07-27 15:19:17 -0700581 CHECK_LT(i, GetLength());
Jesse Wilsonfd687c52011-08-04 19:27:35 -0700582 return GetData()[i];
Brian Carlstrom913af1b2011-07-23 21:41:13 -0700583 }
Carl Shapirof88c9522011-08-06 15:47:38 -0700584
Brian Carlstroma40f9bc2011-07-26 21:26:07 -0700585 void Set(uint32_t i, T* object) {
Brian Carlstrom0b138b22011-07-27 15:19:17 -0700586 CHECK_LT(i, GetLength());
Jesse Wilsondf4189c2011-08-09 17:10:28 -0400587 GetData()[i] = object; // TODO: write barrier
Brian Carlstrom913af1b2011-07-23 21:41:13 -0700588 }
Carl Shapirof88c9522011-08-06 15:47:38 -0700589
590 static void Copy(ObjectArray<T>* src, int src_pos,
591 ObjectArray<T>* dst, int dst_pos,
592 size_t length) {
Brian Carlstrom913af1b2011-07-23 21:41:13 -0700593 for (size_t i = 0; i < length; i++) {
594 dst->Set(dst_pos + i, src->Get(src_pos + i));
595 }
596 }
Carl Shapirof88c9522011-08-06 15:47:38 -0700597
Brian Carlstroma40f9bc2011-07-26 21:26:07 -0700598 ObjectArray<T>* CopyOf(size_t new_length) {
599 ObjectArray<T>* new_array = Alloc(klass_, new_length);
600 Copy(this, 0, new_array, 0, std::min(GetLength(), new_length));
601 return new_array;
602 }
Brian Carlstrom913af1b2011-07-23 21:41:13 -0700603
604 private:
Jesse Wilsonfd687c52011-08-04 19:27:35 -0700605 // Location of first element.
606 T* elements_[0];
Carl Shapirof88c9522011-08-06 15:47:38 -0700607
608 DISALLOW_IMPLICIT_CONSTRUCTORS(ObjectArray);
Brian Carlstrom913af1b2011-07-23 21:41:13 -0700609};
610
Brian Carlstrom74eb46a2011-08-02 20:10:14 -0700611// ClassLoader objects.
612class ClassLoader : public Object {
613 public:
614 std::vector<const DexFile*>& GetClassPath() {
615 return class_path_;
616 }
617 void SetClassPath(std::vector<const DexFile*>& class_path) {
618 DCHECK_EQ(0U, class_path_.size());
619 class_path_ = class_path;
620 }
621
622 private:
623 // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses".
624 Object* packages_;
625 ClassLoader* parent_;
626
627 // TODO remove once we can create a real PathClassLoader
628 std::vector<const DexFile*> class_path_;
629
Carl Shapirof88c9522011-08-06 15:47:38 -0700630 DISALLOW_IMPLICIT_CONSTRUCTORS(ClassLoader);
Brian Carlstrom74eb46a2011-08-02 20:10:14 -0700631};
632
633class BaseDexClassLoader : public ClassLoader {
634 private:
635 // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses".
636 String* original_path_;
637 Object* path_list_;
Carl Shapirof88c9522011-08-06 15:47:38 -0700638 DISALLOW_IMPLICIT_CONSTRUCTORS(BaseDexClassLoader);
Brian Carlstrom74eb46a2011-08-02 20:10:14 -0700639};
640
641class PathClassLoader : public BaseDexClassLoader {
642 private:
Carl Shapirof88c9522011-08-06 15:47:38 -0700643 DISALLOW_IMPLICIT_CONSTRUCTORS(PathClassLoader);
Brian Carlstrom74eb46a2011-08-02 20:10:14 -0700644};
645
Carl Shapiro1fb86202011-06-27 17:43:13 -0700646// Class objects.
Carl Shapiro3ee755d2011-06-28 12:11:04 -0700647class Class : public Object {
Carl Shapiro1fb86202011-06-27 17:43:13 -0700648 public:
Brian Carlstrom74eb46a2011-08-02 20:10:14 -0700649
650 // Class Status
651 //
652 // kStatusNotReady: If a Class cannot be found in the class table by
653 // FindClass, it allocates an new one with AllocClass in the
654 // kStatusNotReady and calls LoadClass. Note if it does find a
655 // class, it may not be kStatusResolved and it will try to push it
656 // forward toward kStatusResolved.
657 //
658 // kStatusIdx: LoadClass populates with Class with information from
659 // the DexFile, moving the status to kStatusIdx, indicating that the
660 // Class values in super_class_ and interfaces_ have not been
661 // populated based on super_class_idx_ and interfaces_idx_. The new
662 // Class can then be inserted into the classes table.
663 //
664 // kStatusLoaded: After taking a lock on Class, the ClassLinker will
665 // attempt to move a kStatusIdx class forward to kStatusLoaded by
666 // using ResolveClass to initialize the super_class_ and interfaces_.
667 //
668 // kStatusResolved: Still holding the lock on Class, the ClassLinker
669 // will use LinkClass to link all members, creating Field and Method
670 // objects, setting up the vtable, etc. On success, the class is
671 // marked kStatusResolved.
672
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700673 enum Status {
Carl Shapiro894d0fa2011-06-30 14:48:49 -0700674 kStatusError = -1,
675 kStatusNotReady = 0,
Brian Carlstrom74eb46a2011-08-02 20:10:14 -0700676 kStatusIdx = 1, // loaded, DEX idx in super_class_idx_ and interfaces_idx_
Carl Shapiro894d0fa2011-06-30 14:48:49 -0700677 kStatusLoaded = 2, // DEX idx values resolved
678 kStatusResolved = 3, // part of linking
679 kStatusVerifying = 4, // in the process of being verified
680 kStatusVerified = 5, // logically part of linking; done pre-init
681 kStatusInitializing = 6, // class init in progress
682 kStatusInitialized = 7, // ready to go
Carl Shapiro1fb86202011-06-27 17:43:13 -0700683 };
684
685 enum PrimitiveType {
686 kPrimNot = -1
687 };
688
Brian Carlstromf7ed11a2011-08-09 17:55:51 -0700689 Object* NewInstance() {
690 return Heap::AllocObject(this, this->object_size_);
691 }
692
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700693 Class* GetSuperClass() const {
694 return super_class_;
695 }
696
697 uint32_t GetSuperClassIdx() const {
698 return super_class_idx_;
699 }
700
701 bool HasSuperClass() const {
702 return super_class_ != NULL;
703 }
704
Brian Carlstromf7ed11a2011-08-09 17:55:51 -0700705 bool IsAssignableFrom(const Class* klass) const {
706 DCHECK(klass != NULL);
707 if (this == klass) {
708 return true;
709 }
710 if (IsInterface()) {
711 return klass->Implements(this);
712 }
713 if (klass->IsArray()) {
714 return IsAssignableFromArray(klass);
715 }
716 return klass->IsSubClass(this);
717 }
718
Brian Carlstrom74eb46a2011-08-02 20:10:14 -0700719 ClassLoader* GetClassLoader() const {
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700720 return class_loader_;
721 }
722
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700723 DexCache* GetDexCache() const {
724 return dex_cache_;
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700725 }
726
727 Class* GetComponentType() const {
728 return component_type_;
729 }
730
731 const StringPiece& GetDescriptor() const {
Brian Carlstrom74eb46a2011-08-02 20:10:14 -0700732 DCHECK_NE(0, descriptor_.size());
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700733 return descriptor_;
734 }
735
736 Status GetStatus() const {
737 return status_;
738 }
739
740 void SetStatus(Status new_status) {
741 // TODO: validate transition
742 status_ = new_status;
743 }
744
Carl Shapiro69759ea2011-07-21 18:13:35 -0700745 // Returns true if the class has failed to link.
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700746 bool IsErroneous() const {
747 return GetStatus() == kStatusError;
748 }
749
Carl Shapiro69759ea2011-07-21 18:13:35 -0700750 // Returns true if the class has been verified.
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700751 bool IsVerified() const {
752 return GetStatus() >= kStatusVerified;
753 }
754
Carl Shapiro69759ea2011-07-21 18:13:35 -0700755 // Returns true if the class has been linked.
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700756 bool IsLinked() const {
757 return GetStatus() >= kStatusResolved;
758 }
759
Carl Shapiro69759ea2011-07-21 18:13:35 -0700760 bool IsLoaded() const {
761 return GetStatus() >= kStatusLoaded;
762 }
763
Carl Shapiro894d0fa2011-06-30 14:48:49 -0700764 // Returns true if this class is in the same packages as that class.
765 bool IsInSamePackage(const Class* that) const;
766
Ian Rogersb033c752011-07-20 12:22:35 -0700767 static bool IsInSamePackage(const StringPiece& descriptor1,
768 const StringPiece& descriptor2);
Carl Shapiro894d0fa2011-06-30 14:48:49 -0700769
770 // Returns true if this class represents an array class.
771 bool IsArray() const {
Brian Carlstrom74eb46a2011-08-02 20:10:14 -0700772 return GetDescriptor()[0] == '['; // TODO: avoid parsing the descriptor
Carl Shapiro894d0fa2011-06-30 14:48:49 -0700773 }
774
775 // Returns true if the class is an interface.
776 bool IsInterface() const {
777 return (access_flags_ & kAccInterface) != 0;
778 }
779
780 // Returns true if the class is declared public.
781 bool IsPublic() const {
782 return (access_flags_ & kAccPublic) != 0;
783 }
784
785 // Returns true if the class is declared final.
786 bool IsFinal() const {
787 return (access_flags_ & kAccFinal) != 0;
788 }
789
790 // Returns true if the class is abstract.
791 bool IsAbstract() const {
792 return (access_flags_ & kAccAbstract) != 0;
793 }
794
795 // Returns true if the class is an annotation.
796 bool IsAnnotation() const {
797 return (access_flags_ & kAccAnnotation) != 0;
798 }
799
800 // Returns true if the class is a primitive type.
801 bool IsPrimitive() const {
802 return primitive_type_ != kPrimNot;
803 }
804
Brian Carlstromae3ac012011-07-27 01:30:28 -0700805 // Returns true if the class is synthetic.
806 bool IsSynthetic() const {
807 return (access_flags_ & kAccSynthetic) != 0;
808 }
809
Carl Shapiro894d0fa2011-06-30 14:48:49 -0700810 // Returns true if this class can access that class.
811 bool CanAccess(const Class* that) const {
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700812 return that->IsPublic() || this->IsInSamePackage(that);
Carl Shapiro894d0fa2011-06-30 14:48:49 -0700813 }
814
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700815 // Returns the number of static, private, and constructor methods.
816 size_t NumDirectMethods() const {
Brian Carlstrom913af1b2011-07-23 21:41:13 -0700817 return (direct_methods_ != NULL) ? direct_methods_->GetLength() : 0;
Carl Shapiro3ee755d2011-06-28 12:11:04 -0700818 }
819
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700820 Method* GetDirectMethod(uint32_t i) const {
Brian Carlstrom75cb3b42011-07-28 02:13:36 -0700821 DCHECK_NE(NumDirectMethods(), 0U);
Brian Carlstrom4a96b602011-07-26 16:40:23 -0700822 return direct_methods_->Get(i);
Brian Carlstrom913af1b2011-07-23 21:41:13 -0700823 }
824
825 void SetDirectMethod(uint32_t i, Method* f) { // TODO: uint16_t
Brian Carlstrom75cb3b42011-07-28 02:13:36 -0700826 DCHECK_NE(NumDirectMethods(), 0U);
Brian Carlstrom913af1b2011-07-23 21:41:13 -0700827 direct_methods_->Set(i, f);
Carl Shapiro3ee755d2011-06-28 12:11:04 -0700828 }
829
Carl Shapiro419ec7b2011-08-03 14:48:33 -0700830 Method* FindDeclaredDirectMethod(const StringPiece& name,
831 const StringPiece& descriptor);
832
833 Method* FindDirectMethod(const StringPiece& name,
834 const StringPiece& descriptor);
835
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700836 // Returns the number of non-inherited virtual methods.
837 size_t NumVirtualMethods() const {
Brian Carlstrom913af1b2011-07-23 21:41:13 -0700838 return (virtual_methods_ != NULL) ? virtual_methods_->GetLength() : 0;
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700839 }
840
841 Method* GetVirtualMethod(uint32_t i) const {
Brian Carlstrom75cb3b42011-07-28 02:13:36 -0700842 DCHECK_NE(NumVirtualMethods(), 0U);
Brian Carlstrom4a96b602011-07-26 16:40:23 -0700843 return virtual_methods_->Get(i);
Brian Carlstrom913af1b2011-07-23 21:41:13 -0700844 }
845
846 void SetVirtualMethod(uint32_t i, Method* f) { // TODO: uint16_t
Brian Carlstrom75cb3b42011-07-28 02:13:36 -0700847 DCHECK_NE(NumVirtualMethods(), 0U);
Brian Carlstrom913af1b2011-07-23 21:41:13 -0700848 virtual_methods_->Set(i, f);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700849 }
850
Carl Shapiro419ec7b2011-08-03 14:48:33 -0700851 Method* FindDeclaredVirtualMethod(const StringPiece& name,
852 const StringPiece& descriptor);
853
854 Method* FindVirtualMethod(const StringPiece& name,
855 const StringPiece& descriptor);
856
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700857 size_t NumInstanceFields() const {
Brian Carlstrom913af1b2011-07-23 21:41:13 -0700858 return (ifields_ != NULL) ? ifields_->GetLength() : 0;
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700859 }
860
Carl Shapiro69759ea2011-07-21 18:13:35 -0700861 // Returns the number of instance fields containing reference types.
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700862 size_t NumReferenceInstanceFields() const {
Carl Shapiro69759ea2011-07-21 18:13:35 -0700863 return num_reference_instance_fields_;
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700864 }
865
Jesse Wilson35baaab2011-08-10 16:18:03 -0400866 Field* GetInstanceField(uint32_t i) const { // TODO: uint16_t
Brian Carlstrom75cb3b42011-07-28 02:13:36 -0700867 DCHECK_NE(NumInstanceFields(), 0U);
Brian Carlstrom4a96b602011-07-26 16:40:23 -0700868 return ifields_->Get(i);
Brian Carlstroma7f4f482011-07-17 17:01:34 -0700869 }
870
Jesse Wilson35baaab2011-08-10 16:18:03 -0400871 void SetInstanceField(uint32_t i, Field* f) { // TODO: uint16_t
Brian Carlstrom75cb3b42011-07-28 02:13:36 -0700872 DCHECK_NE(NumInstanceFields(), 0U);
Brian Carlstrom913af1b2011-07-23 21:41:13 -0700873 ifields_->Set(i, f);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700874 }
875
876 size_t NumStaticFields() const {
Brian Carlstrom913af1b2011-07-23 21:41:13 -0700877 return (sfields_ != NULL) ? sfields_->GetLength() : 0;
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700878 }
879
Jesse Wilson35baaab2011-08-10 16:18:03 -0400880 Field* GetStaticField(uint32_t i) const { // TODO: uint16_t
Brian Carlstrom75cb3b42011-07-28 02:13:36 -0700881 DCHECK_NE(NumStaticFields(), 0U);
Brian Carlstrom4a96b602011-07-26 16:40:23 -0700882 return sfields_->Get(i);
Brian Carlstrom913af1b2011-07-23 21:41:13 -0700883 }
884
Jesse Wilson35baaab2011-08-10 16:18:03 -0400885 void SetStaticField(uint32_t i, Field* f) { // TODO: uint16_t
Brian Carlstrom75cb3b42011-07-28 02:13:36 -0700886 DCHECK_NE(NumStaticFields(), 0U);
Brian Carlstrom913af1b2011-07-23 21:41:13 -0700887 sfields_->Set(i, f);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700888 }
889
890 uint32_t GetReferenceOffsets() const {
891 return reference_offsets_;
892 }
893
894 void SetReferenceOffsets(uint32_t new_reference_offsets) {
895 reference_offsets_ = new_reference_offsets;
896 }
897
Carl Shapiro69759ea2011-07-21 18:13:35 -0700898 size_t NumInterfaces() const {
Brian Carlstrom913af1b2011-07-23 21:41:13 -0700899 return (interfaces_ != NULL) ? interfaces_->GetLength() : 0;
Carl Shapiro69759ea2011-07-21 18:13:35 -0700900 }
901
902 Class* GetInterface(uint32_t i) const {
Brian Carlstrom75cb3b42011-07-28 02:13:36 -0700903 DCHECK_NE(NumInterfaces(), 0U);
Brian Carlstrom4a96b602011-07-26 16:40:23 -0700904 return interfaces_->Get(i);
Brian Carlstrom913af1b2011-07-23 21:41:13 -0700905 }
906
907 void SetInterface(uint32_t i, Class* f) { // TODO: uint16_t
Brian Carlstrom75cb3b42011-07-28 02:13:36 -0700908 DCHECK_NE(NumInterfaces(), 0U);
Brian Carlstrom913af1b2011-07-23 21:41:13 -0700909 interfaces_->Set(i, f);
Carl Shapiro69759ea2011-07-21 18:13:35 -0700910 }
911
Brian Carlstromf7ed11a2011-08-09 17:55:51 -0700912 void SetVerifyErrorClass(Class* klass) {
913 // Note SetFieldObject is used rather than verify_error_class_ directly for the barrier
914 size_t field_offset = OFFSETOF_MEMBER(Class, verify_error_class_);
915 klass->SetFieldObject(field_offset, klass);
916 }
917
918 private:
919 bool Implements(const Class* klass) const;
920 bool IsArrayAssignableFromArray(const Class* klass) const;
921 bool IsAssignableFromArray(const Class* klass) const;
922 bool IsSubClass(const Class* klass) const;
923
Ian Rogersb033c752011-07-20 12:22:35 -0700924 public: // TODO: private
Carl Shapiro1fb86202011-06-27 17:43:13 -0700925 // leave space for instance data; we could access fields directly if
926 // we freeze the definition of java/lang/Class
Brian Carlstroma7f4f482011-07-17 17:01:34 -0700927#define CLASS_FIELD_SLOTS 1
928 // Class.#0 name
Carl Shapiro1fb86202011-06-27 17:43:13 -0700929 uint32_t instance_data_[CLASS_FIELD_SLOTS];
930#undef CLASS_FIELD_SLOTS
931
932 // UTF-8 descriptor for the class from constant pool
933 // ("Ljava/lang/Class;"), or on heap if generated ("[C")
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700934 StringPiece descriptor_;
Carl Shapiro1fb86202011-06-27 17:43:13 -0700935
936 // Proxy classes have their descriptor allocated on the native heap.
937 // When this field is non-NULL it must be explicitly freed.
Brian Carlstroma331b3c2011-07-18 17:47:56 -0700938 std::string* descriptor_alloc_;
Carl Shapiro1fb86202011-06-27 17:43:13 -0700939
940 // access flags; low 16 bits are defined by VM spec
Carl Shapiro3ee755d2011-06-28 12:11:04 -0700941 uint32_t access_flags_; // TODO: make an instance field?
Carl Shapiro1fb86202011-06-27 17:43:13 -0700942
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700943 // DexCache of resolved constant pool entries
Carl Shapiro1fb86202011-06-27 17:43:13 -0700944 // (will be NULL for VM-generated, e.g. arrays and primitive classes)
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700945 DexCache* dex_cache_;
Carl Shapiro1fb86202011-06-27 17:43:13 -0700946
947 // state of class initialization
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700948 Status status_;
Carl Shapiro1fb86202011-06-27 17:43:13 -0700949
Brian Carlstromf7ed11a2011-08-09 17:55:51 -0700950 // If class verify fails, we must return same error on subsequent tries.
951 // Update with SetVerifyErrorClass to ensure a write barrier is used.
952 const Class* verify_error_class_;
Carl Shapiro1fb86202011-06-27 17:43:13 -0700953
954 // threadId, used to check for recursive <clinit> invocation
955 uint32_t clinit_thread_id_;
956
957 // Total object size; used when allocating storage on gc heap. (For
958 // interfaces and abstract classes this will be zero.)
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700959 size_t object_size_;
Carl Shapiro1fb86202011-06-27 17:43:13 -0700960
961 // For array classes, the class object for base element, for
962 // instanceof/checkcast (for String[][][], this will be String).
963 // Otherwise, NULL.
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700964 Class* component_type_; // TODO: make an instance field
Carl Shapiro1fb86202011-06-27 17:43:13 -0700965
966 // For array classes, the number of array dimensions, e.g. int[][]
967 // is 2. Otherwise 0.
968 int32_t array_rank_;
969
970 // primitive type index, or PRIM_NOT (-1); set for generated prim classes
971 PrimitiveType primitive_type_;
972
973 // The superclass, or NULL if this is java.lang.Object or a
974 // primitive type.
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700975 Class* super_class_; // TODO: make an instance field
976 uint32_t super_class_idx_;
Carl Shapiro1fb86202011-06-27 17:43:13 -0700977
978 // defining class loader, or NULL for the "bootstrap" system loader
Brian Carlstrom74eb46a2011-08-02 20:10:14 -0700979 ClassLoader* class_loader_; // TODO: make an instance field
Carl Shapiro1fb86202011-06-27 17:43:13 -0700980
981 // initiating class loader list
982 // NOTE: for classes with low serialNumber, these are unused, and the
983 // values are kept in a table in gDvm.
Ian Rogersb033c752011-07-20 12:22:35 -0700984 // InitiatingLoaderList initiating_loader_list_;
Carl Shapiro1fb86202011-06-27 17:43:13 -0700985
986 // array of interfaces this class implements directly
Brian Carlstrom4a96b602011-07-26 16:40:23 -0700987 ObjectArray<Class>* interfaces_;
Brian Carlstrom913af1b2011-07-23 21:41:13 -0700988 uint32_t* interfaces_idx_;
Carl Shapiro1fb86202011-06-27 17:43:13 -0700989
990 // static, private, and <init> methods
Brian Carlstrom4a96b602011-07-26 16:40:23 -0700991 ObjectArray<Method>* direct_methods_;
Carl Shapiro1fb86202011-06-27 17:43:13 -0700992
993 // virtual methods defined in this class; invoked through vtable
Brian Carlstrom4a96b602011-07-26 16:40:23 -0700994 ObjectArray<Method>* virtual_methods_;
Carl Shapiro1fb86202011-06-27 17:43:13 -0700995
996 // Virtual method table (vtable), for use by "invoke-virtual". The
997 // vtable from the superclass is copied in, and virtual methods from
998 // our class either replace those from the super or are appended.
Brian Carlstrom4a96b602011-07-26 16:40:23 -0700999 ObjectArray<Method>* vtable_;
Carl Shapiro1fb86202011-06-27 17:43:13 -07001000
1001 // Interface table (iftable), one entry per interface supported by
1002 // this class. That means one entry for each interface we support
1003 // directly, indirectly via superclass, or indirectly via
1004 // superinterface. This will be null if neither we nor our
1005 // superclass implement any interfaces.
1006 //
1007 // Why we need this: given "class Foo implements Face", declare
1008 // "Face faceObj = new Foo()". Invoke faceObj.blah(), where "blah"
1009 // is part of the Face interface. We can't easily use a single
1010 // vtable.
1011 //
1012 // For every interface a concrete class implements, we create a list
1013 // of virtualMethod indices for the methods in the interface.
Carl Shapiro0e5d75d2011-07-06 18:28:37 -07001014 size_t iftable_count_;
Carl Shapiro1fb86202011-06-27 17:43:13 -07001015 InterfaceEntry* iftable_;
1016
1017 // The interface vtable indices for iftable get stored here. By
1018 // placing them all in a single pool for each class that implements
1019 // interfaces, we decrease the number of allocations.
Carl Shapiro0e5d75d2011-07-06 18:28:37 -07001020 size_t ifvi_pool_count_;
1021 uint32_t* ifvi_pool_;
Carl Shapiro1fb86202011-06-27 17:43:13 -07001022
1023 // instance fields
1024 //
1025 // These describe the layout of the contents of a
1026 // DataObject-compatible Object. Note that only the fields directly
1027 // declared by this class are listed in ifields; fields declared by
Brian Carlstroma331b3c2011-07-18 17:47:56 -07001028 // a superclass are listed in the superclass's Class.ifields.
Carl Shapiro1fb86202011-06-27 17:43:13 -07001029 //
1030 // All instance fields that refer to objects are guaranteed to be at
Brian Carlstrom913af1b2011-07-23 21:41:13 -07001031 // the beginning of the field list. num_reference_instance_fields_
1032 // specifies the number of reference fields.
Jesse Wilson35baaab2011-08-10 16:18:03 -04001033 ObjectArray<Field>* ifields_;
Carl Shapiro3ee755d2011-06-28 12:11:04 -07001034
1035 // number of fields that are object refs
Carl Shapiro69759ea2011-07-21 18:13:35 -07001036 size_t num_reference_instance_fields_;
Carl Shapiro1fb86202011-06-27 17:43:13 -07001037
Carl Shapiro0e5d75d2011-07-06 18:28:37 -07001038 // Bitmap of offsets of ifields.
1039 uint32_t reference_offsets_;
Carl Shapiro1fb86202011-06-27 17:43:13 -07001040
1041 // source file name, if known. Otherwise, NULL.
1042 const char* source_file_;
1043
Jesse Wilson7833bd22011-08-09 18:31:44 -04001044 // Static fields
Jesse Wilson35baaab2011-08-10 16:18:03 -04001045 ObjectArray<Field>* sfields_;
Jesse Wilson7833bd22011-08-09 18:31:44 -04001046
1047 // static field storage
1048 //
1049 // Each static field is stored in one of three arrays:
1050 // o references are stored in static_references_
1051 // o doubles and longs are stored in static_64bit_primitives_
1052 // o everything else is in static_32bit_primitives_
1053 // Static fields select their array using their type and their index using the
1054 // Field->slot_ member. Storing static fields in arrays avoids the need for a
1055 // special case in the GC.
Jesse Wilsonfd687c52011-08-04 19:27:35 -07001056 ObjectArray<Object>* static_references_;
1057 IntArray* static_32bit_primitives_;
1058 LongArray* static_64bit_primitives_;
1059
Brian Carlstroma7f4f482011-07-17 17:01:34 -07001060 private:
Carl Shapirof88c9522011-08-06 15:47:38 -07001061 DISALLOW_IMPLICIT_CONSTRUCTORS(Class);
Carl Shapiro1fb86202011-06-27 17:43:13 -07001062};
Elliott Hughes1f359b02011-07-17 14:27:17 -07001063std::ostream& operator<<(std::ostream& os, const Class::Status& rhs);
Carl Shapiro1fb86202011-06-27 17:43:13 -07001064
Brian Carlstromf7ed11a2011-08-09 17:55:51 -07001065inline bool Object::InstanceOf(const Class* klass) const {
Jesse Wilson14150742011-07-29 19:04:44 -04001066 DCHECK(klass != NULL);
Brian Carlstromf7ed11a2011-08-09 17:55:51 -07001067 DCHECK(klass_ != NULL);
1068 return klass->IsAssignableFrom(klass_);
Brian Carlstroma40f9bc2011-07-26 21:26:07 -07001069}
1070
Brian Carlstromf7ed11a2011-08-09 17:55:51 -07001071
Carl Shapiro0e5d75d2011-07-06 18:28:37 -07001072class DataObject : public Object {
1073 public:
Brian Carlstrom578bbdc2011-07-21 14:07:47 -07001074 uint32_t fields_[0];
Brian Carlstroma7f4f482011-07-17 17:01:34 -07001075 private:
Carl Shapirof88c9522011-08-06 15:47:38 -07001076 DISALLOW_IMPLICIT_CONSTRUCTORS(DataObject);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -07001077};
1078
Jesse Wilsonfd687c52011-08-04 19:27:35 -07001079template<class T>
1080class PrimitiveArray : public Array {
Brian Carlstroma40f9bc2011-07-26 21:26:07 -07001081 public:
Jesse Wilsonfd687c52011-08-04 19:27:35 -07001082 static PrimitiveArray<T>* Alloc(Class* element_class, size_t length) {
1083 return down_cast<PrimitiveArray<T>*>(Array::Alloc(element_class,
1084 length,
1085 sizeof(T)));
Brian Carlstroma40f9bc2011-07-26 21:26:07 -07001086 }
Brian Carlstrom0b138b22011-07-27 15:19:17 -07001087
Jesse Wilsonfd687c52011-08-04 19:27:35 -07001088 const T* GetData() const {
1089 return reinterpret_cast<const T*>(&elements_);
Brian Carlstrom0b138b22011-07-27 15:19:17 -07001090 }
1091
Jesse Wilsonfd687c52011-08-04 19:27:35 -07001092 T* GetData() {
1093 return reinterpret_cast<T*>(&elements_);
Brian Carlstrom0b138b22011-07-27 15:19:17 -07001094 }
1095
Jesse Wilsonfd687c52011-08-04 19:27:35 -07001096 T Get(T i) const {
Brian Carlstrom0b138b22011-07-27 15:19:17 -07001097 CHECK_LT(i, GetLength());
Jesse Wilsonfd687c52011-08-04 19:27:35 -07001098 return GetData()[i];
Brian Carlstrom0b138b22011-07-27 15:19:17 -07001099 }
1100
Jesse Wilsonfd687c52011-08-04 19:27:35 -07001101 void Set(uint32_t i, T value) {
Brian Carlstrom0b138b22011-07-27 15:19:17 -07001102 CHECK_LT(i, GetLength());
Jesse Wilsonfd687c52011-08-04 19:27:35 -07001103 GetData()[i] = value;
Brian Carlstrom0b138b22011-07-27 15:19:17 -07001104 }
1105
Brian Carlstroma7f4f482011-07-17 17:01:34 -07001106 private:
Jesse Wilsonfd687c52011-08-04 19:27:35 -07001107 // Location of first element.
1108 T elements_[0];
Carl Shapirof88c9522011-08-06 15:47:38 -07001109
1110 DISALLOW_IMPLICIT_CONSTRUCTORS(PrimitiveArray);
Brian Carlstroma7f4f482011-07-17 17:01:34 -07001111};
Carl Shapiro5fafe2b2011-07-09 15:34:41 -07001112
Carl Shapiro0e5d75d2011-07-06 18:28:37 -07001113class String : public Object {
Carl Shapiro1fb86202011-06-27 17:43:13 -07001114 public:
Carl Shapiro8860c0e2011-08-04 17:36:16 -07001115 const CharArray* GetCharArray() const {
Carl Shapirof88c9522011-08-06 15:47:38 -07001116 DCHECK(array_ != NULL);
Carl Shapiro8860c0e2011-08-04 17:36:16 -07001117 return array_;
1118 }
1119
Carl Shapirof88c9522011-08-06 15:47:38 -07001120 uint32_t GetHashCode() const {
Carl Shapiro8860c0e2011-08-04 17:36:16 -07001121 return hash_code_;
1122 }
1123
Carl Shapirof88c9522011-08-06 15:47:38 -07001124 uint32_t GetOffset() const {
Carl Shapiro8860c0e2011-08-04 17:36:16 -07001125 return offset_;
1126 }
1127
Carl Shapirof88c9522011-08-06 15:47:38 -07001128 uint32_t GetLength() const {
Carl Shapiro8860c0e2011-08-04 17:36:16 -07001129 return count_;
1130 }
1131
Carl Shapirof88c9522011-08-06 15:47:38 -07001132 uint16_t CharAt(uint32_t index) const {
1133 DCHECK_LE(index, GetLength());
Jesse Wilsonfd687c52011-08-04 19:27:35 -07001134 return GetCharArray()->Get(index + GetOffset());
Carl Shapiro8860c0e2011-08-04 17:36:16 -07001135 }
1136
Brian Carlstrom7e93b502011-08-04 14:16:22 -07001137 static String* AllocFromUtf16(int32_t utf16_length,
1138 uint16_t* utf16_data_in,
1139 int32_t hash_code) {
Carl Shapirof88c9522011-08-06 15:47:38 -07001140 String* string = Alloc(GetJavaLangString(),
1141 GetCharArrayClass(),
1142 utf16_length);
Brian Carlstrom0b138b22011-07-27 15:19:17 -07001143 // TODO use 16-bit wide memset variant
1144 for (int i = 0; i < utf16_length; i++ ) {
Jesse Wilsonfd687c52011-08-04 19:27:35 -07001145 string->array_->Set(i, utf16_data_in[i]);
Brian Carlstrom0b138b22011-07-27 15:19:17 -07001146 }
Jesse Wilsonfd687c52011-08-04 19:27:35 -07001147 string->ComputeHashCode();
Brian Carlstrom0b138b22011-07-27 15:19:17 -07001148 return string;
Brian Carlstroma40f9bc2011-07-26 21:26:07 -07001149 }
1150
1151 static String* AllocFromModifiedUtf8(Class* java_lang_String,
1152 Class* char_array,
Brian Carlstrom0b138b22011-07-27 15:19:17 -07001153 int32_t utf16_length,
1154 const char* utf8_data_in) {
1155 String* string = Alloc(java_lang_String, char_array, utf16_length);
Jesse Wilsonfd687c52011-08-04 19:27:35 -07001156 uint16_t* utf16_data_out = string->array_->GetData();
Brian Carlstrom0b138b22011-07-27 15:19:17 -07001157 ConvertModifiedUtf8ToUtf16(utf16_data_out, utf8_data_in);
Jesse Wilsonfd687c52011-08-04 19:27:35 -07001158 string->ComputeHashCode();
Brian Carlstroma40f9bc2011-07-26 21:26:07 -07001159 return string;
1160 }
1161
Jesse Wilsonf7e85a52011-08-01 18:45:58 -07001162 // Creates a String of the given ASCII characters. It is an error to call this
1163 // using non-ASCII characters as this function assumes one char per byte.
1164 static String* AllocFromAscii(const char* ascii_data_in) {
Brian Carlstrom7e93b502011-08-04 14:16:22 -07001165 return AllocFromModifiedUtf8(GetJavaLangString(),
1166 GetCharArrayClass(),
Jesse Wilsonf7e85a52011-08-01 18:45:58 -07001167 strlen(ascii_data_in),
1168 ascii_data_in);
1169 }
1170
Jesse Wilson8989d992011-08-02 13:39:42 -07001171 static String* AllocFromModifiedUtf8(int32_t utf16_length,
1172 const char* utf8_data_in) {
Brian Carlstrom7e93b502011-08-04 14:16:22 -07001173 return AllocFromModifiedUtf8(GetJavaLangString(), GetCharArrayClass(),
1174 utf16_length, utf8_data_in);
Jesse Wilson8989d992011-08-02 13:39:42 -07001175 }
1176
Jesse Wilsonf7e85a52011-08-01 18:45:58 -07001177 static void InitClasses(Class* java_lang_String, Class* char_array);
1178
Brian Carlstrom0b138b22011-07-27 15:19:17 -07001179 static String* Alloc(Class* java_lang_String,
1180 Class* char_array,
1181 int32_t utf16_length) {
Brian Carlstromf7ed11a2011-08-09 17:55:51 -07001182 String* string = down_cast<String*>(java_lang_String->NewInstance());
Brian Carlstrom0b138b22011-07-27 15:19:17 -07001183 CharArray* array = CharArray::Alloc(char_array, utf16_length);
1184 string->array_ = array;
1185 string->count_ = utf16_length;
1186 return string;
1187 }
1188
1189 // Convert Modified UTF-8 to UTF-16
1190 // http://en.wikipedia.org/wiki/UTF-8#Modified_UTF-8
1191 static void ConvertModifiedUtf8ToUtf16(uint16_t* utf16_data_out, const char* utf8_data_in) {
1192 while (*utf8_data_in != '\0') {
1193 *utf16_data_out++ = GetUtf16FromUtf8(&utf8_data_in);
1194 }
1195 }
1196
1197 // Retrieve the next UTF-16 character from a UTF-8 string.
1198 //
1199 // Advances "*pUtf8Ptr" to the start of the next character.
1200 //
1201 // WARNING: If a string is corrupted by dropping a '\0' in the middle
1202 // of a 3-byte sequence, you can end up overrunning the buffer with
1203 // reads (and possibly with the writes if the length was computed and
1204 // cached before the damage). For performance reasons, this function
1205 // assumes that the string being parsed is known to be valid (e.g., by
1206 // already being verified). Most strings we process here are coming
1207 // out of dex files or other internal translations, so the only real
1208 // risk comes from the JNI NewStringUTF call.
1209 static uint16_t GetUtf16FromUtf8(const char** utf8_data_in) {
1210 uint8_t one = *(*utf8_data_in)++;
1211 if ((one & 0x80) == 0) {
Brian Carlstrom74eb46a2011-08-02 20:10:14 -07001212 // one-byte encoding
Brian Carlstrom0b138b22011-07-27 15:19:17 -07001213 return one;
1214 }
Brian Carlstrom74eb46a2011-08-02 20:10:14 -07001215 // two- or three-byte encoding
Brian Carlstrom0b138b22011-07-27 15:19:17 -07001216 uint8_t two = *(*utf8_data_in)++;
1217 if ((one & 0x20) == 0) {
Brian Carlstrom74eb46a2011-08-02 20:10:14 -07001218 // two-byte encoding
Brian Carlstrom0b138b22011-07-27 15:19:17 -07001219 return ((one & 0x1f) << 6) |
1220 (two & 0x3f);
1221 }
Brian Carlstrom74eb46a2011-08-02 20:10:14 -07001222 // three-byte encoding
Brian Carlstrom0b138b22011-07-27 15:19:17 -07001223 uint8_t three = *(*utf8_data_in)++;
1224 return ((one & 0x0f) << 12) |
1225 ((two & 0x3f) << 6) |
1226 (three & 0x3f);
1227 }
1228
Brian Carlstrom74eb46a2011-08-02 20:10:14 -07001229 // Like "strlen", but for strings encoded with "modified" UTF-8.
1230 //
1231 // The value returned is the number of characters, which may or may not
1232 // be the same as the number of bytes.
1233 //
1234 // (If this needs optimizing, try: mask against 0xa0, shift right 5,
1235 // get increment {1-3} from table of 8 values.)
1236 static size_t ModifiedUtf8Len(const char* utf8) {
1237 size_t len = 0;
1238 int ic;
1239 while ((ic = *utf8++) != '\0') {
1240 len++;
1241 if ((ic & 0x80) == 0) {
1242 // one-byte encoding
1243 continue;
1244 }
1245 // two- or three-byte encoding
1246 utf8++;
1247 if ((ic & 0x20) == 0) {
1248 // two-byte encoding
1249 continue;
1250 }
1251 // three-byte encoding
1252 utf8++;
1253 }
1254 return len;
1255 }
1256
Brian Carlstrom0b138b22011-07-27 15:19:17 -07001257 // The java/lang/String.computeHashCode() algorithm
Jesse Wilsoncbe9fc02011-07-29 18:59:50 -04001258 static int32_t ComputeUtf16Hash(const uint16_t* string_data, size_t string_length) {
1259 int32_t hash = 0;
Brian Carlstrom0b138b22011-07-27 15:19:17 -07001260 while (string_length--) {
Brian Carlstrom7e93b502011-08-04 14:16:22 -07001261 hash = hash * 31 + *string_data++;
Brian Carlstrom0b138b22011-07-27 15:19:17 -07001262 }
1263 return hash;
1264 }
1265
Jesse Wilsonfd687c52011-08-04 19:27:35 -07001266 void ComputeHashCode() {
1267 hash_code_ = ComputeUtf16Hash(array_->GetData(), count_);
1268 }
1269
Carl Shapiro8860c0e2011-08-04 17:36:16 -07001270 bool Equals(const char* modified_utf8) const {
Carl Shapirof88c9522011-08-06 15:47:38 -07001271 for (uint32_t i = 0; i < GetLength(); ++i) {
Carl Shapiro8860c0e2011-08-04 17:36:16 -07001272 uint16_t ch = GetUtf16FromUtf8(&modified_utf8);
1273 if (ch == '\0' || ch != CharAt(i)) {
Jesse Wilsoncbe9fc02011-07-29 18:59:50 -04001274 return false;
1275 }
1276 }
Carl Shapiro8860c0e2011-08-04 17:36:16 -07001277 return *modified_utf8 == '\0';
Jesse Wilsoncbe9fc02011-07-29 18:59:50 -04001278 }
1279
Carl Shapiro8860c0e2011-08-04 17:36:16 -07001280 bool Equals(const StringPiece& modified_utf8) const {
1281 // TODO: do not assume C-string representation.
1282 return Equals(modified_utf8.data());
1283 }
1284
1285 bool Equals(const String* that) const {
Brian Carlstrom7e93b502011-08-04 14:16:22 -07001286 // TODO short circuit on hash_code_
Carl Shapiro8860c0e2011-08-04 17:36:16 -07001287 if (this->GetLength() != that->GetLength()) {
Jesse Wilsonf7e85a52011-08-01 18:45:58 -07001288 return false;
1289 }
Carl Shapirof88c9522011-08-06 15:47:38 -07001290 for (uint32_t i = 0; i < that->GetLength(); ++i) {
Carl Shapiro8860c0e2011-08-04 17:36:16 -07001291 if (this->CharAt(i) != that->CharAt(i)) {
Jesse Wilsonf7e85a52011-08-01 18:45:58 -07001292 return false;
1293 }
1294 }
1295 return true;
1296 }
1297
Carl Shapirof88c9522011-08-06 15:47:38 -07001298 bool Equals(const uint16_t* that_chars, uint32_t that_offset, uint32_t that_length) const {
Brian Carlstrom7e93b502011-08-04 14:16:22 -07001299 if (this->GetLength() != that_length) {
1300 return false;
1301 }
Carl Shapirof88c9522011-08-06 15:47:38 -07001302 for (uint32_t i = 0; i < that_length; ++i) {
Brian Carlstrom7e93b502011-08-04 14:16:22 -07001303 if (this->CharAt(i) != that_chars[that_offset + i]) {
1304 return false;
1305 }
1306 }
1307 return true;
1308 }
1309
Brian Carlstroma7f4f482011-07-17 17:01:34 -07001310 private:
Carl Shapiro8860c0e2011-08-04 17:36:16 -07001311 // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses".
1312 CharArray* array_;
1313
Carl Shapirof88c9522011-08-06 15:47:38 -07001314 uint32_t hash_code_;
Carl Shapiro8860c0e2011-08-04 17:36:16 -07001315
Carl Shapirof88c9522011-08-06 15:47:38 -07001316 uint32_t offset_;
Carl Shapiro8860c0e2011-08-04 17:36:16 -07001317
Carl Shapirof88c9522011-08-06 15:47:38 -07001318 uint32_t count_;
Brian Carlstrom7e93b502011-08-04 14:16:22 -07001319
1320 static Class* GetJavaLangString() {
1321 DCHECK(java_lang_String_ != NULL);
1322 return java_lang_String_;
1323 }
1324 static Class* GetCharArrayClass() {
1325 DCHECK(char_array_ != NULL);
1326 return char_array_;
1327 }
Jesse Wilsonf7e85a52011-08-01 18:45:58 -07001328
1329 static Class* java_lang_String_;
1330 static Class* char_array_;
Carl Shapiro8860c0e2011-08-04 17:36:16 -07001331
1332 DISALLOW_IMPLICIT_CONSTRUCTORS(String);
Carl Shapiro1fb86202011-06-27 17:43:13 -07001333};
1334
Carl Shapiro0e5d75d2011-07-06 18:28:37 -07001335class InterfaceEntry {
Carl Shapiro1fb86202011-06-27 17:43:13 -07001336 public:
Carl Shapirof88c9522011-08-06 15:47:38 -07001337 InterfaceEntry() : klass_(NULL), method_index_array_(NULL) {
1338 }
1339
Carl Shapiro0e5d75d2011-07-06 18:28:37 -07001340 Class* GetClass() const {
1341 return klass_;
Carl Shapirof88c9522011-08-06 15:47:38 -07001342 }
Carl Shapiro3ee755d2011-06-28 12:11:04 -07001343
Carl Shapiro0e5d75d2011-07-06 18:28:37 -07001344 void SetClass(Class* klass) {
1345 klass_ = klass;
Carl Shapirof88c9522011-08-06 15:47:38 -07001346 }
Carl Shapiro3ee755d2011-06-28 12:11:04 -07001347
Carl Shapiro0e5d75d2011-07-06 18:28:37 -07001348 private:
1349 // Points to the interface class.
Carl Shapiro3ee755d2011-06-28 12:11:04 -07001350 Class* klass_;
1351
Carl Shapiro0e5d75d2011-07-06 18:28:37 -07001352 public: // TODO: private
1353 // Index into array of vtable offsets. This points into the
1354 // ifviPool, which holds the vtables for all interfaces declared by
1355 // this class.
1356 uint32_t* method_index_array_;
Carl Shapirof88c9522011-08-06 15:47:38 -07001357
1358 private:
1359 DISALLOW_COPY_AND_ASSIGN(InterfaceEntry);
Carl Shapiro1fb86202011-06-27 17:43:13 -07001360};
1361
1362} // namespace art
1363
1364#endif // ART_SRC_OBJECT_H_