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 5272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5283 break; | 5283 break; |
5284 case RawFunction::kMethodExtractor: | 5284 case RawFunction::kMethodExtractor: |
5285 return "kMethodExtractor"; | 5285 return "kMethodExtractor"; |
5286 break; | 5286 break; |
5287 case RawFunction::kNoSuchMethodDispatcher: | 5287 case RawFunction::kNoSuchMethodDispatcher: |
5288 return "kNoSuchMethodDispatcher"; | 5288 return "kNoSuchMethodDispatcher"; |
5289 break; | 5289 break; |
5290 case RawFunction::kInvokeFieldDispatcher: | 5290 case RawFunction::kInvokeFieldDispatcher: |
5291 return "kInvokeFieldDispatcher"; | 5291 return "kInvokeFieldDispatcher"; |
5292 break; | 5292 break; |
5293 case RawFunction::kIrregexpFunction: | |
5294 return "kIrregexpFunction"; | |
5295 break; | |
5293 default: | 5296 default: |
5294 UNREACHABLE(); | 5297 UNREACHABLE(); |
5295 return NULL; | 5298 return NULL; |
5296 } | 5299 } |
5297 } | 5300 } |
5298 | 5301 |
5299 | 5302 |
5300 void Function::SetRedirectionType(const Type& type) const { | 5303 void Function::SetRedirectionType(const Type& type) const { |
5301 ASSERT(IsFactory()); | 5304 ASSERT(IsFactory()); |
5302 Object& obj = Object::Handle(raw_ptr()->data_); | 5305 Object& obj = Object::Handle(raw_ptr()->data_); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5368 StorePointer(&raw_ptr()->name_, value.raw()); | 5371 StorePointer(&raw_ptr()->name_, value.raw()); |
5369 } | 5372 } |
5370 | 5373 |
5371 | 5374 |
5372 void Function::set_owner(const Object& value) const { | 5375 void Function::set_owner(const Object& value) const { |
5373 ASSERT(!value.IsNull()); | 5376 ASSERT(!value.IsNull()); |
5374 StorePointer(&raw_ptr()->owner_, value.raw()); | 5377 StorePointer(&raw_ptr()->owner_, value.raw()); |
5375 } | 5378 } |
5376 | 5379 |
5377 | 5380 |
5381 RawJSRegExp* Function::regexp() const { | |
5382 ASSERT(kind() == RawFunction::kIrregexpFunction); | |
5383 const Object& obj = Object::Handle(raw_ptr()->data_); | |
5384 ASSERT(obj.IsJSRegExp()); | |
5385 return JSRegExp::Cast(obj).raw(); | |
5386 } | |
5387 | |
5388 | |
5389 void Function::set_regexp(const JSRegExp& value) const { | |
5390 ASSERT(kind() == RawFunction::kIrregexpFunction); | |
5391 ASSERT(raw_ptr()->data_ == Object::null()); | |
5392 set_data(value); | |
5393 } | |
5394 | |
5395 | |
5378 void Function::set_result_type(const AbstractType& value) const { | 5396 void Function::set_result_type(const AbstractType& value) const { |
5379 ASSERT(!value.IsNull()); | 5397 ASSERT(!value.IsNull()); |
5380 StorePointer(&raw_ptr()->result_type_, value.raw()); | 5398 StorePointer(&raw_ptr()->result_type_, value.raw()); |
5381 } | 5399 } |
5382 | 5400 |
5383 | 5401 |
5384 RawAbstractType* Function::ParameterTypeAt(intptr_t index) const { | 5402 RawAbstractType* Function::ParameterTypeAt(intptr_t index) const { |
5385 const Array& parameter_types = Array::Handle(raw_ptr()->parameter_types_); | 5403 const Array& parameter_types = Array::Handle(raw_ptr()->parameter_types_); |
5386 return AbstractType::RawCast(parameter_types.At(index)); | 5404 return AbstractType::RawCast(parameter_types.At(index)); |
5387 } | 5405 } |
(...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6686 break; | 6704 break; |
6687 case RawFunction::kMethodExtractor: | 6705 case RawFunction::kMethodExtractor: |
6688 kind_str = " method-extractor"; | 6706 kind_str = " method-extractor"; |
6689 break; | 6707 break; |
6690 case RawFunction::kNoSuchMethodDispatcher: | 6708 case RawFunction::kNoSuchMethodDispatcher: |
6691 kind_str = " no-such-method-dispatcher"; | 6709 kind_str = " no-such-method-dispatcher"; |
6692 break; | 6710 break; |
6693 case RawFunction::kInvokeFieldDispatcher: | 6711 case RawFunction::kInvokeFieldDispatcher: |
6694 kind_str = "invoke-field-dispatcher"; | 6712 kind_str = "invoke-field-dispatcher"; |
6695 break; | 6713 break; |
6714 case RawFunction::kIrregexpFunction: | |
6715 kind_str = "irregexp-function"; | |
6716 break; | |
6696 default: | 6717 default: |
6697 UNREACHABLE(); | 6718 UNREACHABLE(); |
6698 } | 6719 } |
6699 const char* kFormat = "Function '%s':%s%s%s%s."; | 6720 const char* kFormat = "Function '%s':%s%s%s%s."; |
6700 const char* function_name = String::Handle(name()).ToCString(); | 6721 const char* function_name = String::Handle(name()).ToCString(); |
6701 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, | 6722 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, |
6702 static_str, abstract_str, kind_str, const_str) + 1; | 6723 static_str, abstract_str, kind_str, const_str) + 1; |
6703 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 6724 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
6704 OS::SNPrint(chars, len, kFormat, function_name, | 6725 OS::SNPrint(chars, len, kFormat, function_name, |
6705 static_str, abstract_str, kind_str, const_str); | 6726 static_str, abstract_str, kind_str, const_str); |
(...skipping 3656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10362 OS::Print("Function not found %s.%s\n", #class_name, #function_name); \ | 10383 OS::Print("Function not found %s.%s\n", #class_name, #function_name); \ |
10363 } else if (func.SourceFingerprint() != fp) { \ | 10384 } else if (func.SourceFingerprint() != fp) { \ |
10364 has_errors = true; \ | 10385 has_errors = true; \ |
10365 OS::Print("Wrong fingerprint for '%s': expecting %d found %d\n", \ | 10386 OS::Print("Wrong fingerprint for '%s': expecting %d found %d\n", \ |
10366 func.ToFullyQualifiedCString(), fp, func.SourceFingerprint()); \ | 10387 func.ToFullyQualifiedCString(), fp, func.SourceFingerprint()); \ |
10367 collected_fp_diffs.Add(FpDiff(fp, func.SourceFingerprint())); \ | 10388 collected_fp_diffs.Add(FpDiff(fp, func.SourceFingerprint())); \ |
10368 } \ | 10389 } \ |
10369 | 10390 |
10370 all_libs.Add(&Library::ZoneHandle(Library::CoreLibrary())); | 10391 all_libs.Add(&Library::ZoneHandle(Library::CoreLibrary())); |
10371 CORE_LIB_INTRINSIC_LIST(CHECK_FINGERPRINTS); | 10392 CORE_LIB_INTRINSIC_LIST(CHECK_FINGERPRINTS); |
10393 CORE_REGEXP_LIB_INTRINSIC_LIST(CHECK_FINGERPRINTS); | |
10372 CORE_INTEGER_LIB_INTRINSIC_LIST(CHECK_FINGERPRINTS); | 10394 CORE_INTEGER_LIB_INTRINSIC_LIST(CHECK_FINGERPRINTS); |
10373 | 10395 |
10374 all_libs.Add(&Library::ZoneHandle(Library::MathLibrary())); | 10396 all_libs.Add(&Library::ZoneHandle(Library::MathLibrary())); |
10375 all_libs.Add(&Library::ZoneHandle(Library::TypedDataLibrary())); | 10397 all_libs.Add(&Library::ZoneHandle(Library::TypedDataLibrary())); |
10376 OTHER_RECOGNIZED_LIST(CHECK_FINGERPRINTS); | 10398 OTHER_RECOGNIZED_LIST(CHECK_FINGERPRINTS); |
10377 INLINE_WHITE_LIST(CHECK_FINGERPRINTS); | 10399 INLINE_WHITE_LIST(CHECK_FINGERPRINTS); |
10378 POLYMORPHIC_TARGET_LIST(CHECK_FINGERPRINTS); | 10400 POLYMORPHIC_TARGET_LIST(CHECK_FINGERPRINTS); |
10379 | 10401 |
10380 all_libs.Clear(); | 10402 all_libs.Clear(); |
10381 all_libs.Add(&Library::ZoneHandle(Library::MathLibrary())); | 10403 all_libs.Add(&Library::ZoneHandle(Library::MathLibrary())); |
(...skipping 9589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
19971 chars[total_len] = '\0'; | 19993 chars[total_len] = '\0'; |
19972 return chars; | 19994 return chars; |
19973 } | 19995 } |
19974 | 19996 |
19975 | 19997 |
19976 void JSRegExp::set_pattern(const String& pattern) const { | 19998 void JSRegExp::set_pattern(const String& pattern) const { |
19977 StorePointer(&raw_ptr()->pattern_, pattern.raw()); | 19999 StorePointer(&raw_ptr()->pattern_, pattern.raw()); |
19978 } | 20000 } |
19979 | 20001 |
19980 | 20002 |
20003 void JSRegExp::set_function(intptr_t cid, const Function& value) { | |
20004 RawFunction** dest = NULL; | |
20005 switch (cid) { | |
20006 case kOneByteStringCid: dest = &raw_ptr()->one_byte_function_; break; | |
Vyacheslav Egorov (Google)
2014/10/07 15:48:30
I suggest make formatting more uniform
case kOneB
jgruber1
2014/10/07 17:16:51
Done.
| |
20007 case kTwoByteStringCid: dest = &raw_ptr()->two_byte_function_; break; | |
20008 case kExternalOneByteStringCid: | |
20009 dest = &raw_ptr()->external_one_byte_function_; break; | |
20010 case kExternalTwoByteStringCid: | |
20011 dest = &raw_ptr()->external_two_byte_function_; break; | |
20012 default: UNREACHABLE(); | |
20013 } | |
20014 ASSERT(dest != NULL); | |
20015 | |
20016 StorePointer(dest, value.raw()); | |
Vyacheslav Egorov (Google)
2014/10/07 15:48:30
You can make JSRegExp a friend class of Instance a
jgruber1
2014/10/07 17:16:51
Done.
| |
20017 } | |
20018 | |
20019 | |
19981 void JSRegExp::set_num_bracket_expressions(intptr_t value) const { | 20020 void JSRegExp::set_num_bracket_expressions(intptr_t value) const { |
19982 StoreSmi(&raw_ptr()->num_bracket_expressions_, Smi::New(value)); | 20021 StoreSmi(&raw_ptr()->num_bracket_expressions_, Smi::New(value)); |
19983 } | 20022 } |
19984 | 20023 |
19985 | 20024 |
19986 RawJSRegExp* JSRegExp::New(intptr_t len, Heap::Space space) { | 20025 RawJSRegExp* JSRegExp::New(intptr_t len, Heap::Space space) { |
19987 if (len < 0 || len > kMaxElements) { | 20026 if (len < 0 || len > kMaxElements) { |
19988 // This should be caught before we reach here. | 20027 // This should be caught before we reach here. |
19989 FATAL1("Fatal error in JSRegexp::New: invalid len %" Pd "\n", len); | 20028 FATAL1("Fatal error in JSRegexp::New: invalid len %" Pd "\n", len); |
19990 } | 20029 } |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
20307 return tag_label.ToCString(); | 20346 return tag_label.ToCString(); |
20308 } | 20347 } |
20309 | 20348 |
20310 | 20349 |
20311 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20350 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
20312 Instance::PrintJSONImpl(stream, ref); | 20351 Instance::PrintJSONImpl(stream, ref); |
20313 } | 20352 } |
20314 | 20353 |
20315 | 20354 |
20316 } // namespace dart | 20355 } // namespace dart |
OLD | NEW |