| 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 4668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4679 COMPILE_ASSERT(StubCode::kNoInstantiator == 0); | 4679 COMPILE_ASSERT(StubCode::kNoInstantiator == 0); |
| 4680 result.set_instantiations(Object::zero_array()); | 4680 result.set_instantiations(Object::zero_array()); |
| 4681 return result.raw(); | 4681 return result.raw(); |
| 4682 } | 4682 } |
| 4683 | 4683 |
| 4684 | 4684 |
| 4685 | 4685 |
| 4686 RawAbstractType** TypeArguments::TypeAddr(intptr_t index) const { | 4686 RawAbstractType** TypeArguments::TypeAddr(intptr_t index) const { |
| 4687 // TODO(iposva): Determine if we should throw an exception here. | 4687 // TODO(iposva): Determine if we should throw an exception here. |
| 4688 ASSERT((index >= 0) && (index < Length())); | 4688 ASSERT((index >= 0) && (index < Length())); |
| 4689 return &raw_ptr()->types_[index]; | 4689 return &raw_ptr()->types()[index]; |
| 4690 } | 4690 } |
| 4691 | 4691 |
| 4692 | 4692 |
| 4693 void TypeArguments::SetLength(intptr_t value) const { | 4693 void TypeArguments::SetLength(intptr_t value) const { |
| 4694 ASSERT(!IsCanonical()); | 4694 ASSERT(!IsCanonical()); |
| 4695 // This is only safe because we create a new Smi, which does not cause | 4695 // This is only safe because we create a new Smi, which does not cause |
| 4696 // heap allocation. | 4696 // heap allocation. |
| 4697 raw_ptr()->length_ = Smi::New(value); | 4697 raw_ptr()->length_ = Smi::New(value); |
| 4698 } | 4698 } |
| 4699 | 4699 |
| (...skipping 5693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10393 } | 10393 } |
| 10394 return 0; | 10394 return 0; |
| 10395 } | 10395 } |
| 10396 | 10396 |
| 10397 | 10397 |
| 10398 bool Stackmap::GetBit(intptr_t bit_index) const { | 10398 bool Stackmap::GetBit(intptr_t bit_index) const { |
| 10399 ASSERT(InRange(bit_index)); | 10399 ASSERT(InRange(bit_index)); |
| 10400 int byte_index = bit_index >> kBitsPerByteLog2; | 10400 int byte_index = bit_index >> kBitsPerByteLog2; |
| 10401 int bit_remainder = bit_index & (kBitsPerByte - 1); | 10401 int bit_remainder = bit_index & (kBitsPerByte - 1); |
| 10402 uint8_t byte_mask = 1U << bit_remainder; | 10402 uint8_t byte_mask = 1U << bit_remainder; |
| 10403 uint8_t byte = raw_ptr()->data_[byte_index]; | 10403 uint8_t byte = raw_ptr()->data()[byte_index]; |
| 10404 return (byte & byte_mask); | 10404 return (byte & byte_mask); |
| 10405 } | 10405 } |
| 10406 | 10406 |
| 10407 | 10407 |
| 10408 void Stackmap::SetBit(intptr_t bit_index, bool value) const { | 10408 void Stackmap::SetBit(intptr_t bit_index, bool value) const { |
| 10409 ASSERT(InRange(bit_index)); | 10409 ASSERT(InRange(bit_index)); |
| 10410 int byte_index = bit_index >> kBitsPerByteLog2; | 10410 int byte_index = bit_index >> kBitsPerByteLog2; |
| 10411 int bit_remainder = bit_index & (kBitsPerByte - 1); | 10411 int bit_remainder = bit_index & (kBitsPerByte - 1); |
| 10412 uint8_t byte_mask = 1U << bit_remainder; | 10412 uint8_t byte_mask = 1U << bit_remainder; |
| 10413 uint8_t* byte_addr = &(raw_ptr()->data_[byte_index]); | 10413 uint8_t* byte_addr = &(raw_ptr()->data()[byte_index]); |
| 10414 if (value) { | 10414 if (value) { |
| 10415 *byte_addr |= byte_mask; | 10415 *byte_addr |= byte_mask; |
| 10416 } else { | 10416 } else { |
| 10417 *byte_addr &= ~byte_mask; | 10417 *byte_addr &= ~byte_mask; |
| 10418 } | 10418 } |
| 10419 } | 10419 } |
| 10420 | 10420 |
| 10421 | 10421 |
| 10422 RawStackmap* Stackmap::New(intptr_t pc_offset, | 10422 RawStackmap* Stackmap::New(intptr_t pc_offset, |
| 10423 BitmapBuilder* bmap, | 10423 BitmapBuilder* bmap, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10499 } | 10499 } |
| 10500 | 10500 |
| 10501 | 10501 |
| 10502 void LocalVarDescriptors::SetVar(intptr_t var_index, | 10502 void LocalVarDescriptors::SetVar(intptr_t var_index, |
| 10503 const String& name, | 10503 const String& name, |
| 10504 RawLocalVarDescriptors::VarInfo* info) const { | 10504 RawLocalVarDescriptors::VarInfo* info) const { |
| 10505 ASSERT(var_index < Length()); | 10505 ASSERT(var_index < Length()); |
| 10506 const Array& names = Array::Handle(raw_ptr()->names_); | 10506 const Array& names = Array::Handle(raw_ptr()->names_); |
| 10507 ASSERT(Length() == names.Length()); | 10507 ASSERT(Length() == names.Length()); |
| 10508 names.SetAt(var_index, name); | 10508 names.SetAt(var_index, name); |
| 10509 raw_ptr()->data_[var_index] = *info; | 10509 raw_ptr()->data()[var_index] = *info; |
| 10510 } | 10510 } |
| 10511 | 10511 |
| 10512 | 10512 |
| 10513 void LocalVarDescriptors::GetInfo(intptr_t var_index, | 10513 void LocalVarDescriptors::GetInfo(intptr_t var_index, |
| 10514 RawLocalVarDescriptors::VarInfo* info) const { | 10514 RawLocalVarDescriptors::VarInfo* info) const { |
| 10515 ASSERT(var_index < Length()); | 10515 ASSERT(var_index < Length()); |
| 10516 *info = raw_ptr()->data_[var_index]; | 10516 *info = raw_ptr()->data()[var_index]; |
| 10517 } | 10517 } |
| 10518 | 10518 |
| 10519 | 10519 |
| 10520 static const char* VarKindString(int kind) { | 10520 static const char* VarKindString(int kind) { |
| 10521 switch (kind) { | 10521 switch (kind) { |
| 10522 case RawLocalVarDescriptors::kStackVar: | 10522 case RawLocalVarDescriptors::kStackVar: |
| 10523 return "StackVar"; | 10523 return "StackVar"; |
| 10524 break; | 10524 break; |
| 10525 case RawLocalVarDescriptors::kContextVar: | 10525 case RawLocalVarDescriptors::kContextVar: |
| 10526 return "ContextVar"; | 10526 return "ContextVar"; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10652 return raw_ptr()->length_; | 10652 return raw_ptr()->length_; |
| 10653 } | 10653 } |
| 10654 | 10654 |
| 10655 | 10655 |
| 10656 void ExceptionHandlers::SetHandlerInfo(intptr_t try_index, | 10656 void ExceptionHandlers::SetHandlerInfo(intptr_t try_index, |
| 10657 intptr_t outer_try_index, | 10657 intptr_t outer_try_index, |
| 10658 intptr_t handler_pc, | 10658 intptr_t handler_pc, |
| 10659 bool needs_stacktrace, | 10659 bool needs_stacktrace, |
| 10660 bool has_catch_all) const { | 10660 bool has_catch_all) const { |
| 10661 ASSERT((try_index >= 0) && (try_index < Length())); | 10661 ASSERT((try_index >= 0) && (try_index < Length())); |
| 10662 RawExceptionHandlers::HandlerInfo* info = &raw_ptr()->data_[try_index]; | 10662 RawExceptionHandlers::HandlerInfo* info = &raw_ptr()->data()[try_index]; |
| 10663 info->outer_try_index = outer_try_index; | 10663 info->outer_try_index = outer_try_index; |
| 10664 info->handler_pc = handler_pc; | 10664 info->handler_pc = handler_pc; |
| 10665 info->needs_stacktrace = needs_stacktrace; | 10665 info->needs_stacktrace = needs_stacktrace; |
| 10666 info->has_catch_all = has_catch_all; | 10666 info->has_catch_all = has_catch_all; |
| 10667 } | 10667 } |
| 10668 | 10668 |
| 10669 void ExceptionHandlers::GetHandlerInfo( | 10669 void ExceptionHandlers::GetHandlerInfo( |
| 10670 intptr_t try_index, | 10670 intptr_t try_index, |
| 10671 RawExceptionHandlers::HandlerInfo* info) const { | 10671 RawExceptionHandlers::HandlerInfo* info) const { |
| 10672 ASSERT((try_index >= 0) && (try_index < Length())); | 10672 ASSERT((try_index >= 0) && (try_index < Length())); |
| 10673 ASSERT(info != NULL); | 10673 ASSERT(info != NULL); |
| 10674 *info = raw_ptr()->data_[try_index]; | 10674 *info = raw_ptr()->data()[try_index]; |
| 10675 } | 10675 } |
| 10676 | 10676 |
| 10677 | 10677 |
| 10678 intptr_t ExceptionHandlers::HandlerPC(intptr_t try_index) const { | 10678 intptr_t ExceptionHandlers::HandlerPC(intptr_t try_index) const { |
| 10679 ASSERT((try_index >= 0) && (try_index < Length())); | 10679 ASSERT((try_index >= 0) && (try_index < Length())); |
| 10680 return raw_ptr()->data_[try_index].handler_pc; | 10680 return raw_ptr()->data()[try_index].handler_pc; |
| 10681 } | 10681 } |
| 10682 | 10682 |
| 10683 | 10683 |
| 10684 intptr_t ExceptionHandlers::OuterTryIndex(intptr_t try_index) const { | 10684 intptr_t ExceptionHandlers::OuterTryIndex(intptr_t try_index) const { |
| 10685 ASSERT((try_index >= 0) && (try_index < Length())); | 10685 ASSERT((try_index >= 0) && (try_index < Length())); |
| 10686 return raw_ptr()->data_[try_index].outer_try_index; | 10686 return raw_ptr()->data()[try_index].outer_try_index; |
| 10687 } | 10687 } |
| 10688 | 10688 |
| 10689 | 10689 |
| 10690 bool ExceptionHandlers::NeedsStacktrace(intptr_t try_index) const { | 10690 bool ExceptionHandlers::NeedsStacktrace(intptr_t try_index) const { |
| 10691 ASSERT((try_index >= 0) && (try_index < Length())); | 10691 ASSERT((try_index >= 0) && (try_index < Length())); |
| 10692 return raw_ptr()->data_[try_index].needs_stacktrace; | 10692 return raw_ptr()->data()[try_index].needs_stacktrace; |
| 10693 } | 10693 } |
| 10694 | 10694 |
| 10695 | 10695 |
| 10696 bool ExceptionHandlers::HasCatchAll(intptr_t try_index) const { | 10696 bool ExceptionHandlers::HasCatchAll(intptr_t try_index) const { |
| 10697 ASSERT((try_index >= 0) && (try_index < Length())); | 10697 ASSERT((try_index >= 0) && (try_index < Length())); |
| 10698 return raw_ptr()->data_[try_index].has_catch_all; | 10698 return raw_ptr()->data()[try_index].has_catch_all; |
| 10699 } | 10699 } |
| 10700 | 10700 |
| 10701 | 10701 |
| 10702 void ExceptionHandlers::SetHandledTypes(intptr_t try_index, | 10702 void ExceptionHandlers::SetHandledTypes(intptr_t try_index, |
| 10703 const Array& handled_types) const { | 10703 const Array& handled_types) const { |
| 10704 ASSERT((try_index >= 0) && (try_index < Length())); | 10704 ASSERT((try_index >= 0) && (try_index < Length())); |
| 10705 const Array& handled_types_data = | 10705 const Array& handled_types_data = |
| 10706 Array::Handle(raw_ptr()->handled_types_data_); | 10706 Array::Handle(raw_ptr()->handled_types_data_); |
| 10707 handled_types_data.SetAt(try_index, handled_types); | 10707 handled_types_data.SetAt(try_index, handled_types); |
| 10708 } | 10708 } |
| (...skipping 2416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13125 } | 13125 } |
| 13126 | 13126 |
| 13127 | 13127 |
| 13128 intptr_t* Instance::NativeFieldsDataAddr() const { | 13128 intptr_t* Instance::NativeFieldsDataAddr() const { |
| 13129 NoGCScope no_gc; | 13129 NoGCScope no_gc; |
| 13130 RawTypedData* native_fields = | 13130 RawTypedData* native_fields = |
| 13131 reinterpret_cast<RawTypedData*>(*NativeFieldsAddr()); | 13131 reinterpret_cast<RawTypedData*>(*NativeFieldsAddr()); |
| 13132 if (native_fields == TypedData::null()) { | 13132 if (native_fields == TypedData::null()) { |
| 13133 return NULL; | 13133 return NULL; |
| 13134 } | 13134 } |
| 13135 return reinterpret_cast<intptr_t*>(native_fields->ptr()->data_); | 13135 return reinterpret_cast<intptr_t*>(native_fields->ptr()->data()); |
| 13136 } | 13136 } |
| 13137 | 13137 |
| 13138 | 13138 |
| 13139 void Instance::SetNativeField(int index, intptr_t value) const { | 13139 void Instance::SetNativeField(int index, intptr_t value) const { |
| 13140 ASSERT(IsValidNativeIndex(index)); | 13140 ASSERT(IsValidNativeIndex(index)); |
| 13141 Object& native_fields = Object::Handle(*NativeFieldsAddr()); | 13141 Object& native_fields = Object::Handle(*NativeFieldsAddr()); |
| 13142 if (native_fields.IsNull()) { | 13142 if (native_fields.IsNull()) { |
| 13143 // Allocate backing storage for the native fields. | 13143 // Allocate backing storage for the native fields. |
| 13144 native_fields = TypedData::New(kIntPtrCid, NumNativeFields()); | 13144 native_fields = TypedData::New(kIntPtrCid, NumNativeFields()); |
| 13145 StorePointer(NativeFieldsAddr(), native_fields.raw()); | 13145 StorePointer(NativeFieldsAddr(), native_fields.raw()); |
| (...skipping 4221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17367 ASSERT(!str.IsNull() && str.IsOneByteString()); | 17367 ASSERT(!str.IsNull() && str.IsOneByteString()); |
| 17368 ASSERT(begin_index >= 0); | 17368 ASSERT(begin_index >= 0); |
| 17369 ASSERT(length >= 0); | 17369 ASSERT(length >= 0); |
| 17370 if (begin_index <= str.Length() && length == 0) { | 17370 if (begin_index <= str.Length() && length == 0) { |
| 17371 return OneByteString::raw(Symbols::Empty()); | 17371 return OneByteString::raw(Symbols::Empty()); |
| 17372 } | 17372 } |
| 17373 ASSERT(begin_index < str.Length()); | 17373 ASSERT(begin_index < str.Length()); |
| 17374 RawOneByteString* result = OneByteString::New(length, space); | 17374 RawOneByteString* result = OneByteString::New(length, space); |
| 17375 NoGCScope no_gc; | 17375 NoGCScope no_gc; |
| 17376 if (length > 0) { | 17376 if (length > 0) { |
| 17377 uint8_t* dest = &result->ptr()->data_[0]; | 17377 uint8_t* dest = &result->ptr()->data()[0]; |
| 17378 uint8_t* src = &raw_ptr(str)->data_[begin_index]; | 17378 uint8_t* src = &raw_ptr(str)->data()[begin_index]; |
| 17379 memmove(dest, src, length); | 17379 memmove(dest, src, length); |
| 17380 } | 17380 } |
| 17381 return result; | 17381 return result; |
| 17382 } | 17382 } |
| 17383 | 17383 |
| 17384 | 17384 |
| 17385 void OneByteString::SetPeer(const String& str, | 17385 void OneByteString::SetPeer(const String& str, |
| 17386 void* peer, | 17386 void* peer, |
| 17387 Dart_PeerFinalizer cback) { | 17387 Dart_PeerFinalizer cback) { |
| 17388 ASSERT(!str.IsNull() && str.IsOneByteString()); | 17388 ASSERT(!str.IsNull() && str.IsOneByteString()); |
| (...skipping 1699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19088 return tag_label.ToCString(); | 19088 return tag_label.ToCString(); |
| 19089 } | 19089 } |
| 19090 | 19090 |
| 19091 | 19091 |
| 19092 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 19092 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 19093 Instance::PrintJSONImpl(stream, ref); | 19093 Instance::PrintJSONImpl(stream, ref); |
| 19094 } | 19094 } |
| 19095 | 19095 |
| 19096 | 19096 |
| 19097 } // namespace dart | 19097 } // namespace dart |
| OLD | NEW |