| 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/become.h" | 10 #include "vm/become.h" |
| (...skipping 5678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5689 } | 5689 } |
| 5690 | 5690 |
| 5691 | 5691 |
| 5692 RawRegExp* Function::regexp() const { | 5692 RawRegExp* Function::regexp() const { |
| 5693 ASSERT(kind() == RawFunction::kIrregexpFunction); | 5693 ASSERT(kind() == RawFunction::kIrregexpFunction); |
| 5694 const Array& pair = Array::Cast(Object::Handle(raw_ptr()->data_)); | 5694 const Array& pair = Array::Cast(Object::Handle(raw_ptr()->data_)); |
| 5695 return RegExp::RawCast(pair.At(0)); | 5695 return RegExp::RawCast(pair.At(0)); |
| 5696 } | 5696 } |
| 5697 | 5697 |
| 5698 | 5698 |
| 5699 class StickySpecialization : public BitField<intptr_t, bool, 0, 1> {}; |
| 5700 class StringSpecializationCid |
| 5701 : public BitField<intptr_t, intptr_t, 1, RawObject::kClassIdTagSize> {}; |
| 5702 |
| 5703 |
| 5699 intptr_t Function::string_specialization_cid() const { | 5704 intptr_t Function::string_specialization_cid() const { |
| 5700 ASSERT(kind() == RawFunction::kIrregexpFunction); | 5705 ASSERT(kind() == RawFunction::kIrregexpFunction); |
| 5701 const Array& pair = Array::Cast(Object::Handle(raw_ptr()->data_)); | 5706 const Array& pair = Array::Cast(Object::Handle(raw_ptr()->data_)); |
| 5702 return Smi::Value(Smi::RawCast(pair.At(1))); | 5707 return StringSpecializationCid::decode(Smi::Value(Smi::RawCast(pair.At(1)))); |
| 5708 } |
| 5709 |
| 5710 |
| 5711 bool Function::is_sticky_specialization() const { |
| 5712 ASSERT(kind() == RawFunction::kIrregexpFunction); |
| 5713 const Array& pair = Array::Cast(Object::Handle(raw_ptr()->data_)); |
| 5714 return StickySpecialization::decode(Smi::Value(Smi::RawCast(pair.At(1)))); |
| 5703 } | 5715 } |
| 5704 | 5716 |
| 5705 | 5717 |
| 5706 void Function::SetRegExpData(const RegExp& regexp, | 5718 void Function::SetRegExpData(const RegExp& regexp, |
| 5707 intptr_t string_specialization_cid) const { | 5719 intptr_t string_specialization_cid, |
| 5720 bool sticky) const { |
| 5708 ASSERT(kind() == RawFunction::kIrregexpFunction); | 5721 ASSERT(kind() == RawFunction::kIrregexpFunction); |
| 5709 ASSERT(RawObject::IsStringClassId(string_specialization_cid)); | 5722 ASSERT(RawObject::IsStringClassId(string_specialization_cid)); |
| 5710 ASSERT(raw_ptr()->data_ == Object::null()); | 5723 ASSERT(raw_ptr()->data_ == Object::null()); |
| 5711 const Array& pair = Array::Handle(Array::New(2, Heap::kOld)); | 5724 const Array& pair = Array::Handle(Array::New(2, Heap::kOld)); |
| 5712 pair.SetAt(0, regexp); | 5725 pair.SetAt(0, regexp); |
| 5713 pair.SetAt(1, Smi::Handle(Smi::New(string_specialization_cid))); | 5726 pair.SetAt(1, Smi::Handle(Smi::New(StickySpecialization::encode(sticky) | |
| 5727 StringSpecializationCid::encode( |
| 5728 string_specialization_cid)))); |
| 5714 set_data(pair); | 5729 set_data(pair); |
| 5715 } | 5730 } |
| 5716 | 5731 |
| 5717 | 5732 |
| 5718 RawString* Function::native_name() const { | 5733 RawString* Function::native_name() const { |
| 5719 ASSERT(is_native()); | 5734 ASSERT(is_native()); |
| 5720 const Object& obj = Object::Handle(raw_ptr()->data_); | 5735 const Object& obj = Object::Handle(raw_ptr()->data_); |
| 5721 ASSERT(obj.IsArray()); | 5736 ASSERT(obj.IsArray()); |
| 5722 return String::RawCast(Array::Cast(obj).At(0)); | 5737 return String::RawCast(Array::Cast(obj).At(0)); |
| 5723 } | 5738 } |
| (...skipping 16661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 22385 chars[total_len] = '\0'; | 22400 chars[total_len] = '\0'; |
| 22386 return chars; | 22401 return chars; |
| 22387 } | 22402 } |
| 22388 | 22403 |
| 22389 | 22404 |
| 22390 void RegExp::set_pattern(const String& pattern) const { | 22405 void RegExp::set_pattern(const String& pattern) const { |
| 22391 StorePointer(&raw_ptr()->pattern_, pattern.raw()); | 22406 StorePointer(&raw_ptr()->pattern_, pattern.raw()); |
| 22392 } | 22407 } |
| 22393 | 22408 |
| 22394 | 22409 |
| 22395 void RegExp::set_function(intptr_t cid, const Function& value) const { | 22410 void RegExp::set_function(intptr_t cid, |
| 22396 StorePointer(FunctionAddr(cid), value.raw()); | 22411 bool sticky, |
| 22412 const Function& value) const { |
| 22413 StorePointer(FunctionAddr(cid, sticky), value.raw()); |
| 22397 } | 22414 } |
| 22398 | 22415 |
| 22399 | 22416 |
| 22400 void RegExp::set_bytecode(bool is_one_byte, const TypedData& bytecode) const { | 22417 void RegExp::set_bytecode(bool is_one_byte, |
| 22401 if (is_one_byte) { | 22418 bool sticky, |
| 22402 StorePointer(&raw_ptr()->one_byte_bytecode_, bytecode.raw()); | 22419 const TypedData& bytecode) const { |
| 22420 if (sticky) { |
| 22421 if (is_one_byte) { |
| 22422 StorePointer(&raw_ptr()->one_byte_sticky_.bytecode_, bytecode.raw()); |
| 22423 } else { |
| 22424 StorePointer(&raw_ptr()->two_byte_sticky_.bytecode_, bytecode.raw()); |
| 22425 } |
| 22403 } else { | 22426 } else { |
| 22404 StorePointer(&raw_ptr()->two_byte_bytecode_, bytecode.raw()); | 22427 if (is_one_byte) { |
| 22428 StorePointer(&raw_ptr()->one_byte_.bytecode_, bytecode.raw()); |
| 22429 } else { |
| 22430 StorePointer(&raw_ptr()->two_byte_.bytecode_, bytecode.raw()); |
| 22431 } |
| 22405 } | 22432 } |
| 22406 } | 22433 } |
| 22407 | 22434 |
| 22408 | 22435 |
| 22409 void RegExp::set_num_bracket_expressions(intptr_t value) const { | 22436 void RegExp::set_num_bracket_expressions(intptr_t value) const { |
| 22410 StoreSmi(&raw_ptr()->num_bracket_expressions_, Smi::New(value)); | 22437 StoreSmi(&raw_ptr()->num_bracket_expressions_, Smi::New(value)); |
| 22411 } | 22438 } |
| 22412 | 22439 |
| 22413 | 22440 |
| 22414 RawRegExp* RegExp::New(Heap::Space space) { | 22441 RawRegExp* RegExp::New(Heap::Space space) { |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 22689 return UserTag::null(); | 22716 return UserTag::null(); |
| 22690 } | 22717 } |
| 22691 | 22718 |
| 22692 | 22719 |
| 22693 const char* UserTag::ToCString() const { | 22720 const char* UserTag::ToCString() const { |
| 22694 const String& tag_label = String::Handle(label()); | 22721 const String& tag_label = String::Handle(label()); |
| 22695 return tag_label.ToCString(); | 22722 return tag_label.ToCString(); |
| 22696 } | 22723 } |
| 22697 | 22724 |
| 22698 } // namespace dart | 22725 } // namespace dart |
| OLD | NEW |