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 #include "vm/object.h" | 5 #include "vm/object.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
(...skipping 4663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4674 COMPILE_ASSERT(StubCode::kNoInstantiator == 0); | 4674 COMPILE_ASSERT(StubCode::kNoInstantiator == 0); |
4675 result.set_instantiations(Object::zero_array()); | 4675 result.set_instantiations(Object::zero_array()); |
4676 return result.raw(); | 4676 return result.raw(); |
4677 } | 4677 } |
4678 | 4678 |
4679 | 4679 |
4680 | 4680 |
4681 RawAbstractType** TypeArguments::TypeAddr(intptr_t index) const { | 4681 RawAbstractType** TypeArguments::TypeAddr(intptr_t index) const { |
4682 // TODO(iposva): Determine if we should throw an exception here. | 4682 // TODO(iposva): Determine if we should throw an exception here. |
4683 ASSERT((index >= 0) && (index < Length())); | 4683 ASSERT((index >= 0) && (index < Length())); |
4684 return &raw_ptr()->types_[index]; | 4684 return &raw_ptr()->types()[index]; |
4685 } | 4685 } |
4686 | 4686 |
4687 | 4687 |
4688 void TypeArguments::SetLength(intptr_t value) const { | 4688 void TypeArguments::SetLength(intptr_t value) const { |
4689 ASSERT(!IsCanonical()); | 4689 ASSERT(!IsCanonical()); |
4690 // This is only safe because we create a new Smi, which does not cause | 4690 // This is only safe because we create a new Smi, which does not cause |
4691 // heap allocation. | 4691 // heap allocation. |
4692 raw_ptr()->length_ = Smi::New(value); | 4692 raw_ptr()->length_ = Smi::New(value); |
4693 } | 4693 } |
4694 | 4694 |
(...skipping 5591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10286 } | 10286 } |
10287 return 0; | 10287 return 0; |
10288 } | 10288 } |
10289 | 10289 |
10290 | 10290 |
10291 bool Stackmap::GetBit(intptr_t bit_index) const { | 10291 bool Stackmap::GetBit(intptr_t bit_index) const { |
10292 ASSERT(InRange(bit_index)); | 10292 ASSERT(InRange(bit_index)); |
10293 int byte_index = bit_index >> kBitsPerByteLog2; | 10293 int byte_index = bit_index >> kBitsPerByteLog2; |
10294 int bit_remainder = bit_index & (kBitsPerByte - 1); | 10294 int bit_remainder = bit_index & (kBitsPerByte - 1); |
10295 uint8_t byte_mask = 1U << bit_remainder; | 10295 uint8_t byte_mask = 1U << bit_remainder; |
10296 uint8_t byte = raw_ptr()->data_[byte_index]; | 10296 uint8_t byte = raw_ptr()->data()[byte_index]; |
10297 return (byte & byte_mask); | 10297 return (byte & byte_mask); |
10298 } | 10298 } |
10299 | 10299 |
10300 | 10300 |
10301 void Stackmap::SetBit(intptr_t bit_index, bool value) const { | 10301 void Stackmap::SetBit(intptr_t bit_index, bool value) const { |
10302 ASSERT(InRange(bit_index)); | 10302 ASSERT(InRange(bit_index)); |
10303 int byte_index = bit_index >> kBitsPerByteLog2; | 10303 int byte_index = bit_index >> kBitsPerByteLog2; |
10304 int bit_remainder = bit_index & (kBitsPerByte - 1); | 10304 int bit_remainder = bit_index & (kBitsPerByte - 1); |
10305 uint8_t byte_mask = 1U << bit_remainder; | 10305 uint8_t byte_mask = 1U << bit_remainder; |
10306 uint8_t* byte_addr = &(raw_ptr()->data_[byte_index]); | 10306 uint8_t* byte_addr = &(raw_ptr()->data()[byte_index]); |
10307 if (value) { | 10307 if (value) { |
10308 *byte_addr |= byte_mask; | 10308 *byte_addr |= byte_mask; |
10309 } else { | 10309 } else { |
10310 *byte_addr &= ~byte_mask; | 10310 *byte_addr &= ~byte_mask; |
10311 } | 10311 } |
10312 } | 10312 } |
10313 | 10313 |
10314 | 10314 |
10315 RawStackmap* Stackmap::New(intptr_t pc_offset, | 10315 RawStackmap* Stackmap::New(intptr_t pc_offset, |
10316 BitmapBuilder* bmap, | 10316 BitmapBuilder* bmap, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10392 } | 10392 } |
10393 | 10393 |
10394 | 10394 |
10395 void LocalVarDescriptors::SetVar(intptr_t var_index, | 10395 void LocalVarDescriptors::SetVar(intptr_t var_index, |
10396 const String& name, | 10396 const String& name, |
10397 RawLocalVarDescriptors::VarInfo* info) const { | 10397 RawLocalVarDescriptors::VarInfo* info) const { |
10398 ASSERT(var_index < Length()); | 10398 ASSERT(var_index < Length()); |
10399 const Array& names = Array::Handle(raw_ptr()->names_); | 10399 const Array& names = Array::Handle(raw_ptr()->names_); |
10400 ASSERT(Length() == names.Length()); | 10400 ASSERT(Length() == names.Length()); |
10401 names.SetAt(var_index, name); | 10401 names.SetAt(var_index, name); |
10402 raw_ptr()->data_[var_index] = *info; | 10402 raw_ptr()->data()[var_index] = *info; |
10403 } | 10403 } |
10404 | 10404 |
10405 | 10405 |
10406 void LocalVarDescriptors::GetInfo(intptr_t var_index, | 10406 void LocalVarDescriptors::GetInfo(intptr_t var_index, |
10407 RawLocalVarDescriptors::VarInfo* info) const { | 10407 RawLocalVarDescriptors::VarInfo* info) const { |
10408 ASSERT(var_index < Length()); | 10408 ASSERT(var_index < Length()); |
10409 *info = raw_ptr()->data_[var_index]; | 10409 *info = raw_ptr()->data()[var_index]; |
10410 } | 10410 } |
10411 | 10411 |
10412 | 10412 |
10413 static const char* VarKindString(int kind) { | 10413 static const char* VarKindString(int kind) { |
10414 switch (kind) { | 10414 switch (kind) { |
10415 case RawLocalVarDescriptors::kStackVar: | 10415 case RawLocalVarDescriptors::kStackVar: |
10416 return "StackVar"; | 10416 return "StackVar"; |
10417 break; | 10417 break; |
10418 case RawLocalVarDescriptors::kContextVar: | 10418 case RawLocalVarDescriptors::kContextVar: |
10419 return "ContextVar"; | 10419 return "ContextVar"; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10545 return raw_ptr()->length_; | 10545 return raw_ptr()->length_; |
10546 } | 10546 } |
10547 | 10547 |
10548 | 10548 |
10549 void ExceptionHandlers::SetHandlerInfo(intptr_t try_index, | 10549 void ExceptionHandlers::SetHandlerInfo(intptr_t try_index, |
10550 intptr_t outer_try_index, | 10550 intptr_t outer_try_index, |
10551 intptr_t handler_pc, | 10551 intptr_t handler_pc, |
10552 bool needs_stacktrace, | 10552 bool needs_stacktrace, |
10553 bool has_catch_all) const { | 10553 bool has_catch_all) const { |
10554 ASSERT((try_index >= 0) && (try_index < Length())); | 10554 ASSERT((try_index >= 0) && (try_index < Length())); |
10555 RawExceptionHandlers::HandlerInfo* info = &raw_ptr()->data_[try_index]; | 10555 RawExceptionHandlers::HandlerInfo* info = &raw_ptr()->data()[try_index]; |
10556 info->outer_try_index = outer_try_index; | 10556 info->outer_try_index = outer_try_index; |
10557 info->handler_pc = handler_pc; | 10557 info->handler_pc = handler_pc; |
10558 info->needs_stacktrace = needs_stacktrace; | 10558 info->needs_stacktrace = needs_stacktrace; |
10559 info->has_catch_all = has_catch_all; | 10559 info->has_catch_all = has_catch_all; |
10560 } | 10560 } |
10561 | 10561 |
10562 void ExceptionHandlers::GetHandlerInfo( | 10562 void ExceptionHandlers::GetHandlerInfo( |
10563 intptr_t try_index, | 10563 intptr_t try_index, |
10564 RawExceptionHandlers::HandlerInfo* info) const { | 10564 RawExceptionHandlers::HandlerInfo* info) const { |
10565 ASSERT((try_index >= 0) && (try_index < Length())); | 10565 ASSERT((try_index >= 0) && (try_index < Length())); |
10566 ASSERT(info != NULL); | 10566 ASSERT(info != NULL); |
10567 *info = raw_ptr()->data_[try_index]; | 10567 *info = raw_ptr()->data()[try_index]; |
10568 } | 10568 } |
10569 | 10569 |
10570 | 10570 |
10571 intptr_t ExceptionHandlers::HandlerPC(intptr_t try_index) const { | 10571 intptr_t ExceptionHandlers::HandlerPC(intptr_t try_index) const { |
10572 ASSERT((try_index >= 0) && (try_index < Length())); | 10572 ASSERT((try_index >= 0) && (try_index < Length())); |
10573 return raw_ptr()->data_[try_index].handler_pc; | 10573 return raw_ptr()->data()[try_index].handler_pc; |
10574 } | 10574 } |
10575 | 10575 |
10576 | 10576 |
10577 intptr_t ExceptionHandlers::OuterTryIndex(intptr_t try_index) const { | 10577 intptr_t ExceptionHandlers::OuterTryIndex(intptr_t try_index) const { |
10578 ASSERT((try_index >= 0) && (try_index < Length())); | 10578 ASSERT((try_index >= 0) && (try_index < Length())); |
10579 return raw_ptr()->data_[try_index].outer_try_index; | 10579 return raw_ptr()->data()[try_index].outer_try_index; |
10580 } | 10580 } |
10581 | 10581 |
10582 | 10582 |
10583 bool ExceptionHandlers::NeedsStacktrace(intptr_t try_index) const { | 10583 bool ExceptionHandlers::NeedsStacktrace(intptr_t try_index) const { |
10584 ASSERT((try_index >= 0) && (try_index < Length())); | 10584 ASSERT((try_index >= 0) && (try_index < Length())); |
10585 return raw_ptr()->data_[try_index].needs_stacktrace; | 10585 return raw_ptr()->data()[try_index].needs_stacktrace; |
10586 } | 10586 } |
10587 | 10587 |
10588 | 10588 |
10589 bool ExceptionHandlers::HasCatchAll(intptr_t try_index) const { | 10589 bool ExceptionHandlers::HasCatchAll(intptr_t try_index) const { |
10590 ASSERT((try_index >= 0) && (try_index < Length())); | 10590 ASSERT((try_index >= 0) && (try_index < Length())); |
10591 return raw_ptr()->data_[try_index].has_catch_all; | 10591 return raw_ptr()->data()[try_index].has_catch_all; |
10592 } | 10592 } |
10593 | 10593 |
10594 | 10594 |
10595 void ExceptionHandlers::SetHandledTypes(intptr_t try_index, | 10595 void ExceptionHandlers::SetHandledTypes(intptr_t try_index, |
10596 const Array& handled_types) const { | 10596 const Array& handled_types) const { |
10597 ASSERT((try_index >= 0) && (try_index < Length())); | 10597 ASSERT((try_index >= 0) && (try_index < Length())); |
10598 const Array& handled_types_data = | 10598 const Array& handled_types_data = |
10599 Array::Handle(raw_ptr()->handled_types_data_); | 10599 Array::Handle(raw_ptr()->handled_types_data_); |
10600 handled_types_data.SetAt(try_index, handled_types); | 10600 handled_types_data.SetAt(try_index, handled_types); |
10601 } | 10601 } |
(...skipping 2464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13066 } | 13066 } |
13067 | 13067 |
13068 | 13068 |
13069 intptr_t* Instance::NativeFieldsDataAddr() const { | 13069 intptr_t* Instance::NativeFieldsDataAddr() const { |
13070 NoGCScope no_gc; | 13070 NoGCScope no_gc; |
13071 RawTypedData* native_fields = | 13071 RawTypedData* native_fields = |
13072 reinterpret_cast<RawTypedData*>(*NativeFieldsAddr()); | 13072 reinterpret_cast<RawTypedData*>(*NativeFieldsAddr()); |
13073 if (native_fields == TypedData::null()) { | 13073 if (native_fields == TypedData::null()) { |
13074 return NULL; | 13074 return NULL; |
13075 } | 13075 } |
13076 return reinterpret_cast<intptr_t*>(native_fields->ptr()->data_); | 13076 return reinterpret_cast<intptr_t*>(native_fields->ptr()->data()); |
13077 } | 13077 } |
13078 | 13078 |
13079 | 13079 |
13080 void Instance::SetNativeField(int index, intptr_t value) const { | 13080 void Instance::SetNativeField(int index, intptr_t value) const { |
13081 ASSERT(IsValidNativeIndex(index)); | 13081 ASSERT(IsValidNativeIndex(index)); |
13082 Object& native_fields = Object::Handle(*NativeFieldsAddr()); | 13082 Object& native_fields = Object::Handle(*NativeFieldsAddr()); |
13083 if (native_fields.IsNull()) { | 13083 if (native_fields.IsNull()) { |
13084 // Allocate backing storage for the native fields. | 13084 // Allocate backing storage for the native fields. |
13085 native_fields = TypedData::New(kIntPtrCid, NumNativeFields()); | 13085 native_fields = TypedData::New(kIntPtrCid, NumNativeFields()); |
13086 StorePointer(NativeFieldsAddr(), native_fields.raw()); | 13086 StorePointer(NativeFieldsAddr(), native_fields.raw()); |
(...skipping 4213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17300 ASSERT(!str.IsNull() && str.IsOneByteString()); | 17300 ASSERT(!str.IsNull() && str.IsOneByteString()); |
17301 ASSERT(begin_index >= 0); | 17301 ASSERT(begin_index >= 0); |
17302 ASSERT(length >= 0); | 17302 ASSERT(length >= 0); |
17303 if (begin_index <= str.Length() && length == 0) { | 17303 if (begin_index <= str.Length() && length == 0) { |
17304 return OneByteString::raw(Symbols::Empty()); | 17304 return OneByteString::raw(Symbols::Empty()); |
17305 } | 17305 } |
17306 ASSERT(begin_index < str.Length()); | 17306 ASSERT(begin_index < str.Length()); |
17307 RawOneByteString* result = OneByteString::New(length, space); | 17307 RawOneByteString* result = OneByteString::New(length, space); |
17308 NoGCScope no_gc; | 17308 NoGCScope no_gc; |
17309 if (length > 0) { | 17309 if (length > 0) { |
17310 uint8_t* dest = &result->ptr()->data_[0]; | 17310 uint8_t* dest = &result->ptr()->data()[0]; |
17311 uint8_t* src = &raw_ptr(str)->data_[begin_index]; | 17311 uint8_t* src = &raw_ptr(str)->data()[begin_index]; |
17312 memmove(dest, src, length); | 17312 memmove(dest, src, length); |
17313 } | 17313 } |
17314 return result; | 17314 return result; |
17315 } | 17315 } |
17316 | 17316 |
17317 | 17317 |
17318 void OneByteString::SetPeer(const String& str, | 17318 void OneByteString::SetPeer(const String& str, |
17319 void* peer, | 17319 void* peer, |
17320 Dart_PeerFinalizer cback) { | 17320 Dart_PeerFinalizer cback) { |
17321 ASSERT(!str.IsNull() && str.IsOneByteString()); | 17321 ASSERT(!str.IsNull() && str.IsOneByteString()); |
(...skipping 1699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19021 return tag_label.ToCString(); | 19021 return tag_label.ToCString(); |
19022 } | 19022 } |
19023 | 19023 |
19024 | 19024 |
19025 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 19025 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
19026 Instance::PrintJSONImpl(stream, ref); | 19026 Instance::PrintJSONImpl(stream, ref); |
19027 } | 19027 } |
19028 | 19028 |
19029 | 19029 |
19030 } // namespace dart | 19030 } // namespace dart |
OLD | NEW |