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 5365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5376 break; | 5376 break; |
5377 case RawFunction::kMethodExtractor: | 5377 case RawFunction::kMethodExtractor: |
5378 return "kMethodExtractor"; | 5378 return "kMethodExtractor"; |
5379 break; | 5379 break; |
5380 case RawFunction::kNoSuchMethodDispatcher: | 5380 case RawFunction::kNoSuchMethodDispatcher: |
5381 return "kNoSuchMethodDispatcher"; | 5381 return "kNoSuchMethodDispatcher"; |
5382 break; | 5382 break; |
5383 case RawFunction::kInvokeFieldDispatcher: | 5383 case RawFunction::kInvokeFieldDispatcher: |
5384 return "kInvokeFieldDispatcher"; | 5384 return "kInvokeFieldDispatcher"; |
5385 break; | 5385 break; |
| 5386 case RawFunction::kIrregexpFunction: |
| 5387 return "kIrregexpFunction"; |
| 5388 break; |
5386 default: | 5389 default: |
5387 UNREACHABLE(); | 5390 UNREACHABLE(); |
5388 return NULL; | 5391 return NULL; |
5389 } | 5392 } |
5390 } | 5393 } |
5391 | 5394 |
5392 | 5395 |
5393 void Function::SetRedirectionType(const Type& type) const { | 5396 void Function::SetRedirectionType(const Type& type) const { |
5394 ASSERT(IsFactory()); | 5397 ASSERT(IsFactory()); |
5395 Object& obj = Object::Handle(raw_ptr()->data_); | 5398 Object& obj = Object::Handle(raw_ptr()->data_); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5461 StorePointer(&raw_ptr()->name_, value.raw()); | 5464 StorePointer(&raw_ptr()->name_, value.raw()); |
5462 } | 5465 } |
5463 | 5466 |
5464 | 5467 |
5465 void Function::set_owner(const Object& value) const { | 5468 void Function::set_owner(const Object& value) const { |
5466 ASSERT(!value.IsNull()); | 5469 ASSERT(!value.IsNull()); |
5467 StorePointer(&raw_ptr()->owner_, value.raw()); | 5470 StorePointer(&raw_ptr()->owner_, value.raw()); |
5468 } | 5471 } |
5469 | 5472 |
5470 | 5473 |
| 5474 RawJSRegExp* Function::regexp() const { |
| 5475 ASSERT(kind() == RawFunction::kIrregexpFunction); |
| 5476 const Object& obj = Object::Handle(raw_ptr()->data_); |
| 5477 return JSRegExp::Cast(obj).raw(); |
| 5478 } |
| 5479 |
| 5480 |
| 5481 void Function::set_regexp(const JSRegExp& value) const { |
| 5482 ASSERT(kind() == RawFunction::kIrregexpFunction); |
| 5483 ASSERT(raw_ptr()->data_ == Object::null()); |
| 5484 set_data(value); |
| 5485 } |
| 5486 |
| 5487 |
| 5488 void Function::set_regexp_cid(intptr_t regexp_cid) const { |
| 5489 ASSERT((regexp_cid == kIllegalCid) || |
| 5490 (kind() == RawFunction::kIrregexpFunction)); |
| 5491 ASSERT((regexp_cid == kIllegalCid) || |
| 5492 RawObject::IsStringClassId(regexp_cid)); |
| 5493 StoreNonPointer(&raw_ptr()->regexp_cid_, regexp_cid); |
| 5494 } |
| 5495 |
| 5496 |
5471 void Function::set_result_type(const AbstractType& value) const { | 5497 void Function::set_result_type(const AbstractType& value) const { |
5472 ASSERT(!value.IsNull()); | 5498 ASSERT(!value.IsNull()); |
5473 StorePointer(&raw_ptr()->result_type_, value.raw()); | 5499 StorePointer(&raw_ptr()->result_type_, value.raw()); |
5474 } | 5500 } |
5475 | 5501 |
5476 | 5502 |
5477 RawAbstractType* Function::ParameterTypeAt(intptr_t index) const { | 5503 RawAbstractType* Function::ParameterTypeAt(intptr_t index) const { |
5478 const Array& parameter_types = Array::Handle(raw_ptr()->parameter_types_); | 5504 const Array& parameter_types = Array::Handle(raw_ptr()->parameter_types_); |
5479 return AbstractType::RawCast(parameter_types.At(index)); | 5505 return AbstractType::RawCast(parameter_types.At(index)); |
5480 } | 5506 } |
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6141 result.set_is_async_closure(false); | 6167 result.set_is_async_closure(false); |
6142 result.set_always_inline(false); | 6168 result.set_always_inline(false); |
6143 result.set_is_polymorphic_target(false); | 6169 result.set_is_polymorphic_target(false); |
6144 result.set_owner(owner); | 6170 result.set_owner(owner); |
6145 result.set_token_pos(token_pos); | 6171 result.set_token_pos(token_pos); |
6146 result.set_end_token_pos(token_pos); | 6172 result.set_end_token_pos(token_pos); |
6147 result.set_num_fixed_parameters(0); | 6173 result.set_num_fixed_parameters(0); |
6148 result.set_num_optional_parameters(0); | 6174 result.set_num_optional_parameters(0); |
6149 result.set_usage_counter(0); | 6175 result.set_usage_counter(0); |
6150 result.set_deoptimization_counter(0); | 6176 result.set_deoptimization_counter(0); |
| 6177 result.set_regexp_cid(kIllegalCid); |
6151 result.set_optimized_instruction_count(0); | 6178 result.set_optimized_instruction_count(0); |
6152 result.set_optimized_call_site_count(0); | 6179 result.set_optimized_call_site_count(0); |
6153 result.set_is_optimizable(is_native ? false : true); | 6180 result.set_is_optimizable(is_native ? false : true); |
6154 result.set_is_inlinable(true); | 6181 result.set_is_inlinable(true); |
6155 result.set_allows_hoisting_check_class(true); | 6182 result.set_allows_hoisting_check_class(true); |
6156 result.set_allows_bounds_check_generalization(true); | 6183 result.set_allows_bounds_check_generalization(true); |
6157 StubCode* stub_code = Isolate::Current()->stub_code(); | 6184 StubCode* stub_code = Isolate::Current()->stub_code(); |
6158 result.SetInstructions(Code::Handle(stub_code->LazyCompile_entry()->code())); | 6185 result.SetInstructions(Code::Handle(stub_code->LazyCompile_entry()->code())); |
6159 if (kind == RawFunction::kClosureFunction) { | 6186 if (kind == RawFunction::kClosureFunction) { |
6160 const ClosureData& data = ClosureData::Handle(ClosureData::New()); | 6187 const ClosureData& data = ClosureData::Handle(ClosureData::New()); |
6161 result.set_data(data); | 6188 result.set_data(data); |
6162 } | 6189 } |
6163 | 6190 |
6164 return result.raw(); | 6191 return result.raw(); |
6165 } | 6192 } |
6166 | 6193 |
6167 | 6194 |
6168 RawFunction* Function::Clone(const Class& new_owner) const { | 6195 RawFunction* Function::Clone(const Class& new_owner) const { |
6169 ASSERT(!IsConstructor()); | 6196 ASSERT(!IsConstructor()); |
6170 Function& clone = Function::Handle(); | 6197 Function& clone = Function::Handle(); |
6171 clone ^= Object::Clone(*this, Heap::kOld); | 6198 clone ^= Object::Clone(*this, Heap::kOld); |
6172 const Class& origin = Class::Handle(this->origin()); | 6199 const Class& origin = Class::Handle(this->origin()); |
6173 const PatchClass& clone_owner = | 6200 const PatchClass& clone_owner = |
6174 PatchClass::Handle(PatchClass::New(new_owner, origin)); | 6201 PatchClass::Handle(PatchClass::New(new_owner, origin)); |
6175 clone.set_owner(clone_owner); | 6202 clone.set_owner(clone_owner); |
6176 clone.ClearCode(); | 6203 clone.ClearCode(); |
6177 clone.set_usage_counter(0); | 6204 clone.set_usage_counter(0); |
6178 clone.set_deoptimization_counter(0); | 6205 clone.set_deoptimization_counter(0); |
| 6206 clone.set_regexp_cid(kIllegalCid); |
6179 clone.set_optimized_instruction_count(0); | 6207 clone.set_optimized_instruction_count(0); |
6180 clone.set_optimized_call_site_count(0); | 6208 clone.set_optimized_call_site_count(0); |
6181 clone.set_ic_data_array(Array::Handle()); | 6209 clone.set_ic_data_array(Array::Handle()); |
6182 if (new_owner.NumTypeParameters() > 0) { | 6210 if (new_owner.NumTypeParameters() > 0) { |
6183 // Adjust uninstantiated types to refer to type parameters of the new owner. | 6211 // Adjust uninstantiated types to refer to type parameters of the new owner. |
6184 AbstractType& type = AbstractType::Handle(clone.result_type()); | 6212 AbstractType& type = AbstractType::Handle(clone.result_type()); |
6185 type ^= type.CloneUninstantiated(new_owner); | 6213 type ^= type.CloneUninstantiated(new_owner); |
6186 clone.set_result_type(type); | 6214 clone.set_result_type(type); |
6187 const intptr_t num_params = clone.NumParameters(); | 6215 const intptr_t num_params = clone.NumParameters(); |
6188 Array& array = Array::Handle(clone.parameter_types()); | 6216 Array& array = Array::Handle(clone.parameter_types()); |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6736 break; | 6764 break; |
6737 case RawFunction::kMethodExtractor: | 6765 case RawFunction::kMethodExtractor: |
6738 kind_str = " method-extractor"; | 6766 kind_str = " method-extractor"; |
6739 break; | 6767 break; |
6740 case RawFunction::kNoSuchMethodDispatcher: | 6768 case RawFunction::kNoSuchMethodDispatcher: |
6741 kind_str = " no-such-method-dispatcher"; | 6769 kind_str = " no-such-method-dispatcher"; |
6742 break; | 6770 break; |
6743 case RawFunction::kInvokeFieldDispatcher: | 6771 case RawFunction::kInvokeFieldDispatcher: |
6744 kind_str = "invoke-field-dispatcher"; | 6772 kind_str = "invoke-field-dispatcher"; |
6745 break; | 6773 break; |
| 6774 case RawFunction::kIrregexpFunction: |
| 6775 kind_str = "irregexp-function"; |
| 6776 break; |
6746 default: | 6777 default: |
6747 UNREACHABLE(); | 6778 UNREACHABLE(); |
6748 } | 6779 } |
6749 const char* kFormat = "Function '%s':%s%s%s%s."; | 6780 const char* kFormat = "Function '%s':%s%s%s%s."; |
6750 const char* function_name = String::Handle(name()).ToCString(); | 6781 const char* function_name = String::Handle(name()).ToCString(); |
6751 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, | 6782 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, |
6752 static_str, abstract_str, kind_str, const_str) + 1; | 6783 static_str, abstract_str, kind_str, const_str) + 1; |
6753 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 6784 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
6754 OS::SNPrint(chars, len, kFormat, function_name, | 6785 OS::SNPrint(chars, len, kFormat, function_name, |
6755 static_str, abstract_str, kind_str, const_str); | 6786 static_str, abstract_str, kind_str, const_str); |
(...skipping 13324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20080 chars[total_len] = '\0'; | 20111 chars[total_len] = '\0'; |
20081 return chars; | 20112 return chars; |
20082 } | 20113 } |
20083 | 20114 |
20084 | 20115 |
20085 void JSRegExp::set_pattern(const String& pattern) const { | 20116 void JSRegExp::set_pattern(const String& pattern) const { |
20086 StorePointer(&raw_ptr()->pattern_, pattern.raw()); | 20117 StorePointer(&raw_ptr()->pattern_, pattern.raw()); |
20087 } | 20118 } |
20088 | 20119 |
20089 | 20120 |
| 20121 void JSRegExp::set_function(intptr_t cid, const Function& value) const { |
| 20122 StorePointer(FunctionAddr(cid), value.raw()); |
| 20123 } |
| 20124 |
| 20125 |
20090 void JSRegExp::set_num_bracket_expressions(intptr_t value) const { | 20126 void JSRegExp::set_num_bracket_expressions(intptr_t value) const { |
20091 StoreSmi(&raw_ptr()->num_bracket_expressions_, Smi::New(value)); | 20127 StoreSmi(&raw_ptr()->num_bracket_expressions_, Smi::New(value)); |
20092 } | 20128 } |
20093 | 20129 |
20094 | 20130 |
20095 RawJSRegExp* JSRegExp::New(intptr_t len, Heap::Space space) { | 20131 RawJSRegExp* JSRegExp::New(intptr_t len, Heap::Space space) { |
20096 if (len < 0 || len > kMaxElements) { | 20132 if (len < 0 || len > kMaxElements) { |
20097 // This should be caught before we reach here. | 20133 // This should be caught before we reach here. |
20098 FATAL1("Fatal error in JSRegexp::New: invalid len %" Pd "\n", len); | 20134 FATAL1("Fatal error in JSRegexp::New: invalid len %" Pd "\n", len); |
20099 } | 20135 } |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20416 return tag_label.ToCString(); | 20452 return tag_label.ToCString(); |
20417 } | 20453 } |
20418 | 20454 |
20419 | 20455 |
20420 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20456 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
20421 Instance::PrintJSONImpl(stream, ref); | 20457 Instance::PrintJSONImpl(stream, ref); |
20422 } | 20458 } |
20423 | 20459 |
20424 | 20460 |
20425 } // namespace dart | 20461 } // namespace dart |
OLD | NEW |