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 5541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5552 | 5552 |
5553 | 5553 |
5554 void Function::set_owner(const Object& value) const { | 5554 void Function::set_owner(const Object& value) const { |
5555 ASSERT(!value.IsNull()); | 5555 ASSERT(!value.IsNull()); |
5556 StorePointer(&raw_ptr()->owner_, value.raw()); | 5556 StorePointer(&raw_ptr()->owner_, value.raw()); |
5557 } | 5557 } |
5558 | 5558 |
5559 | 5559 |
5560 RawJSRegExp* Function::regexp() const { | 5560 RawJSRegExp* Function::regexp() const { |
5561 ASSERT(kind() == RawFunction::kIrregexpFunction); | 5561 ASSERT(kind() == RawFunction::kIrregexpFunction); |
5562 const Object& obj = Object::Handle(raw_ptr()->data_); | 5562 const Array& pair = Array::Cast(Object::Handle(raw_ptr()->data_)); |
5563 return JSRegExp::Cast(obj).raw(); | 5563 return JSRegExp::RawCast(pair.At(0)); |
5564 } | 5564 } |
5565 | 5565 |
5566 | 5566 |
5567 void Function::set_regexp(const JSRegExp& value) const { | 5567 intptr_t Function::string_specialization_cid() const { |
5568 ASSERT(kind() == RawFunction::kIrregexpFunction); | 5568 ASSERT(kind() == RawFunction::kIrregexpFunction); |
5569 ASSERT(raw_ptr()->data_ == Object::null()); | 5569 const Array& pair = Array::Cast(Object::Handle(raw_ptr()->data_)); |
5570 set_data(value); | 5570 return Smi::Value(Smi::RawCast(pair.At(1))); |
5571 } | 5571 } |
5572 | 5572 |
5573 | 5573 |
5574 void Function::set_regexp_cid(intptr_t regexp_cid) const { | 5574 void Function::SetRegExpData(const JSRegExp& regexp, |
5575 ASSERT((regexp_cid == kIllegalCid) || | 5575 intptr_t string_specialization_cid) const { |
5576 (kind() == RawFunction::kIrregexpFunction)); | 5576 ASSERT(kind() == RawFunction::kIrregexpFunction); |
5577 ASSERT((regexp_cid == kIllegalCid) || | 5577 ASSERT(RawObject::IsStringClassId(string_specialization_cid)); |
5578 RawObject::IsStringClassId(regexp_cid)); | 5578 ASSERT(raw_ptr()->data_ == Object::null()); |
5579 StoreNonPointer(&raw_ptr()->regexp_cid_, regexp_cid); | 5579 const Array& pair = Array::Handle(Array::New(2, Heap::kOld)); |
| 5580 pair.SetAt(0, regexp); |
| 5581 pair.SetAt(1, Smi::Handle(Smi::New(string_specialization_cid))); |
| 5582 set_data(pair); |
5580 } | 5583 } |
5581 | 5584 |
5582 | 5585 |
5583 void Function::set_result_type(const AbstractType& value) const { | 5586 void Function::set_result_type(const AbstractType& value) const { |
5584 ASSERT(!value.IsNull()); | 5587 ASSERT(!value.IsNull()); |
5585 StorePointer(&raw_ptr()->result_type_, value.raw()); | 5588 StorePointer(&raw_ptr()->result_type_, value.raw()); |
5586 } | 5589 } |
5587 | 5590 |
5588 | 5591 |
5589 RawAbstractType* Function::ParameterTypeAt(intptr_t index) const { | 5592 RawAbstractType* Function::ParameterTypeAt(intptr_t index) const { |
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6272 result.set_is_generated_body(false); | 6275 result.set_is_generated_body(false); |
6273 result.set_always_inline(false); | 6276 result.set_always_inline(false); |
6274 result.set_is_polymorphic_target(false); | 6277 result.set_is_polymorphic_target(false); |
6275 result.set_owner(owner); | 6278 result.set_owner(owner); |
6276 result.set_token_pos(token_pos); | 6279 result.set_token_pos(token_pos); |
6277 result.set_end_token_pos(token_pos); | 6280 result.set_end_token_pos(token_pos); |
6278 result.set_num_fixed_parameters(0); | 6281 result.set_num_fixed_parameters(0); |
6279 result.set_num_optional_parameters(0); | 6282 result.set_num_optional_parameters(0); |
6280 result.set_usage_counter(0); | 6283 result.set_usage_counter(0); |
6281 result.set_deoptimization_counter(0); | 6284 result.set_deoptimization_counter(0); |
6282 result.set_regexp_cid(kIllegalCid); | |
6283 result.set_optimized_instruction_count(0); | 6285 result.set_optimized_instruction_count(0); |
6284 result.set_optimized_call_site_count(0); | 6286 result.set_optimized_call_site_count(0); |
6285 result.set_is_optimizable(is_native ? false : true); | 6287 result.set_is_optimizable(is_native ? false : true); |
6286 result.set_is_inlinable(true); | 6288 result.set_is_inlinable(true); |
6287 result.set_allows_hoisting_check_class(true); | 6289 result.set_allows_hoisting_check_class(true); |
6288 result.set_allows_bounds_check_generalization(true); | 6290 result.set_allows_bounds_check_generalization(true); |
6289 result.SetInstructions(Code::Handle(StubCode::LazyCompile_entry()->code())); | 6291 result.SetInstructions(Code::Handle(StubCode::LazyCompile_entry()->code())); |
6290 if (kind == RawFunction::kClosureFunction) { | 6292 if (kind == RawFunction::kClosureFunction) { |
6291 const ClosureData& data = ClosureData::Handle(ClosureData::New()); | 6293 const ClosureData& data = ClosureData::Handle(ClosureData::New()); |
6292 result.set_data(data); | 6294 result.set_data(data); |
6293 } | 6295 } |
6294 return result.raw(); | 6296 return result.raw(); |
6295 } | 6297 } |
6296 | 6298 |
6297 | 6299 |
6298 RawFunction* Function::Clone(const Class& new_owner) const { | 6300 RawFunction* Function::Clone(const Class& new_owner) const { |
6299 ASSERT(!IsGenerativeConstructor()); | 6301 ASSERT(!IsGenerativeConstructor()); |
6300 Function& clone = Function::Handle(); | 6302 Function& clone = Function::Handle(); |
6301 clone ^= Object::Clone(*this, Heap::kOld); | 6303 clone ^= Object::Clone(*this, Heap::kOld); |
6302 const Class& origin = Class::Handle(this->origin()); | 6304 const Class& origin = Class::Handle(this->origin()); |
6303 const PatchClass& clone_owner = | 6305 const PatchClass& clone_owner = |
6304 PatchClass::Handle(PatchClass::New(new_owner, origin)); | 6306 PatchClass::Handle(PatchClass::New(new_owner, origin)); |
6305 clone.set_owner(clone_owner); | 6307 clone.set_owner(clone_owner); |
6306 clone.ClearICDataArray(); | 6308 clone.ClearICDataArray(); |
6307 clone.ClearCode(); | 6309 clone.ClearCode(); |
6308 clone.set_usage_counter(0); | 6310 clone.set_usage_counter(0); |
6309 clone.set_deoptimization_counter(0); | 6311 clone.set_deoptimization_counter(0); |
6310 clone.set_regexp_cid(kIllegalCid); | |
6311 clone.set_optimized_instruction_count(0); | 6312 clone.set_optimized_instruction_count(0); |
6312 clone.set_optimized_call_site_count(0); | 6313 clone.set_optimized_call_site_count(0); |
6313 if (new_owner.NumTypeParameters() > 0) { | 6314 if (new_owner.NumTypeParameters() > 0) { |
6314 // Adjust uninstantiated types to refer to type parameters of the new owner. | 6315 // Adjust uninstantiated types to refer to type parameters of the new owner. |
6315 AbstractType& type = AbstractType::Handle(clone.result_type()); | 6316 AbstractType& type = AbstractType::Handle(clone.result_type()); |
6316 type ^= type.CloneUninstantiated(new_owner); | 6317 type ^= type.CloneUninstantiated(new_owner); |
6317 clone.set_result_type(type); | 6318 clone.set_result_type(type); |
6318 const intptr_t num_params = clone.NumParameters(); | 6319 const intptr_t num_params = clone.NumParameters(); |
6319 Array& array = Array::Handle(clone.parameter_types()); | 6320 Array& array = Array::Handle(clone.parameter_types()); |
6320 array ^= Object::Clone(array, Heap::kOld); | 6321 array ^= Object::Clone(array, Heap::kOld); |
(...skipping 15059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21380 return tag_label.ToCString(); | 21381 return tag_label.ToCString(); |
21381 } | 21382 } |
21382 | 21383 |
21383 | 21384 |
21384 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 21385 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
21385 Instance::PrintJSONImpl(stream, ref); | 21386 Instance::PrintJSONImpl(stream, ref); |
21386 } | 21387 } |
21387 | 21388 |
21388 | 21389 |
21389 } // namespace dart | 21390 } // namespace dart |
OLD | NEW |