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

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

Issue 539153002: Port and integrate the irregexp engine from V8 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Missed a TODO. Created 6 years, 2 months 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 5280 matching lines...) Expand 10 before | Expand all | Expand 10 after
5291 break; 5291 break;
5292 case RawFunction::kMethodExtractor: 5292 case RawFunction::kMethodExtractor:
5293 return "kMethodExtractor"; 5293 return "kMethodExtractor";
5294 break; 5294 break;
5295 case RawFunction::kNoSuchMethodDispatcher: 5295 case RawFunction::kNoSuchMethodDispatcher:
5296 return "kNoSuchMethodDispatcher"; 5296 return "kNoSuchMethodDispatcher";
5297 break; 5297 break;
5298 case RawFunction::kInvokeFieldDispatcher: 5298 case RawFunction::kInvokeFieldDispatcher:
5299 return "kInvokeFieldDispatcher"; 5299 return "kInvokeFieldDispatcher";
5300 break; 5300 break;
5301 case RawFunction::kIrregexpFunction:
5302 return "kIrregexpFunction";
5303 break;
5301 default: 5304 default:
5302 UNREACHABLE(); 5305 UNREACHABLE();
5303 return NULL; 5306 return NULL;
5304 } 5307 }
5305 } 5308 }
5306 5309
5307 5310
5308 void Function::SetRedirectionType(const Type& type) const { 5311 void Function::SetRedirectionType(const Type& type) const {
5309 ASSERT(IsFactory()); 5312 ASSERT(IsFactory());
5310 Object& obj = Object::Handle(raw_ptr()->data_); 5313 Object& obj = Object::Handle(raw_ptr()->data_);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
5376 StorePointer(&raw_ptr()->name_, value.raw()); 5379 StorePointer(&raw_ptr()->name_, value.raw());
5377 } 5380 }
5378 5381
5379 5382
5380 void Function::set_owner(const Object& value) const { 5383 void Function::set_owner(const Object& value) const {
5381 ASSERT(!value.IsNull()); 5384 ASSERT(!value.IsNull());
5382 StorePointer(&raw_ptr()->owner_, value.raw()); 5385 StorePointer(&raw_ptr()->owner_, value.raw());
5383 } 5386 }
5384 5387
5385 5388
5389 RawJSRegExp* Function::regexp() const {
5390 ASSERT(kind() == RawFunction::kIrregexpFunction);
5391 const Object& obj = Object::Handle(raw_ptr()->data_);
5392 ASSERT(obj.IsJSRegExp());
5393 return JSRegExp::Cast(obj).raw();
5394 }
5395
5396
5397 void Function::set_regexp(const JSRegExp& value) const {
5398 ASSERT(kind() == RawFunction::kIrregexpFunction);
5399 ASSERT(raw_ptr()->data_ == Object::null());
5400 set_data(value);
5401 }
5402
5403
5386 void Function::set_result_type(const AbstractType& value) const { 5404 void Function::set_result_type(const AbstractType& value) const {
5387 ASSERT(!value.IsNull()); 5405 ASSERT(!value.IsNull());
5388 StorePointer(&raw_ptr()->result_type_, value.raw()); 5406 StorePointer(&raw_ptr()->result_type_, value.raw());
5389 } 5407 }
5390 5408
5391 5409
5392 RawAbstractType* Function::ParameterTypeAt(intptr_t index) const { 5410 RawAbstractType* Function::ParameterTypeAt(intptr_t index) const {
5393 const Array& parameter_types = Array::Handle(raw_ptr()->parameter_types_); 5411 const Array& parameter_types = Array::Handle(raw_ptr()->parameter_types_);
5394 return AbstractType::RawCast(parameter_types.At(index)); 5412 return AbstractType::RawCast(parameter_types.At(index));
5395 } 5413 }
(...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after
6633 break; 6651 break;
6634 case RawFunction::kMethodExtractor: 6652 case RawFunction::kMethodExtractor:
6635 kind_str = " method-extractor"; 6653 kind_str = " method-extractor";
6636 break; 6654 break;
6637 case RawFunction::kNoSuchMethodDispatcher: 6655 case RawFunction::kNoSuchMethodDispatcher:
6638 kind_str = " no-such-method-dispatcher"; 6656 kind_str = " no-such-method-dispatcher";
6639 break; 6657 break;
6640 case RawFunction::kInvokeFieldDispatcher: 6658 case RawFunction::kInvokeFieldDispatcher:
6641 kind_str = "invoke-field-dispatcher"; 6659 kind_str = "invoke-field-dispatcher";
6642 break; 6660 break;
6661 case RawFunction::kIrregexpFunction:
6662 kind_str = "irregexp-function";
6663 break;
6643 default: 6664 default:
6644 UNREACHABLE(); 6665 UNREACHABLE();
6645 } 6666 }
6646 const char* kFormat = "Function '%s':%s%s%s%s."; 6667 const char* kFormat = "Function '%s':%s%s%s%s.";
6647 const char* function_name = String::Handle(name()).ToCString(); 6668 const char* function_name = String::Handle(name()).ToCString();
6648 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, 6669 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name,
6649 static_str, abstract_str, kind_str, const_str) + 1; 6670 static_str, abstract_str, kind_str, const_str) + 1;
6650 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 6671 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
6651 OS::SNPrint(chars, len, kFormat, function_name, 6672 OS::SNPrint(chars, len, kFormat, function_name,
6652 static_str, abstract_str, kind_str, const_str); 6673 static_str, abstract_str, kind_str, const_str);
(...skipping 3656 matching lines...) Expand 10 before | Expand all | Expand 10 after
10309 OS::Print("Function not found %s.%s\n", #class_name, #function_name); \ 10330 OS::Print("Function not found %s.%s\n", #class_name, #function_name); \
10310 } else if (func.SourceFingerprint() != fp) { \ 10331 } else if (func.SourceFingerprint() != fp) { \
10311 has_errors = true; \ 10332 has_errors = true; \
10312 OS::Print("Wrong fingerprint for '%s': expecting %d found %d\n", \ 10333 OS::Print("Wrong fingerprint for '%s': expecting %d found %d\n", \
10313 func.ToFullyQualifiedCString(), fp, func.SourceFingerprint()); \ 10334 func.ToFullyQualifiedCString(), fp, func.SourceFingerprint()); \
10314 collected_fp_diffs.Add(FpDiff(fp, func.SourceFingerprint())); \ 10335 collected_fp_diffs.Add(FpDiff(fp, func.SourceFingerprint())); \
10315 } \ 10336 } \
10316 10337
10317 all_libs.Add(&Library::ZoneHandle(Library::CoreLibrary())); 10338 all_libs.Add(&Library::ZoneHandle(Library::CoreLibrary()));
10318 CORE_LIB_INTRINSIC_LIST(CHECK_FINGERPRINTS); 10339 CORE_LIB_INTRINSIC_LIST(CHECK_FINGERPRINTS);
10340 CORE_REGEXP_LIB_INTRINSIC_LIST(CHECK_FINGERPRINTS);
10319 CORE_INTEGER_LIB_INTRINSIC_LIST(CHECK_FINGERPRINTS); 10341 CORE_INTEGER_LIB_INTRINSIC_LIST(CHECK_FINGERPRINTS);
10320 10342
10321 all_libs.Add(&Library::ZoneHandle(Library::MathLibrary())); 10343 all_libs.Add(&Library::ZoneHandle(Library::MathLibrary()));
10322 all_libs.Add(&Library::ZoneHandle(Library::TypedDataLibrary())); 10344 all_libs.Add(&Library::ZoneHandle(Library::TypedDataLibrary()));
10323 OTHER_RECOGNIZED_LIST(CHECK_FINGERPRINTS); 10345 OTHER_RECOGNIZED_LIST(CHECK_FINGERPRINTS);
10324 INLINE_WHITE_LIST(CHECK_FINGERPRINTS); 10346 INLINE_WHITE_LIST(CHECK_FINGERPRINTS);
10325 POLYMORPHIC_TARGET_LIST(CHECK_FINGERPRINTS); 10347 POLYMORPHIC_TARGET_LIST(CHECK_FINGERPRINTS);
10326 10348
10327 all_libs.Clear(); 10349 all_libs.Clear();
10328 all_libs.Add(&Library::ZoneHandle(Library::MathLibrary())); 10350 all_libs.Add(&Library::ZoneHandle(Library::MathLibrary()));
(...skipping 9590 matching lines...) Expand 10 before | Expand all | Expand 10 after
19919 chars[total_len] = '\0'; 19941 chars[total_len] = '\0';
19920 return chars; 19942 return chars;
19921 } 19943 }
19922 19944
19923 19945
19924 void JSRegExp::set_pattern(const String& pattern) const { 19946 void JSRegExp::set_pattern(const String& pattern) const {
19925 StorePointer(&raw_ptr()->pattern_, pattern.raw()); 19947 StorePointer(&raw_ptr()->pattern_, pattern.raw());
19926 } 19948 }
19927 19949
19928 19950
19951 void JSRegExp::set_function(intptr_t cid, const Function& value) {
19952 StorePointer(FunctionAddr(cid), value.raw());
19953 }
19954
19955
19929 void JSRegExp::set_num_bracket_expressions(intptr_t value) const { 19956 void JSRegExp::set_num_bracket_expressions(intptr_t value) const {
19930 StoreSmi(&raw_ptr()->num_bracket_expressions_, Smi::New(value)); 19957 StoreSmi(&raw_ptr()->num_bracket_expressions_, Smi::New(value));
19931 } 19958 }
19932 19959
19933 19960
19934 RawJSRegExp* JSRegExp::New(intptr_t len, Heap::Space space) { 19961 RawJSRegExp* JSRegExp::New(intptr_t len, Heap::Space space) {
19935 if (len < 0 || len > kMaxElements) { 19962 if (len < 0 || len > kMaxElements) {
19936 // This should be caught before we reach here. 19963 // This should be caught before we reach here.
19937 FATAL1("Fatal error in JSRegexp::New: invalid len %" Pd "\n", len); 19964 FATAL1("Fatal error in JSRegexp::New: invalid len %" Pd "\n", len);
19938 } 19965 }
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
20255 return tag_label.ToCString(); 20282 return tag_label.ToCString();
20256 } 20283 }
20257 20284
20258 20285
20259 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20286 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20260 Instance::PrintJSONImpl(stream, ref); 20287 Instance::PrintJSONImpl(stream, ref);
20261 } 20288 }
20262 20289
20263 20290
20264 } // namespace dart 20291 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698