| 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 4667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4678 COMPILE_ASSERT(StubCode::kNoInstantiator == 0); | 4678 COMPILE_ASSERT(StubCode::kNoInstantiator == 0); |
| 4679 result.set_instantiations(Object::zero_array()); | 4679 result.set_instantiations(Object::zero_array()); |
| 4680 return result.raw(); | 4680 return result.raw(); |
| 4681 } | 4681 } |
| 4682 | 4682 |
| 4683 | 4683 |
| 4684 | 4684 |
| 4685 RawAbstractType** TypeArguments::TypeAddr(intptr_t index) const { | 4685 RawAbstractType** TypeArguments::TypeAddr(intptr_t index) const { |
| 4686 // TODO(iposva): Determine if we should throw an exception here. | 4686 // TODO(iposva): Determine if we should throw an exception here. |
| 4687 ASSERT((index >= 0) && (index < Length())); | 4687 ASSERT((index >= 0) && (index < Length())); |
| 4688 return &raw_ptr()->types_[index]; | 4688 return &raw_ptr()->types()[index]; |
| 4689 } | 4689 } |
| 4690 | 4690 |
| 4691 | 4691 |
| 4692 void TypeArguments::SetLength(intptr_t value) const { | 4692 void TypeArguments::SetLength(intptr_t value) const { |
| 4693 ASSERT(!IsCanonical()); | 4693 ASSERT(!IsCanonical()); |
| 4694 // This is only safe because we create a new Smi, which does not cause | 4694 // This is only safe because we create a new Smi, which does not cause |
| 4695 // heap allocation. | 4695 // heap allocation. |
| 4696 raw_ptr()->length_ = Smi::New(value); | 4696 raw_ptr()->length_ = Smi::New(value); |
| 4697 } | 4697 } |
| 4698 | 4698 |
| (...skipping 5634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10333 } | 10333 } |
| 10334 return 0; | 10334 return 0; |
| 10335 } | 10335 } |
| 10336 | 10336 |
| 10337 | 10337 |
| 10338 bool Stackmap::GetBit(intptr_t bit_index) const { | 10338 bool Stackmap::GetBit(intptr_t bit_index) const { |
| 10339 ASSERT(InRange(bit_index)); | 10339 ASSERT(InRange(bit_index)); |
| 10340 int byte_index = bit_index >> kBitsPerByteLog2; | 10340 int byte_index = bit_index >> kBitsPerByteLog2; |
| 10341 int bit_remainder = bit_index & (kBitsPerByte - 1); | 10341 int bit_remainder = bit_index & (kBitsPerByte - 1); |
| 10342 uint8_t byte_mask = 1U << bit_remainder; | 10342 uint8_t byte_mask = 1U << bit_remainder; |
| 10343 uint8_t byte = raw_ptr()->data_[byte_index]; | 10343 uint8_t byte = raw_ptr()->data()[byte_index]; |
| 10344 return (byte & byte_mask); | 10344 return (byte & byte_mask); |
| 10345 } | 10345 } |
| 10346 | 10346 |
| 10347 | 10347 |
| 10348 void Stackmap::SetBit(intptr_t bit_index, bool value) const { | 10348 void Stackmap::SetBit(intptr_t bit_index, bool value) const { |
| 10349 ASSERT(InRange(bit_index)); | 10349 ASSERT(InRange(bit_index)); |
| 10350 int byte_index = bit_index >> kBitsPerByteLog2; | 10350 int byte_index = bit_index >> kBitsPerByteLog2; |
| 10351 int bit_remainder = bit_index & (kBitsPerByte - 1); | 10351 int bit_remainder = bit_index & (kBitsPerByte - 1); |
| 10352 uint8_t byte_mask = 1U << bit_remainder; | 10352 uint8_t byte_mask = 1U << bit_remainder; |
| 10353 uint8_t* byte_addr = &(raw_ptr()->data_[byte_index]); | 10353 uint8_t* byte_addr = &(raw_ptr()->data()[byte_index]); |
| 10354 if (value) { | 10354 if (value) { |
| 10355 *byte_addr |= byte_mask; | 10355 *byte_addr |= byte_mask; |
| 10356 } else { | 10356 } else { |
| 10357 *byte_addr &= ~byte_mask; | 10357 *byte_addr &= ~byte_mask; |
| 10358 } | 10358 } |
| 10359 } | 10359 } |
| 10360 | 10360 |
| 10361 | 10361 |
| 10362 RawStackmap* Stackmap::New(intptr_t pc_offset, | 10362 RawStackmap* Stackmap::New(intptr_t pc_offset, |
| 10363 BitmapBuilder* bmap, | 10363 BitmapBuilder* bmap, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10439 } | 10439 } |
| 10440 | 10440 |
| 10441 | 10441 |
| 10442 void LocalVarDescriptors::SetVar(intptr_t var_index, | 10442 void LocalVarDescriptors::SetVar(intptr_t var_index, |
| 10443 const String& name, | 10443 const String& name, |
| 10444 RawLocalVarDescriptors::VarInfo* info) const { | 10444 RawLocalVarDescriptors::VarInfo* info) const { |
| 10445 ASSERT(var_index < Length()); | 10445 ASSERT(var_index < Length()); |
| 10446 const Array& names = Array::Handle(raw_ptr()->names_); | 10446 const Array& names = Array::Handle(raw_ptr()->names_); |
| 10447 ASSERT(Length() == names.Length()); | 10447 ASSERT(Length() == names.Length()); |
| 10448 names.SetAt(var_index, name); | 10448 names.SetAt(var_index, name); |
| 10449 raw_ptr()->data_[var_index] = *info; | 10449 raw_ptr()->data()[var_index] = *info; |
| 10450 } | 10450 } |
| 10451 | 10451 |
| 10452 | 10452 |
| 10453 void LocalVarDescriptors::GetInfo(intptr_t var_index, | 10453 void LocalVarDescriptors::GetInfo(intptr_t var_index, |
| 10454 RawLocalVarDescriptors::VarInfo* info) const { | 10454 RawLocalVarDescriptors::VarInfo* info) const { |
| 10455 ASSERT(var_index < Length()); | 10455 ASSERT(var_index < Length()); |
| 10456 *info = raw_ptr()->data_[var_index]; | 10456 *info = raw_ptr()->data()[var_index]; |
| 10457 } | 10457 } |
| 10458 | 10458 |
| 10459 | 10459 |
| 10460 static const char* VarKindString(int kind) { | 10460 static const char* VarKindString(int kind) { |
| 10461 switch (kind) { | 10461 switch (kind) { |
| 10462 case RawLocalVarDescriptors::kStackVar: | 10462 case RawLocalVarDescriptors::kStackVar: |
| 10463 return "StackVar"; | 10463 return "StackVar"; |
| 10464 break; | 10464 break; |
| 10465 case RawLocalVarDescriptors::kContextVar: | 10465 case RawLocalVarDescriptors::kContextVar: |
| 10466 return "ContextVar"; | 10466 return "ContextVar"; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10592 return raw_ptr()->length_; | 10592 return raw_ptr()->length_; |
| 10593 } | 10593 } |
| 10594 | 10594 |
| 10595 | 10595 |
| 10596 void ExceptionHandlers::SetHandlerInfo(intptr_t try_index, | 10596 void ExceptionHandlers::SetHandlerInfo(intptr_t try_index, |
| 10597 intptr_t outer_try_index, | 10597 intptr_t outer_try_index, |
| 10598 intptr_t handler_pc, | 10598 intptr_t handler_pc, |
| 10599 bool needs_stacktrace, | 10599 bool needs_stacktrace, |
| 10600 bool has_catch_all) const { | 10600 bool has_catch_all) const { |
| 10601 ASSERT((try_index >= 0) && (try_index < Length())); | 10601 ASSERT((try_index >= 0) && (try_index < Length())); |
| 10602 RawExceptionHandlers::HandlerInfo* info = &raw_ptr()->data_[try_index]; | 10602 RawExceptionHandlers::HandlerInfo* info = &raw_ptr()->data()[try_index]; |
| 10603 info->outer_try_index = outer_try_index; | 10603 info->outer_try_index = outer_try_index; |
| 10604 info->handler_pc = handler_pc; | 10604 info->handler_pc = handler_pc; |
| 10605 info->needs_stacktrace = needs_stacktrace; | 10605 info->needs_stacktrace = needs_stacktrace; |
| 10606 info->has_catch_all = has_catch_all; | 10606 info->has_catch_all = has_catch_all; |
| 10607 } | 10607 } |
| 10608 | 10608 |
| 10609 void ExceptionHandlers::GetHandlerInfo( | 10609 void ExceptionHandlers::GetHandlerInfo( |
| 10610 intptr_t try_index, | 10610 intptr_t try_index, |
| 10611 RawExceptionHandlers::HandlerInfo* info) const { | 10611 RawExceptionHandlers::HandlerInfo* info) const { |
| 10612 ASSERT((try_index >= 0) && (try_index < Length())); | 10612 ASSERT((try_index >= 0) && (try_index < Length())); |
| 10613 ASSERT(info != NULL); | 10613 ASSERT(info != NULL); |
| 10614 *info = raw_ptr()->data_[try_index]; | 10614 *info = raw_ptr()->data()[try_index]; |
| 10615 } | 10615 } |
| 10616 | 10616 |
| 10617 | 10617 |
| 10618 intptr_t ExceptionHandlers::HandlerPC(intptr_t try_index) const { | 10618 intptr_t ExceptionHandlers::HandlerPC(intptr_t try_index) const { |
| 10619 ASSERT((try_index >= 0) && (try_index < Length())); | 10619 ASSERT((try_index >= 0) && (try_index < Length())); |
| 10620 return raw_ptr()->data_[try_index].handler_pc; | 10620 return raw_ptr()->data()[try_index].handler_pc; |
| 10621 } | 10621 } |
| 10622 | 10622 |
| 10623 | 10623 |
| 10624 intptr_t ExceptionHandlers::OuterTryIndex(intptr_t try_index) const { | 10624 intptr_t ExceptionHandlers::OuterTryIndex(intptr_t try_index) const { |
| 10625 ASSERT((try_index >= 0) && (try_index < Length())); | 10625 ASSERT((try_index >= 0) && (try_index < Length())); |
| 10626 return raw_ptr()->data_[try_index].outer_try_index; | 10626 return raw_ptr()->data()[try_index].outer_try_index; |
| 10627 } | 10627 } |
| 10628 | 10628 |
| 10629 | 10629 |
| 10630 bool ExceptionHandlers::NeedsStacktrace(intptr_t try_index) const { | 10630 bool ExceptionHandlers::NeedsStacktrace(intptr_t try_index) const { |
| 10631 ASSERT((try_index >= 0) && (try_index < Length())); | 10631 ASSERT((try_index >= 0) && (try_index < Length())); |
| 10632 return raw_ptr()->data_[try_index].needs_stacktrace; | 10632 return raw_ptr()->data()[try_index].needs_stacktrace; |
| 10633 } | 10633 } |
| 10634 | 10634 |
| 10635 | 10635 |
| 10636 bool ExceptionHandlers::HasCatchAll(intptr_t try_index) const { | 10636 bool ExceptionHandlers::HasCatchAll(intptr_t try_index) const { |
| 10637 ASSERT((try_index >= 0) && (try_index < Length())); | 10637 ASSERT((try_index >= 0) && (try_index < Length())); |
| 10638 return raw_ptr()->data_[try_index].has_catch_all; | 10638 return raw_ptr()->data()[try_index].has_catch_all; |
| 10639 } | 10639 } |
| 10640 | 10640 |
| 10641 | 10641 |
| 10642 void ExceptionHandlers::SetHandledTypes(intptr_t try_index, | 10642 void ExceptionHandlers::SetHandledTypes(intptr_t try_index, |
| 10643 const Array& handled_types) const { | 10643 const Array& handled_types) const { |
| 10644 ASSERT((try_index >= 0) && (try_index < Length())); | 10644 ASSERT((try_index >= 0) && (try_index < Length())); |
| 10645 const Array& handled_types_data = | 10645 const Array& handled_types_data = |
| 10646 Array::Handle(raw_ptr()->handled_types_data_); | 10646 Array::Handle(raw_ptr()->handled_types_data_); |
| 10647 handled_types_data.SetAt(try_index, handled_types); | 10647 handled_types_data.SetAt(try_index, handled_types); |
| 10648 } | 10648 } |
| (...skipping 2464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13113 } | 13113 } |
| 13114 | 13114 |
| 13115 | 13115 |
| 13116 intptr_t* Instance::NativeFieldsDataAddr() const { | 13116 intptr_t* Instance::NativeFieldsDataAddr() const { |
| 13117 NoGCScope no_gc; | 13117 NoGCScope no_gc; |
| 13118 RawTypedData* native_fields = | 13118 RawTypedData* native_fields = |
| 13119 reinterpret_cast<RawTypedData*>(*NativeFieldsAddr()); | 13119 reinterpret_cast<RawTypedData*>(*NativeFieldsAddr()); |
| 13120 if (native_fields == TypedData::null()) { | 13120 if (native_fields == TypedData::null()) { |
| 13121 return NULL; | 13121 return NULL; |
| 13122 } | 13122 } |
| 13123 return reinterpret_cast<intptr_t*>(native_fields->ptr()->data_); | 13123 return reinterpret_cast<intptr_t*>(native_fields->ptr()->data()); |
| 13124 } | 13124 } |
| 13125 | 13125 |
| 13126 | 13126 |
| 13127 void Instance::SetNativeField(int index, intptr_t value) const { | 13127 void Instance::SetNativeField(int index, intptr_t value) const { |
| 13128 ASSERT(IsValidNativeIndex(index)); | 13128 ASSERT(IsValidNativeIndex(index)); |
| 13129 Object& native_fields = Object::Handle(*NativeFieldsAddr()); | 13129 Object& native_fields = Object::Handle(*NativeFieldsAddr()); |
| 13130 if (native_fields.IsNull()) { | 13130 if (native_fields.IsNull()) { |
| 13131 // Allocate backing storage for the native fields. | 13131 // Allocate backing storage for the native fields. |
| 13132 native_fields = TypedData::New(kIntPtrCid, NumNativeFields()); | 13132 native_fields = TypedData::New(kIntPtrCid, NumNativeFields()); |
| 13133 StorePointer(NativeFieldsAddr(), native_fields.raw()); | 13133 StorePointer(NativeFieldsAddr(), native_fields.raw()); |
| (...skipping 4213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17347 ASSERT(!str.IsNull() && str.IsOneByteString()); | 17347 ASSERT(!str.IsNull() && str.IsOneByteString()); |
| 17348 ASSERT(begin_index >= 0); | 17348 ASSERT(begin_index >= 0); |
| 17349 ASSERT(length >= 0); | 17349 ASSERT(length >= 0); |
| 17350 if (begin_index <= str.Length() && length == 0) { | 17350 if (begin_index <= str.Length() && length == 0) { |
| 17351 return OneByteString::raw(Symbols::Empty()); | 17351 return OneByteString::raw(Symbols::Empty()); |
| 17352 } | 17352 } |
| 17353 ASSERT(begin_index < str.Length()); | 17353 ASSERT(begin_index < str.Length()); |
| 17354 RawOneByteString* result = OneByteString::New(length, space); | 17354 RawOneByteString* result = OneByteString::New(length, space); |
| 17355 NoGCScope no_gc; | 17355 NoGCScope no_gc; |
| 17356 if (length > 0) { | 17356 if (length > 0) { |
| 17357 uint8_t* dest = &result->ptr()->data_[0]; | 17357 uint8_t* dest = &result->ptr()->data()[0]; |
| 17358 uint8_t* src = &raw_ptr(str)->data_[begin_index]; | 17358 uint8_t* src = &raw_ptr(str)->data()[begin_index]; |
| 17359 memmove(dest, src, length); | 17359 memmove(dest, src, length); |
| 17360 } | 17360 } |
| 17361 return result; | 17361 return result; |
| 17362 } | 17362 } |
| 17363 | 17363 |
| 17364 | 17364 |
| 17365 void OneByteString::SetPeer(const String& str, | 17365 void OneByteString::SetPeer(const String& str, |
| 17366 void* peer, | 17366 void* peer, |
| 17367 Dart_PeerFinalizer cback) { | 17367 Dart_PeerFinalizer cback) { |
| 17368 ASSERT(!str.IsNull() && str.IsOneByteString()); | 17368 ASSERT(!str.IsNull() && str.IsOneByteString()); |
| (...skipping 1699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19068 return tag_label.ToCString(); | 19068 return tag_label.ToCString(); |
| 19069 } | 19069 } |
| 19070 | 19070 |
| 19071 | 19071 |
| 19072 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 19072 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 19073 Instance::PrintJSONImpl(stream, ref); | 19073 Instance::PrintJSONImpl(stream, ref); |
| 19074 } | 19074 } |
| 19075 | 19075 |
| 19076 | 19076 |
| 19077 } // namespace dart | 19077 } // namespace dart |
| OLD | NEW |