| OLD | NEW |
| 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 2180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2191 | 2191 |
| 2192 // Build a string of the form 'T, {B b, C c}' representing the user | 2192 // Build a string of the form 'T, {B b, C c}' representing the user |
| 2193 // visible formal parameters of the function. | 2193 // visible formal parameters of the function. |
| 2194 RawString* UserVisibleFormalParameters() const; | 2194 RawString* UserVisibleFormalParameters() const; |
| 2195 | 2195 |
| 2196 RawClass* Owner() const; | 2196 RawClass* Owner() const; |
| 2197 RawClass* origin() const; | 2197 RawClass* origin() const; |
| 2198 RawScript* script() const; | 2198 RawScript* script() const; |
| 2199 RawObject* RawOwner() const { return raw_ptr()->owner_; } | 2199 RawObject* RawOwner() const { return raw_ptr()->owner_; } |
| 2200 | 2200 |
| 2201 RawJSRegExp* regexp() const; | 2201 RawRegExp* regexp() const; |
| 2202 intptr_t string_specialization_cid() const; | 2202 intptr_t string_specialization_cid() const; |
| 2203 void SetRegExpData(const JSRegExp& regexp, | 2203 void SetRegExpData(const RegExp& regexp, |
| 2204 intptr_t string_specialization_cid) const; | 2204 intptr_t string_specialization_cid) const; |
| 2205 | 2205 |
| 2206 RawString* native_name() const; | 2206 RawString* native_name() const; |
| 2207 void set_native_name(const String& name) const; | 2207 void set_native_name(const String& name) const; |
| 2208 | 2208 |
| 2209 RawAbstractType* result_type() const { return raw_ptr()->result_type_; } | 2209 RawAbstractType* result_type() const { return raw_ptr()->result_type_; } |
| 2210 void set_result_type(const AbstractType& value) const; | 2210 void set_result_type(const AbstractType& value) const; |
| 2211 | 2211 |
| 2212 RawAbstractType* ParameterTypeAt(intptr_t index) const; | 2212 RawAbstractType* ParameterTypeAt(intptr_t index) const; |
| 2213 void SetParameterTypeAt(intptr_t index, const AbstractType& value) const; | 2213 void SetParameterTypeAt(intptr_t index, const AbstractType& value) const; |
| (...skipping 3013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5227 static intptr_t NextFieldOffset() { | 5227 static intptr_t NextFieldOffset() { |
| 5228 return sizeof(RawInstance); | 5228 return sizeof(RawInstance); |
| 5229 } | 5229 } |
| 5230 | 5230 |
| 5231 // TODO(iposva): Determine if this gets in the way of Smi. | 5231 // TODO(iposva): Determine if this gets in the way of Smi. |
| 5232 HEAP_OBJECT_IMPLEMENTATION(Instance, Object); | 5232 HEAP_OBJECT_IMPLEMENTATION(Instance, Object); |
| 5233 friend class ByteBuffer; | 5233 friend class ByteBuffer; |
| 5234 friend class Class; | 5234 friend class Class; |
| 5235 friend class Closure; | 5235 friend class Closure; |
| 5236 friend class DeferredObject; | 5236 friend class DeferredObject; |
| 5237 friend class JSRegExp; | 5237 friend class RegExp; |
| 5238 friend class SnapshotWriter; | 5238 friend class SnapshotWriter; |
| 5239 friend class StubCode; | 5239 friend class StubCode; |
| 5240 friend class TypedDataView; | 5240 friend class TypedDataView; |
| 5241 }; | 5241 }; |
| 5242 | 5242 |
| 5243 | 5243 |
| 5244 class LibraryPrefix : public Instance { | 5244 class LibraryPrefix : public Instance { |
| 5245 public: | 5245 public: |
| 5246 RawString* name() const { return raw_ptr()->name_; } | 5246 RawString* name() const { return raw_ptr()->name_; } |
| 5247 virtual RawString* DictionaryName() const { return name(); } | 5247 virtual RawString* DictionaryName() const { return name(); } |
| (...skipping 2783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8031 void set_pc_offset_array(const Array& pc_offset_array) const; | 8031 void set_pc_offset_array(const Array& pc_offset_array) const; |
| 8032 bool expand_inlined() const; | 8032 bool expand_inlined() const; |
| 8033 | 8033 |
| 8034 FINAL_HEAP_OBJECT_IMPLEMENTATION(Stacktrace, Instance); | 8034 FINAL_HEAP_OBJECT_IMPLEMENTATION(Stacktrace, Instance); |
| 8035 friend class Class; | 8035 friend class Class; |
| 8036 friend class Debugger; | 8036 friend class Debugger; |
| 8037 }; | 8037 }; |
| 8038 | 8038 |
| 8039 | 8039 |
| 8040 // Internal JavaScript regular expression object. | 8040 // Internal JavaScript regular expression object. |
| 8041 class JSRegExp : public Instance { | 8041 class RegExp : public Instance { |
| 8042 public: | 8042 public: |
| 8043 // Meaning of RegExType: | 8043 // Meaning of RegExType: |
| 8044 // kUninitialized: the type of th regexp has not been initialized yet. | 8044 // kUninitialized: the type of th regexp has not been initialized yet. |
| 8045 // kSimple: A simple pattern to match against, using string indexOf operation. | 8045 // kSimple: A simple pattern to match against, using string indexOf operation. |
| 8046 // kComplex: A complex pattern to match. | 8046 // kComplex: A complex pattern to match. |
| 8047 enum RegExType { | 8047 enum RegExType { |
| 8048 kUnitialized = 0, | 8048 kUnitialized = 0, |
| 8049 kSimple = 1, | 8049 kSimple = 1, |
| 8050 kComplex = 2, | 8050 kComplex = 2, |
| 8051 }; | 8051 }; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8085 } | 8085 } |
| 8086 | 8086 |
| 8087 RawTypedData* bytecode(bool is_one_byte) const { | 8087 RawTypedData* bytecode(bool is_one_byte) const { |
| 8088 return is_one_byte ? raw_ptr()->one_byte_bytecode_ | 8088 return is_one_byte ? raw_ptr()->one_byte_bytecode_ |
| 8089 : raw_ptr()->two_byte_bytecode_; | 8089 : raw_ptr()->two_byte_bytecode_; |
| 8090 } | 8090 } |
| 8091 | 8091 |
| 8092 static intptr_t function_offset(intptr_t cid) { | 8092 static intptr_t function_offset(intptr_t cid) { |
| 8093 switch (cid) { | 8093 switch (cid) { |
| 8094 case kOneByteStringCid: | 8094 case kOneByteStringCid: |
| 8095 return OFFSET_OF(RawJSRegExp, one_byte_function_); | 8095 return OFFSET_OF(RawRegExp, one_byte_function_); |
| 8096 case kTwoByteStringCid: | 8096 case kTwoByteStringCid: |
| 8097 return OFFSET_OF(RawJSRegExp, two_byte_function_); | 8097 return OFFSET_OF(RawRegExp, two_byte_function_); |
| 8098 case kExternalOneByteStringCid: | 8098 case kExternalOneByteStringCid: |
| 8099 return OFFSET_OF(RawJSRegExp, external_one_byte_function_); | 8099 return OFFSET_OF(RawRegExp, external_one_byte_function_); |
| 8100 case kExternalTwoByteStringCid: | 8100 case kExternalTwoByteStringCid: |
| 8101 return OFFSET_OF(RawJSRegExp, external_two_byte_function_); | 8101 return OFFSET_OF(RawRegExp, external_two_byte_function_); |
| 8102 } | 8102 } |
| 8103 | 8103 |
| 8104 UNREACHABLE(); | 8104 UNREACHABLE(); |
| 8105 return -1; | 8105 return -1; |
| 8106 } | 8106 } |
| 8107 | 8107 |
| 8108 RawFunction** FunctionAddr(intptr_t cid) const { | 8108 RawFunction** FunctionAddr(intptr_t cid) const { |
| 8109 return reinterpret_cast<RawFunction**>( | 8109 return reinterpret_cast<RawFunction**>( |
| 8110 FieldAddrAtOffset(function_offset(cid))); | 8110 FieldAddrAtOffset(function_offset(cid))); |
| 8111 } | 8111 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 8122 void set_is_global() const { set_flags(flags() | kGlobal); } | 8122 void set_is_global() const { set_flags(flags() | kGlobal); } |
| 8123 void set_is_ignore_case() const { set_flags(flags() | kIgnoreCase); } | 8123 void set_is_ignore_case() const { set_flags(flags() | kIgnoreCase); } |
| 8124 void set_is_multi_line() const { set_flags(flags() | kMultiLine); } | 8124 void set_is_multi_line() const { set_flags(flags() | kMultiLine); } |
| 8125 void set_is_simple() const { set_type(kSimple); } | 8125 void set_is_simple() const { set_type(kSimple); } |
| 8126 void set_is_complex() const { set_type(kComplex); } | 8126 void set_is_complex() const { set_type(kComplex); } |
| 8127 void set_num_registers(intptr_t value) const { | 8127 void set_num_registers(intptr_t value) const { |
| 8128 StoreNonPointer(&raw_ptr()->num_registers_, value); | 8128 StoreNonPointer(&raw_ptr()->num_registers_, value); |
| 8129 } | 8129 } |
| 8130 | 8130 |
| 8131 void* GetDataStartAddress() const; | 8131 void* GetDataStartAddress() const; |
| 8132 static RawJSRegExp* FromDataStartAddress(void* data); | 8132 static RawRegExp* FromDataStartAddress(void* data); |
| 8133 const char* Flags() const; | 8133 const char* Flags() const; |
| 8134 | 8134 |
| 8135 virtual bool CanonicalizeEquals(const Instance& other) const; | 8135 virtual bool CanonicalizeEquals(const Instance& other) const; |
| 8136 | 8136 |
| 8137 static intptr_t InstanceSize() { | 8137 static intptr_t InstanceSize() { |
| 8138 return RoundedAllocationSize(sizeof(RawJSRegExp)); | 8138 return RoundedAllocationSize(sizeof(RawRegExp)); |
| 8139 } | 8139 } |
| 8140 | 8140 |
| 8141 static RawJSRegExp* New(Heap::Space space = Heap::kNew); | 8141 static RawRegExp* New(Heap::Space space = Heap::kNew); |
| 8142 | 8142 |
| 8143 private: | 8143 private: |
| 8144 void set_type(RegExType type) const { | 8144 void set_type(RegExType type) const { |
| 8145 StoreNonPointer(&raw_ptr()->type_flags_, | 8145 StoreNonPointer(&raw_ptr()->type_flags_, |
| 8146 TypeBits::update(type, raw_ptr()->type_flags_)); | 8146 TypeBits::update(type, raw_ptr()->type_flags_)); |
| 8147 } | 8147 } |
| 8148 void set_flags(intptr_t value) const { | 8148 void set_flags(intptr_t value) const { |
| 8149 StoreNonPointer(&raw_ptr()->type_flags_, | 8149 StoreNonPointer(&raw_ptr()->type_flags_, |
| 8150 FlagsBits::update(value, raw_ptr()->type_flags_)); | 8150 FlagsBits::update(value, raw_ptr()->type_flags_)); |
| 8151 } | 8151 } |
| 8152 | 8152 |
| 8153 RegExType type() const { | 8153 RegExType type() const { |
| 8154 return TypeBits::decode(raw_ptr()->type_flags_); | 8154 return TypeBits::decode(raw_ptr()->type_flags_); |
| 8155 } | 8155 } |
| 8156 intptr_t flags() const { | 8156 intptr_t flags() const { |
| 8157 return FlagsBits::decode(raw_ptr()->type_flags_); | 8157 return FlagsBits::decode(raw_ptr()->type_flags_); |
| 8158 } | 8158 } |
| 8159 | 8159 |
| 8160 FINAL_HEAP_OBJECT_IMPLEMENTATION(JSRegExp, Instance); | 8160 FINAL_HEAP_OBJECT_IMPLEMENTATION(RegExp, Instance); |
| 8161 friend class Class; | 8161 friend class Class; |
| 8162 }; | 8162 }; |
| 8163 | 8163 |
| 8164 | 8164 |
| 8165 class WeakProperty : public Instance { | 8165 class WeakProperty : public Instance { |
| 8166 public: | 8166 public: |
| 8167 RawObject* key() const { | 8167 RawObject* key() const { |
| 8168 return raw_ptr()->key_; | 8168 return raw_ptr()->key_; |
| 8169 } | 8169 } |
| 8170 | 8170 |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8418 | 8418 |
| 8419 | 8419 |
| 8420 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 8420 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 8421 intptr_t index) { | 8421 intptr_t index) { |
| 8422 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 8422 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 8423 } | 8423 } |
| 8424 | 8424 |
| 8425 } // namespace dart | 8425 } // namespace dart |
| 8426 | 8426 |
| 8427 #endif // VM_OBJECT_H_ | 8427 #endif // VM_OBJECT_H_ |
| OLD | NEW |