diff options
author | Matt A. Tobin <email@mattatobin.com> | 2020-11-09 20:20:18 -0500 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2020-11-09 20:20:18 -0500 |
commit | cb0208163f5b44651831f217db0d0d4e97dd2463 (patch) | |
tree | f9489df88dad982d544d3799fc6728d9211e6d55 /js/src/regexp/regexp-shim.cc | |
parent | 19499014a36f2f27ac81d11495fdc5bdbd28ae25 (diff) | |
download | UXP-cb0208163f5b44651831f217db0d0d4e97dd2463.tar UXP-cb0208163f5b44651831f217db0d0d4e97dd2463.tar.gz UXP-cb0208163f5b44651831f217db0d0d4e97dd2463.tar.lz UXP-cb0208163f5b44651831f217db0d0d4e97dd2463.tar.xz UXP-cb0208163f5b44651831f217db0d0d4e97dd2463.zip |
Issue #1677 - Part 3: Create shim definitions for V8-specific code in new regexp implementation
Diffstat (limited to 'js/src/regexp/regexp-shim.cc')
-rw-r--r-- | js/src/regexp/regexp-shim.cc | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/js/src/regexp/regexp-shim.cc b/js/src/regexp/regexp-shim.cc new file mode 100644 index 000000000..5e1da7a60 --- /dev/null +++ b/js/src/regexp/regexp-shim.cc @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * vim: set ts=8 sts=2 et sw=2 tw=80: + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// 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 "regexp/regexp-shim.h" + +namespace v8 { +namespace internal { + +void PrintF(const char* format, ...) { + va_list arguments; + va_start(arguments, format); + vprintf(format, arguments); + va_end(arguments); +} + +void PrintF(FILE* out, const char* format, ...) { + va_list arguments; + va_start(arguments, format); + vfprintf(out, format, arguments); + va_end(arguments); +} + +// Origin: +// https://github.com/v8/v8/blob/855591a54d160303349a5f0a32fab15825c708d1/src/utils/ostreams.cc#L120-L169 +// (This is a hand-simplified version.) +// Writes the given character to the output escaping everything outside +// of printable ASCII range. +std::ostream& operator<<(std::ostream& os, const AsUC16& c) { + uint16_t v = c.value; + bool isPrint = 0x20 < v && v <= 0x7e; + char buf[10]; + const char* format = isPrint ? "%c" : (v <= 0xFF) ? "\\x%02x" : "\\u%04x"; + snprintf(buf, sizeof(buf), format, v); + return os << buf; +} +std::ostream& operator<<(std::ostream& os, const AsUC32& c) { + int32_t v = c.value; + if (v <= String::kMaxUtf16CodeUnit) { + return os << AsUC16(v); + } + char buf[13]; + snprintf(buf, sizeof(buf), "\\u{%06x}", v); + return os << buf; +} + +DisallowJavascriptExecution::DisallowJavascriptExecution(Isolate* isolate) + : nojs_(isolate->cx()) {} + +// TODO: Map flags to jitoptions +bool FLAG_correctness_fuzzer_suppressions = false; +bool FLAG_enable_regexp_unaligned_accesses = false; +bool FLAG_harmony_regexp_sequence = false; +bool FLAG_regexp_interpret_all = false; +bool FLAG_regexp_mode_modifiers = false; +bool FLAG_regexp_optimization = false; +bool FLAG_regexp_peephole_optimization = false; +bool FLAG_regexp_possessive_quantifier = false; +bool FLAG_regexp_tier_up = false; +bool FLAG_trace_regexp_assembler = false; +bool FLAG_trace_regexp_bytecodes = false; +bool FLAG_trace_regexp_parser = false; +bool FLAG_trace_regexp_peephole_optimization = false; + +} // namespace internal +} // namespace v8 |