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 5341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5352 break; | 5352 break; |
5353 case RawFunction::kMethodExtractor: | 5353 case RawFunction::kMethodExtractor: |
5354 return "kMethodExtractor"; | 5354 return "kMethodExtractor"; |
5355 break; | 5355 break; |
5356 case RawFunction::kNoSuchMethodDispatcher: | 5356 case RawFunction::kNoSuchMethodDispatcher: |
5357 return "kNoSuchMethodDispatcher"; | 5357 return "kNoSuchMethodDispatcher"; |
5358 break; | 5358 break; |
5359 case RawFunction::kInvokeFieldDispatcher: | 5359 case RawFunction::kInvokeFieldDispatcher: |
5360 return "kInvokeFieldDispatcher"; | 5360 return "kInvokeFieldDispatcher"; |
5361 break; | 5361 break; |
5362 case RawFunction::kIrregexpFunction: | |
5363 return "kIrregexpFunction"; | |
5364 break; | |
5362 default: | 5365 default: |
5363 UNREACHABLE(); | 5366 UNREACHABLE(); |
5364 return NULL; | 5367 return NULL; |
5365 } | 5368 } |
5366 } | 5369 } |
5367 | 5370 |
5368 | 5371 |
5369 void Function::SetRedirectionType(const Type& type) const { | 5372 void Function::SetRedirectionType(const Type& type) const { |
5370 ASSERT(IsFactory()); | 5373 ASSERT(IsFactory()); |
5371 Object& obj = Object::Handle(raw_ptr()->data_); | 5374 Object& obj = Object::Handle(raw_ptr()->data_); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5437 StorePointer(&raw_ptr()->name_, value.raw()); | 5440 StorePointer(&raw_ptr()->name_, value.raw()); |
5438 } | 5441 } |
5439 | 5442 |
5440 | 5443 |
5441 void Function::set_owner(const Object& value) const { | 5444 void Function::set_owner(const Object& value) const { |
5442 ASSERT(!value.IsNull()); | 5445 ASSERT(!value.IsNull()); |
5443 StorePointer(&raw_ptr()->owner_, value.raw()); | 5446 StorePointer(&raw_ptr()->owner_, value.raw()); |
5444 } | 5447 } |
5445 | 5448 |
5446 | 5449 |
5450 RawJSRegExp* Function::regexp() const { | |
5451 ASSERT(kind() == RawFunction::kIrregexpFunction); | |
5452 const Object& obj = Object::Handle(raw_ptr()->data_); | |
5453 ASSERT(obj.IsJSRegExp()); | |
Ivan Posva
2014/11/05 07:55:09
The Cast below is executing this assertion exactly
zerny-google
2014/11/05 11:51:59
Removed the assert.
| |
5454 return JSRegExp::Cast(obj).raw(); | |
5455 } | |
5456 | |
5457 | |
5458 void Function::set_regexp(const JSRegExp& value) const { | |
5459 ASSERT(kind() == RawFunction::kIrregexpFunction); | |
5460 ASSERT(raw_ptr()->data_ == Object::null()); | |
5461 set_data(value); | |
5462 } | |
5463 | |
5464 | |
5465 void Function::set_regexp_cid(intptr_t regexp_cid) const { | |
5466 ASSERT((regexp_cid == kIllegalCid) || | |
5467 (kind() == RawFunction::kIrregexpFunction)); | |
5468 ASSERT((regexp_cid == kIllegalCid) || | |
5469 RawObject::IsStringClassId(regexp_cid)); | |
5470 StoreNonPointer(&raw_ptr()->regexp_cid_, regexp_cid); | |
5471 } | |
5472 | |
5473 | |
5447 void Function::set_result_type(const AbstractType& value) const { | 5474 void Function::set_result_type(const AbstractType& value) const { |
5448 ASSERT(!value.IsNull()); | 5475 ASSERT(!value.IsNull()); |
5449 StorePointer(&raw_ptr()->result_type_, value.raw()); | 5476 StorePointer(&raw_ptr()->result_type_, value.raw()); |
5450 } | 5477 } |
5451 | 5478 |
5452 | 5479 |
5453 RawAbstractType* Function::ParameterTypeAt(intptr_t index) const { | 5480 RawAbstractType* Function::ParameterTypeAt(intptr_t index) const { |
5454 const Array& parameter_types = Array::Handle(raw_ptr()->parameter_types_); | 5481 const Array& parameter_types = Array::Handle(raw_ptr()->parameter_types_); |
5455 return AbstractType::RawCast(parameter_types.At(index)); | 5482 return AbstractType::RawCast(parameter_types.At(index)); |
5456 } | 5483 } |
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6117 result.set_is_async_closure(false); | 6144 result.set_is_async_closure(false); |
6118 result.set_always_inline(false); | 6145 result.set_always_inline(false); |
6119 result.set_is_polymorphic_target(false); | 6146 result.set_is_polymorphic_target(false); |
6120 result.set_owner(owner); | 6147 result.set_owner(owner); |
6121 result.set_token_pos(token_pos); | 6148 result.set_token_pos(token_pos); |
6122 result.set_end_token_pos(token_pos); | 6149 result.set_end_token_pos(token_pos); |
6123 result.set_num_fixed_parameters(0); | 6150 result.set_num_fixed_parameters(0); |
6124 result.set_num_optional_parameters(0); | 6151 result.set_num_optional_parameters(0); |
6125 result.set_usage_counter(0); | 6152 result.set_usage_counter(0); |
6126 result.set_deoptimization_counter(0); | 6153 result.set_deoptimization_counter(0); |
6154 result.set_regexp_cid(kIllegalCid); | |
6127 result.set_optimized_instruction_count(0); | 6155 result.set_optimized_instruction_count(0); |
6128 result.set_optimized_call_site_count(0); | 6156 result.set_optimized_call_site_count(0); |
6129 result.set_is_optimizable(is_native ? false : true); | 6157 result.set_is_optimizable(is_native ? false : true); |
6130 result.set_is_inlinable(true); | 6158 result.set_is_inlinable(true); |
6131 result.set_allows_hoisting_check_class(true); | 6159 result.set_allows_hoisting_check_class(true); |
6132 result.set_allows_bounds_check_generalization(true); | 6160 result.set_allows_bounds_check_generalization(true); |
6133 StubCode* stub_code = Isolate::Current()->stub_code(); | 6161 StubCode* stub_code = Isolate::Current()->stub_code(); |
6134 result.SetInstructions(Code::Handle(stub_code->LazyCompile_entry()->code())); | 6162 result.SetInstructions(Code::Handle(stub_code->LazyCompile_entry()->code())); |
6135 if (kind == RawFunction::kClosureFunction) { | 6163 if (kind == RawFunction::kClosureFunction) { |
6136 const ClosureData& data = ClosureData::Handle(ClosureData::New()); | 6164 const ClosureData& data = ClosureData::Handle(ClosureData::New()); |
6137 result.set_data(data); | 6165 result.set_data(data); |
6138 } | 6166 } |
6139 | 6167 |
6140 return result.raw(); | 6168 return result.raw(); |
6141 } | 6169 } |
6142 | 6170 |
6143 | 6171 |
6144 RawFunction* Function::Clone(const Class& new_owner) const { | 6172 RawFunction* Function::Clone(const Class& new_owner) const { |
6145 ASSERT(!IsConstructor()); | 6173 ASSERT(!IsConstructor()); |
6146 Function& clone = Function::Handle(); | 6174 Function& clone = Function::Handle(); |
6147 clone ^= Object::Clone(*this, Heap::kOld); | 6175 clone ^= Object::Clone(*this, Heap::kOld); |
6148 const Class& origin = Class::Handle(this->origin()); | 6176 const Class& origin = Class::Handle(this->origin()); |
6149 const PatchClass& clone_owner = | 6177 const PatchClass& clone_owner = |
6150 PatchClass::Handle(PatchClass::New(new_owner, origin)); | 6178 PatchClass::Handle(PatchClass::New(new_owner, origin)); |
6151 clone.set_owner(clone_owner); | 6179 clone.set_owner(clone_owner); |
6152 clone.ClearCode(); | 6180 clone.ClearCode(); |
6153 clone.set_usage_counter(0); | 6181 clone.set_usage_counter(0); |
6154 clone.set_deoptimization_counter(0); | 6182 clone.set_deoptimization_counter(0); |
6183 clone.set_regexp_cid(kIllegalCid); | |
6155 clone.set_optimized_instruction_count(0); | 6184 clone.set_optimized_instruction_count(0); |
6156 clone.set_optimized_call_site_count(0); | 6185 clone.set_optimized_call_site_count(0); |
6157 clone.set_ic_data_array(Array::Handle()); | 6186 clone.set_ic_data_array(Array::Handle()); |
6158 return clone.raw(); | 6187 return clone.raw(); |
6159 } | 6188 } |
6160 | 6189 |
6161 | 6190 |
6162 RawFunction* Function::NewClosureFunction(const String& name, | 6191 RawFunction* Function::NewClosureFunction(const String& name, |
6163 const Function& parent, | 6192 const Function& parent, |
6164 intptr_t token_pos) { | 6193 intptr_t token_pos) { |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6697 break; | 6726 break; |
6698 case RawFunction::kMethodExtractor: | 6727 case RawFunction::kMethodExtractor: |
6699 kind_str = " method-extractor"; | 6728 kind_str = " method-extractor"; |
6700 break; | 6729 break; |
6701 case RawFunction::kNoSuchMethodDispatcher: | 6730 case RawFunction::kNoSuchMethodDispatcher: |
6702 kind_str = " no-such-method-dispatcher"; | 6731 kind_str = " no-such-method-dispatcher"; |
6703 break; | 6732 break; |
6704 case RawFunction::kInvokeFieldDispatcher: | 6733 case RawFunction::kInvokeFieldDispatcher: |
6705 kind_str = "invoke-field-dispatcher"; | 6734 kind_str = "invoke-field-dispatcher"; |
6706 break; | 6735 break; |
6736 case RawFunction::kIrregexpFunction: | |
6737 kind_str = "irregexp-function"; | |
6738 break; | |
6707 default: | 6739 default: |
6708 UNREACHABLE(); | 6740 UNREACHABLE(); |
6709 } | 6741 } |
6710 const char* kFormat = "Function '%s':%s%s%s%s."; | 6742 const char* kFormat = "Function '%s':%s%s%s%s."; |
6711 const char* function_name = String::Handle(name()).ToCString(); | 6743 const char* function_name = String::Handle(name()).ToCString(); |
6712 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, | 6744 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, |
6713 static_str, abstract_str, kind_str, const_str) + 1; | 6745 static_str, abstract_str, kind_str, const_str) + 1; |
6714 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 6746 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
6715 OS::SNPrint(chars, len, kFormat, function_name, | 6747 OS::SNPrint(chars, len, kFormat, function_name, |
6716 static_str, abstract_str, kind_str, const_str); | 6748 static_str, abstract_str, kind_str, const_str); |
(...skipping 3656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10373 OS::Print("Function not found %s.%s\n", #class_name, #function_name); \ | 10405 OS::Print("Function not found %s.%s\n", #class_name, #function_name); \ |
10374 } else if (func.SourceFingerprint() != fp) { \ | 10406 } else if (func.SourceFingerprint() != fp) { \ |
10375 has_errors = true; \ | 10407 has_errors = true; \ |
10376 OS::Print("Wrong fingerprint for '%s': expecting %d found %d\n", \ | 10408 OS::Print("Wrong fingerprint for '%s': expecting %d found %d\n", \ |
10377 func.ToFullyQualifiedCString(), fp, func.SourceFingerprint()); \ | 10409 func.ToFullyQualifiedCString(), fp, func.SourceFingerprint()); \ |
10378 collected_fp_diffs.Add(FpDiff(fp, func.SourceFingerprint())); \ | 10410 collected_fp_diffs.Add(FpDiff(fp, func.SourceFingerprint())); \ |
10379 } \ | 10411 } \ |
10380 | 10412 |
10381 all_libs.Add(&Library::ZoneHandle(Library::CoreLibrary())); | 10413 all_libs.Add(&Library::ZoneHandle(Library::CoreLibrary())); |
10382 CORE_LIB_INTRINSIC_LIST(CHECK_FINGERPRINTS); | 10414 CORE_LIB_INTRINSIC_LIST(CHECK_FINGERPRINTS); |
10415 CORE_REGEXP_LIB_INTRINSIC_LIST(CHECK_FINGERPRINTS); | |
10383 CORE_INTEGER_LIB_INTRINSIC_LIST(CHECK_FINGERPRINTS); | 10416 CORE_INTEGER_LIB_INTRINSIC_LIST(CHECK_FINGERPRINTS); |
10384 | 10417 |
10385 all_libs.Add(&Library::ZoneHandle(Library::MathLibrary())); | 10418 all_libs.Add(&Library::ZoneHandle(Library::MathLibrary())); |
10386 all_libs.Add(&Library::ZoneHandle(Library::TypedDataLibrary())); | 10419 all_libs.Add(&Library::ZoneHandle(Library::TypedDataLibrary())); |
10387 OTHER_RECOGNIZED_LIST(CHECK_FINGERPRINTS); | 10420 OTHER_RECOGNIZED_LIST(CHECK_FINGERPRINTS); |
10388 INLINE_WHITE_LIST(CHECK_FINGERPRINTS); | 10421 INLINE_WHITE_LIST(CHECK_FINGERPRINTS); |
10389 POLYMORPHIC_TARGET_LIST(CHECK_FINGERPRINTS); | 10422 POLYMORPHIC_TARGET_LIST(CHECK_FINGERPRINTS); |
10390 | 10423 |
10391 all_libs.Clear(); | 10424 all_libs.Clear(); |
10392 all_libs.Add(&Library::ZoneHandle(Library::MathLibrary())); | 10425 all_libs.Add(&Library::ZoneHandle(Library::MathLibrary())); |
(...skipping 9574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
19967 chars[total_len] = '\0'; | 20000 chars[total_len] = '\0'; |
19968 return chars; | 20001 return chars; |
19969 } | 20002 } |
19970 | 20003 |
19971 | 20004 |
19972 void JSRegExp::set_pattern(const String& pattern) const { | 20005 void JSRegExp::set_pattern(const String& pattern) const { |
19973 StorePointer(&raw_ptr()->pattern_, pattern.raw()); | 20006 StorePointer(&raw_ptr()->pattern_, pattern.raw()); |
19974 } | 20007 } |
19975 | 20008 |
19976 | 20009 |
20010 void JSRegExp::set_function(intptr_t cid, const Function& value) const { | |
20011 StorePointer(FunctionAddr(cid), value.raw()); | |
20012 } | |
20013 | |
20014 | |
19977 void JSRegExp::set_num_bracket_expressions(intptr_t value) const { | 20015 void JSRegExp::set_num_bracket_expressions(intptr_t value) const { |
19978 StoreSmi(&raw_ptr()->num_bracket_expressions_, Smi::New(value)); | 20016 StoreSmi(&raw_ptr()->num_bracket_expressions_, Smi::New(value)); |
19979 } | 20017 } |
19980 | 20018 |
19981 | 20019 |
19982 RawJSRegExp* JSRegExp::New(intptr_t len, Heap::Space space) { | 20020 RawJSRegExp* JSRegExp::New(intptr_t len, Heap::Space space) { |
19983 if (len < 0 || len > kMaxElements) { | 20021 if (len < 0 || len > kMaxElements) { |
19984 // This should be caught before we reach here. | 20022 // This should be caught before we reach here. |
19985 FATAL1("Fatal error in JSRegexp::New: invalid len %" Pd "\n", len); | 20023 FATAL1("Fatal error in JSRegexp::New: invalid len %" Pd "\n", len); |
19986 } | 20024 } |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
20303 return tag_label.ToCString(); | 20341 return tag_label.ToCString(); |
20304 } | 20342 } |
20305 | 20343 |
20306 | 20344 |
20307 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20345 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
20308 Instance::PrintJSONImpl(stream, ref); | 20346 Instance::PrintJSONImpl(stream, ref); |
20309 } | 20347 } |
20310 | 20348 |
20311 | 20349 |
20312 } // namespace dart | 20350 } // namespace dart |
OLD | NEW |