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

Unified Diff: src/regexp-macro-assembler-irregexp.cc

Issue 21481: A little peephole optimization for the Irregexp bytecode interpreter. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/regexp-macro-assembler-irregexp.h ('k') | src/regexp-macro-assembler-irregexp-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/regexp-macro-assembler-irregexp.cc
===================================================================
--- src/regexp-macro-assembler-irregexp.cc (revision 1305)
+++ src/regexp-macro-assembler-irregexp.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright 2008 the V8 project authors. All rights reserved.
+// Copyright 2008-2009 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -39,7 +39,8 @@
RegExpMacroAssemblerIrregexp::RegExpMacroAssemblerIrregexp(Vector<byte> buffer)
: buffer_(buffer),
pc_(0),
- own_buffer_(false) {
+ own_buffer_(false),
+ advance_current_end_(kInvalidPC) {
}
@@ -55,6 +56,7 @@
void RegExpMacroAssemblerIrregexp::Bind(Label* l) {
+ advance_current_end_ = kInvalidPC;
ASSERT(!l->is_bound());
if (l->is_linked()) {
int pos = l->pos();
@@ -172,8 +174,17 @@
void RegExpMacroAssemblerIrregexp::GoTo(Label* l) {
- Emit(BC_GOTO, 0);
- EmitOrLink(l);
+ if (advance_current_end_ == pc_) {
+ // Combine advance current and goto.
+ pc_ = advance_current_start_;
+ Emit(BC_ADVANCE_CP_AND_GOTO, advance_current_offset_);
+ EmitOrLink(l);
+ advance_current_end_ = kInvalidPC;
+ } else {
+ // Regular goto.
+ Emit(BC_GOTO, 0);
+ EmitOrLink(l);
+ }
}
@@ -196,7 +207,10 @@
void RegExpMacroAssemblerIrregexp::AdvanceCurrentPosition(int by) {
ASSERT(by >= kMinCPOffset);
ASSERT(by <= kMaxCPOffset);
+ advance_current_start_ = pc_;
+ advance_current_offset_ = by;
Emit(BC_ADVANCE_CP, by);
+ advance_current_end_ = pc_;
}
« no previous file with comments | « src/regexp-macro-assembler-irregexp.h ('k') | src/regexp-macro-assembler-irregexp-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698