summaryrefslogtreecommitdiff
path: root/deps/v8/src/regexp/regexp-bytecodes.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/regexp/regexp-bytecodes.cc')
-rw-r--r--deps/v8/src/regexp/regexp-bytecodes.cc46
1 files changed, 46 insertions, 0 deletions
diff --git a/deps/v8/src/regexp/regexp-bytecodes.cc b/deps/v8/src/regexp/regexp-bytecodes.cc
new file mode 100644
index 0000000000..fbf8273ab4
--- /dev/null
+++ b/deps/v8/src/regexp/regexp-bytecodes.cc
@@ -0,0 +1,46 @@
+// Copyright 2019 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/regexp/regexp-bytecodes.h"
+
+#include <cctype>
+
+#include "src/utils/utils.h"
+
+namespace v8 {
+namespace internal {
+
+void RegExpBytecodeDisassembleSingle(const byte* code_base, const byte* pc) {
+ PrintF("%s", RegExpBytecodeName(*pc));
+
+ // Args and the bytecode as hex.
+ for (int i = 0; i < RegExpBytecodeLength(*pc); i++) {
+ PrintF(", %02x", pc[i]);
+ }
+ PrintF(" ");
+
+ // Args as ascii.
+ for (int i = 1; i < RegExpBytecodeLength(*pc); i++) {
+ unsigned char b = pc[i];
+ PrintF("%c", std::isprint(b) ? b : '.');
+ }
+ PrintF("\n");
+}
+
+void RegExpBytecodeDisassemble(const byte* code_base, int length,
+ const char* pattern) {
+ PrintF("[generated bytecode for regexp pattern: '%s']\n", pattern);
+
+ ptrdiff_t offset = 0;
+
+ while (offset < length) {
+ const byte* const pc = code_base + offset;
+ PrintF("%p %4" V8PRIxPTRDIFF " ", pc, offset);
+ RegExpBytecodeDisassembleSingle(code_base, pc);
+ offset += RegExpBytecodeLength(*pc);
+ }
+}
+
+} // namespace internal
+} // namespace v8