Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: runtime/vm/object.cc

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

Powered by Google App Engine
This is Rietveld 408576698