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

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

Issue 744853003: Integrate the Irregexp Regular Expression Engine. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix clang and win build Created 6 years 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
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/parser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5370 matching lines...) Expand 10 before | Expand all | Expand 10 after
5381 break; 5381 break;
5382 case RawFunction::kMethodExtractor: 5382 case RawFunction::kMethodExtractor:
5383 return "kMethodExtractor"; 5383 return "kMethodExtractor";
5384 break; 5384 break;
5385 case RawFunction::kNoSuchMethodDispatcher: 5385 case RawFunction::kNoSuchMethodDispatcher:
5386 return "kNoSuchMethodDispatcher"; 5386 return "kNoSuchMethodDispatcher";
5387 break; 5387 break;
5388 case RawFunction::kInvokeFieldDispatcher: 5388 case RawFunction::kInvokeFieldDispatcher:
5389 return "kInvokeFieldDispatcher"; 5389 return "kInvokeFieldDispatcher";
5390 break; 5390 break;
5391 case RawFunction::kIrregexpFunction:
5392 return "kIrregexpFunction";
5393 break;
5391 default: 5394 default:
5392 UNREACHABLE(); 5395 UNREACHABLE();
5393 return NULL; 5396 return NULL;
5394 } 5397 }
5395 } 5398 }
5396 5399
5397 5400
5398 void Function::SetRedirectionType(const Type& type) const { 5401 void Function::SetRedirectionType(const Type& type) const {
5399 ASSERT(IsFactory()); 5402 ASSERT(IsFactory());
5400 Object& obj = Object::Handle(raw_ptr()->data_); 5403 Object& obj = Object::Handle(raw_ptr()->data_);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
5466 StorePointer(&raw_ptr()->name_, value.raw()); 5469 StorePointer(&raw_ptr()->name_, value.raw());
5467 } 5470 }
5468 5471
5469 5472
5470 void Function::set_owner(const Object& value) const { 5473 void Function::set_owner(const Object& value) const {
5471 ASSERT(!value.IsNull()); 5474 ASSERT(!value.IsNull());
5472 StorePointer(&raw_ptr()->owner_, value.raw()); 5475 StorePointer(&raw_ptr()->owner_, value.raw());
5473 } 5476 }
5474 5477
5475 5478
5479 RawJSRegExp* Function::regexp() const {
5480 ASSERT(kind() == RawFunction::kIrregexpFunction);
5481 const Object& obj = Object::Handle(raw_ptr()->data_);
5482 return JSRegExp::Cast(obj).raw();
5483 }
5484
5485
5486 void Function::set_regexp(const JSRegExp& value) const {
5487 ASSERT(kind() == RawFunction::kIrregexpFunction);
5488 ASSERT(raw_ptr()->data_ == Object::null());
5489 set_data(value);
5490 }
5491
5492
5493 void Function::set_regexp_cid(intptr_t regexp_cid) const {
5494 ASSERT((regexp_cid == kIllegalCid) ||
5495 (kind() == RawFunction::kIrregexpFunction));
5496 ASSERT((regexp_cid == kIllegalCid) ||
5497 RawObject::IsStringClassId(regexp_cid));
5498 StoreNonPointer(&raw_ptr()->regexp_cid_, regexp_cid);
5499 }
5500
5501
5476 void Function::set_result_type(const AbstractType& value) const { 5502 void Function::set_result_type(const AbstractType& value) const {
5477 ASSERT(!value.IsNull()); 5503 ASSERT(!value.IsNull());
5478 StorePointer(&raw_ptr()->result_type_, value.raw()); 5504 StorePointer(&raw_ptr()->result_type_, value.raw());
5479 } 5505 }
5480 5506
5481 5507
5482 RawAbstractType* Function::ParameterTypeAt(intptr_t index) const { 5508 RawAbstractType* Function::ParameterTypeAt(intptr_t index) const {
5483 const Array& parameter_types = Array::Handle(raw_ptr()->parameter_types_); 5509 const Array& parameter_types = Array::Handle(raw_ptr()->parameter_types_);
5484 return AbstractType::RawCast(parameter_types.At(index)); 5510 return AbstractType::RawCast(parameter_types.At(index));
5485 } 5511 }
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
6146 result.set_is_async_closure(false); 6172 result.set_is_async_closure(false);
6147 result.set_always_inline(false); 6173 result.set_always_inline(false);
6148 result.set_is_polymorphic_target(false); 6174 result.set_is_polymorphic_target(false);
6149 result.set_owner(owner); 6175 result.set_owner(owner);
6150 result.set_token_pos(token_pos); 6176 result.set_token_pos(token_pos);
6151 result.set_end_token_pos(token_pos); 6177 result.set_end_token_pos(token_pos);
6152 result.set_num_fixed_parameters(0); 6178 result.set_num_fixed_parameters(0);
6153 result.set_num_optional_parameters(0); 6179 result.set_num_optional_parameters(0);
6154 result.set_usage_counter(0); 6180 result.set_usage_counter(0);
6155 result.set_deoptimization_counter(0); 6181 result.set_deoptimization_counter(0);
6182 result.set_regexp_cid(kIllegalCid);
6156 result.set_optimized_instruction_count(0); 6183 result.set_optimized_instruction_count(0);
6157 result.set_optimized_call_site_count(0); 6184 result.set_optimized_call_site_count(0);
6158 result.set_is_optimizable(is_native ? false : true); 6185 result.set_is_optimizable(is_native ? false : true);
6159 result.set_is_inlinable(true); 6186 result.set_is_inlinable(true);
6160 result.set_allows_hoisting_check_class(true); 6187 result.set_allows_hoisting_check_class(true);
6161 result.set_allows_bounds_check_generalization(true); 6188 result.set_allows_bounds_check_generalization(true);
6162 StubCode* stub_code = Isolate::Current()->stub_code(); 6189 StubCode* stub_code = Isolate::Current()->stub_code();
6163 result.SetInstructions(Code::Handle(stub_code->LazyCompile_entry()->code())); 6190 result.SetInstructions(Code::Handle(stub_code->LazyCompile_entry()->code()));
6164 if (kind == RawFunction::kClosureFunction) { 6191 if (kind == RawFunction::kClosureFunction) {
6165 const ClosureData& data = ClosureData::Handle(ClosureData::New()); 6192 const ClosureData& data = ClosureData::Handle(ClosureData::New());
6166 result.set_data(data); 6193 result.set_data(data);
6167 } 6194 }
6168 6195
6169 return result.raw(); 6196 return result.raw();
6170 } 6197 }
6171 6198
6172 6199
6173 RawFunction* Function::Clone(const Class& new_owner) const { 6200 RawFunction* Function::Clone(const Class& new_owner) const {
6174 ASSERT(!IsConstructor()); 6201 ASSERT(!IsConstructor());
6175 Function& clone = Function::Handle(); 6202 Function& clone = Function::Handle();
6176 clone ^= Object::Clone(*this, Heap::kOld); 6203 clone ^= Object::Clone(*this, Heap::kOld);
6177 const Class& origin = Class::Handle(this->origin()); 6204 const Class& origin = Class::Handle(this->origin());
6178 const PatchClass& clone_owner = 6205 const PatchClass& clone_owner =
6179 PatchClass::Handle(PatchClass::New(new_owner, origin)); 6206 PatchClass::Handle(PatchClass::New(new_owner, origin));
6180 clone.set_owner(clone_owner); 6207 clone.set_owner(clone_owner);
6181 clone.ClearCode(); 6208 clone.ClearCode();
6182 clone.set_usage_counter(0); 6209 clone.set_usage_counter(0);
6183 clone.set_deoptimization_counter(0); 6210 clone.set_deoptimization_counter(0);
6211 clone.set_regexp_cid(kIllegalCid);
6184 clone.set_optimized_instruction_count(0); 6212 clone.set_optimized_instruction_count(0);
6185 clone.set_optimized_call_site_count(0); 6213 clone.set_optimized_call_site_count(0);
6186 clone.set_ic_data_array(Array::Handle()); 6214 clone.set_ic_data_array(Array::Handle());
6187 if (new_owner.NumTypeParameters() > 0) { 6215 if (new_owner.NumTypeParameters() > 0) {
6188 // Adjust uninstantiated types to refer to type parameters of the new owner. 6216 // Adjust uninstantiated types to refer to type parameters of the new owner.
6189 AbstractType& type = AbstractType::Handle(clone.result_type()); 6217 AbstractType& type = AbstractType::Handle(clone.result_type());
6190 type ^= type.CloneUninstantiated(new_owner); 6218 type ^= type.CloneUninstantiated(new_owner);
6191 clone.set_result_type(type); 6219 clone.set_result_type(type);
6192 const intptr_t num_params = clone.NumParameters(); 6220 const intptr_t num_params = clone.NumParameters();
6193 Array& array = Array::Handle(clone.parameter_types()); 6221 Array& array = Array::Handle(clone.parameter_types());
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
6741 break; 6769 break;
6742 case RawFunction::kMethodExtractor: 6770 case RawFunction::kMethodExtractor:
6743 kind_str = " method-extractor"; 6771 kind_str = " method-extractor";
6744 break; 6772 break;
6745 case RawFunction::kNoSuchMethodDispatcher: 6773 case RawFunction::kNoSuchMethodDispatcher:
6746 kind_str = " no-such-method-dispatcher"; 6774 kind_str = " no-such-method-dispatcher";
6747 break; 6775 break;
6748 case RawFunction::kInvokeFieldDispatcher: 6776 case RawFunction::kInvokeFieldDispatcher:
6749 kind_str = "invoke-field-dispatcher"; 6777 kind_str = "invoke-field-dispatcher";
6750 break; 6778 break;
6779 case RawFunction::kIrregexpFunction:
6780 kind_str = "irregexp-function";
6781 break;
6751 default: 6782 default:
6752 UNREACHABLE(); 6783 UNREACHABLE();
6753 } 6784 }
6754 const char* kFormat = "Function '%s':%s%s%s%s."; 6785 const char* kFormat = "Function '%s':%s%s%s%s.";
6755 const char* function_name = String::Handle(name()).ToCString(); 6786 const char* function_name = String::Handle(name()).ToCString();
6756 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, 6787 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name,
6757 static_str, abstract_str, kind_str, const_str) + 1; 6788 static_str, abstract_str, kind_str, const_str) + 1;
6758 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 6789 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
6759 OS::SNPrint(chars, len, kFormat, function_name, 6790 OS::SNPrint(chars, len, kFormat, function_name,
6760 static_str, abstract_str, kind_str, const_str); 6791 static_str, abstract_str, kind_str, const_str);
(...skipping 13323 matching lines...) Expand 10 before | Expand all | Expand 10 after
20084 chars[total_len] = '\0'; 20115 chars[total_len] = '\0';
20085 return chars; 20116 return chars;
20086 } 20117 }
20087 20118
20088 20119
20089 void JSRegExp::set_pattern(const String& pattern) const { 20120 void JSRegExp::set_pattern(const String& pattern) const {
20090 StorePointer(&raw_ptr()->pattern_, pattern.raw()); 20121 StorePointer(&raw_ptr()->pattern_, pattern.raw());
20091 } 20122 }
20092 20123
20093 20124
20125 void JSRegExp::set_function(intptr_t cid, const Function& value) const {
20126 StorePointer(FunctionAddr(cid), value.raw());
20127 }
20128
20129
20094 void JSRegExp::set_num_bracket_expressions(intptr_t value) const { 20130 void JSRegExp::set_num_bracket_expressions(intptr_t value) const {
20095 StoreSmi(&raw_ptr()->num_bracket_expressions_, Smi::New(value)); 20131 StoreSmi(&raw_ptr()->num_bracket_expressions_, Smi::New(value));
20096 } 20132 }
20097 20133
20098 20134
20099 RawJSRegExp* JSRegExp::New(intptr_t len, Heap::Space space) { 20135 RawJSRegExp* JSRegExp::New(intptr_t len, Heap::Space space) {
20100 if (len < 0 || len > kMaxElements) { 20136 if (len < 0 || len > kMaxElements) {
20101 // This should be caught before we reach here. 20137 // This should be caught before we reach here.
20102 FATAL1("Fatal error in JSRegexp::New: invalid len %" Pd "\n", len); 20138 FATAL1("Fatal error in JSRegexp::New: invalid len %" Pd "\n", len);
20103 } 20139 }
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
20420 return tag_label.ToCString(); 20456 return tag_label.ToCString();
20421 } 20457 }
20422 20458
20423 20459
20424 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20460 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20425 Instance::PrintJSONImpl(stream, ref); 20461 Instance::PrintJSONImpl(stream, ref);
20426 } 20462 }
20427 20463
20428 20464
20429 } // namespace dart 20465 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698