AuroraEngine V8 MSVC/Multi-char, external buildchain, etc patches

This commit is contained in:
Reece Wilson 2020-12-11 12:37:14 -08:00
parent 3fbc94f625
commit a22b3c35b3
17 changed files with 260 additions and 45 deletions

10
.gclient Normal file
View File

@ -0,0 +1,10 @@
solutions = [
{ "name" : 'v8',
"url" : 'http://github.com/AuroraEngine/v8',
"deps_file" : 'DEPS',
"managed" : True,
"custom_deps" : {
},
"custom_vars": {},
},
]

View File

@ -96,10 +96,12 @@
// do not support adding noexcept to default members.
// Disabled on MSVC because constructors of standard containers are not noexcept
// there.
#if ((!defined(V8_CC_GNU) && !defined(V8_CC_MSVC) && \
#if (((!defined(V8_CC_GNU) && !defined(V8_CC_MSVC) && \
!defined(V8_TARGET_ARCH_MIPS) && !defined(V8_TARGET_ARCH_MIPS64) && \
!defined(V8_TARGET_ARCH_PPC) && !defined(V8_TARGET_ARCH_PPC64)) || \
(defined(__clang__) && __cplusplus > 201300L))
(defined(__clang__) && __cplusplus > 201300L))\
\
&& defined(HAVE_LE_GOOGLERS_UNFUCKED_THEIR_API_YET))
#define V8_NOEXCEPT noexcept
#else
#define V8_NOEXCEPT

View File

@ -81,7 +81,7 @@ bool InitializeSymbols() {
}
wchar_t exe_path[MAX_PATH];
GetModuleFileName(nullptr, exe_path, MAX_PATH);
GetModuleFileNameW(nullptr, exe_path, MAX_PATH);
std::wstring exe_path_wstring(exe_path);
// To get the path without the filename, we just need to remove the final
// slash and everything after it.

View File

@ -888,7 +888,7 @@ bool OS::DiscardSystemPages(void* address, size_t size) {
reinterpret_cast<DiscardVirtualMemoryFunction>(-1))
discard_virtual_memory =
reinterpret_cast<DiscardVirtualMemoryFunction>(GetProcAddress(
GetModuleHandle(L"Kernel32.dll"), "DiscardVirtualMemory"));
GetModuleHandleW(L"Kernel32.dll"), "DiscardVirtualMemory"));
// Use DiscardVirtualMemory when available because it releases faster than
// MEM_RESET.
DiscardVirtualMemoryFunction discard_function = discard_virtual_memory.load();

View File

@ -29,8 +29,12 @@
#endif
// Require Windows Vista or higher (this is required for the
// QueryThreadCycleTime function to be present).
// Update: unwinding-info-64 depends on Rtl functions which have their typedefs lazily yoinked
// Windows 10s latest SDK requires us to either define something blah blah blah i dont care
// ...or to upgrade to a Windows 8+ target
#define _WIN32_WINNT_WIN8 0x0602
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0600
#define _WIN32_WINNT _WIN32_WINNT_WIN8
#endif
#include <windows.h>

View File

@ -0,0 +1,170 @@
/* compression_utils_portable.cc
*
* Copyright 2019 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the Chromium source repository LICENSE file.
*/
#include "compression_utils_portable.h"
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
namespace zlib_internal {
// The difference in bytes between a zlib header and a gzip header.
const size_t kGzipZlibHeaderDifferenceBytes = 16;
// Pass an integer greater than the following get a gzip header instead of a
// zlib header when calling deflateInit2() and inflateInit2().
const int kWindowBitsToGetGzipHeader = 16;
// This describes the amount of memory zlib uses to compress data. It can go
// from 1 to 9, with 8 being the default. For details, see:
// http://www.zlib.net/manual.html (search for memLevel).
const int kZlibMemoryLevel = 8;
// The expected compressed size is based on the input size factored by
// internal Zlib constants (e.g. window size, etc) plus the wrapper
// header size.
uLongf GzipExpectedCompressedSize(uLongf input_size) {
return kGzipZlibHeaderDifferenceBytes + compressBound(input_size);
}
// The expected decompressed size is stored in the last
// 4 bytes of |input| in LE. See https://tools.ietf.org/html/rfc1952#page-5
uint32_t GetGzipUncompressedSize(const Bytef* compressed_data, size_t length) {
uint32_t size;
if (length < sizeof(size))
return 0;
memcpy(&size, &compressed_data[length - sizeof(size)], sizeof(size));
return size;
}
// The number of window bits determines the type of wrapper to use - see
// https://cs.chromium.org/chromium/src/third_party/zlib/zlib.h?l=566
inline int ZlibStreamWrapperType(WrapperType type) {
if (type == ZLIB) // zlib DEFLATE stream wrapper
return MAX_WBITS;
if (type == GZIP) // gzip DEFLATE stream wrapper
return MAX_WBITS + kWindowBitsToGetGzipHeader;
if (type == ZRAW) // no wrapper, use raw DEFLATE
return -MAX_WBITS;
return 0;
}
int GzipCompressHelper(Bytef* dest,
uLongf* dest_length,
const Bytef* source,
uLong source_length,
void* (*malloc_fn)(size_t),
void (*free_fn)(void*)) {
return CompressHelper(GZIP, dest, dest_length, source, source_length,
Z_DEFAULT_COMPRESSION, malloc_fn, free_fn);
}
// This code is taken almost verbatim from third_party/zlib/compress.c. The only
// difference is deflateInit2() is called which allows different window bits to
// be set. > 16 causes a gzip header to be emitted rather than a zlib header,
// and negative causes no header to emitted.
//
// Compression level can be a number from 1-9, with 1 being the fastest, 9 being
// the best compression. The default, which the GZIP helper uses, is 6.
int CompressHelper(WrapperType wrapper_type,
Bytef* dest,
uLongf* dest_length,
const Bytef* source,
uLong source_length,
int compression_level,
void* (*malloc_fn)(size_t),
void (*free_fn)(void*)) {
if (compression_level < 0 || compression_level > 9) {
compression_level = Z_DEFAULT_COMPRESSION;
}
z_stream stream;
// FIXME(cavalcantii): z_const is not defined as 'const'.
stream.next_in = static_cast<z_const Bytef*>(const_cast<Bytef*>(source));
stream.avail_in = static_cast<uInt>(source_length);
stream.next_out = dest;
stream.avail_out = static_cast<uInt>(*dest_length);
if (static_cast<uLong>(stream.avail_out) != *dest_length)
return Z_BUF_ERROR;
// Cannot convert capturing lambdas to function pointers directly, hence the
// structure.
struct MallocFreeFunctions {
void* (*malloc_fn)(size_t);
void (*free_fn)(void*);
} malloc_free = {malloc_fn, free_fn};
if (malloc_fn) {
if (!free_fn)
return Z_BUF_ERROR;
auto zalloc = [](void* opaque, uInt items, uInt size) {
return reinterpret_cast<MallocFreeFunctions*>(opaque)->malloc_fn(items *
size);
};
auto zfree = [](void* opaque, void* address) {
return reinterpret_cast<MallocFreeFunctions*>(opaque)->free_fn(address);
};
stream.zalloc = static_cast<alloc_func>(zalloc);
stream.zfree = static_cast<free_func>(zfree);
stream.opaque = static_cast<voidpf>(&malloc_free);
} else {
stream.zalloc = static_cast<alloc_func>(0);
stream.zfree = static_cast<free_func>(0);
stream.opaque = static_cast<voidpf>(0);
}
int err = deflateInit2(&stream, compression_level, Z_DEFLATED,
ZlibStreamWrapperType(wrapper_type), kZlibMemoryLevel,
Z_DEFAULT_STRATEGY);
if (err != Z_OK)
return err;
// This has to exist outside of the if statement to prevent it going off the
// stack before deflate(), which will use this object.
gz_header gzip_header;
if (wrapper_type == GZIP) {
memset(&gzip_header, 0, sizeof(gzip_header));
err = deflateSetHeader(&stream, &gzip_header);
if (err != Z_OK)
return err;
}
err = deflate(&stream, Z_FINISH);
if (err != Z_STREAM_END) {
deflateEnd(&stream);
return err == Z_OK ? Z_BUF_ERROR : err;
}
*dest_length = stream.total_out;
err = deflateEnd(&stream);
return err;
}
int GzipUncompressHelper(Bytef* dest,
uLongf* dest_length,
const Bytef* source,
uLong source_length) {
return UncompressHelper(GZIP, dest, dest_length, source, source_length);
}
// This code is taken almost verbatim from third_party/zlib/uncompr.c. The only
// difference is inflateInit2() is called which allows different window bits to
// be set. > 16 causes a gzip header to be emitted rather than a zlib header,
// and negative causes no header to emitted.
int UncompressHelper(WrapperType wrapper_type,
Bytef* dest,
uLongf* dest_length,
const Bytef* source,
uLong source_length) {
z_stream stream;
// FIXME(cavalcantii): z_const is not defined as 'const'.
stream.next_in = static_cast<z_const Bytef*>(const_cast<Bytef*>(source));
stream.avail_in = static_cast<uInt>(source_length);
if (static_cast<uLong>(stream.avail_in) != source_length)
return Z_BUF_ERROR;
stream.next_out = dest;
stream.avail_out = static_cast<uInt>(*dest_length);
if (static_cast<uLong>(stream.avail_out) != *dest_length)
return Z_BUF_ERROR;
stream.zalloc = static_cast<alloc_func>(0);
stream.zfree = static_cast<free_func>(0);
int err = inflateInit2(&stream, ZlibStreamWrapperType(wrapper_type));
if (err != Z_OK)
return err;
err = inflate(&stream, Z_FINISH);
if (err != Z_STREAM_END) {
inflateEnd(&stream);
if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))
return Z_DATA_ERROR;
return err;
}
*dest_length = stream.total_out;
err = inflateEnd(&stream);
return err;
}
} // namespace zlib_internal

View File

@ -0,0 +1,31 @@
/* compression_utils_portable.h
*
* Copyright 2019 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the Chromium source repository LICENSE file.
*/
#ifndef THIRD_PARTY_ZLIB_GOOGLE_COMPRESSION_UTILS_PORTABLE_H_
#define THIRD_PARTY_ZLIB_GOOGLE_COMPRESSION_UTILS_PORTABLE_H_
#include <stdint.h>
#include <zlib.h>
namespace zlib_internal {
enum WrapperType {
ZLIB,
GZIP,
ZRAW,
};
uLongf GzipExpectedCompressedSize(uLongf input_size);
uint32_t GetGzipUncompressedSize(const Bytef* compressed_data, size_t length);
int GzipCompressHelper(Bytef* dest, uLongf* dest_length, const Bytef* source,
uLong source_length, void* (*malloc_fn)(size_t),
void (*free_fn)(void*));
int CompressHelper(WrapperType wrapper_type, Bytef* dest, uLongf* dest_length,
const Bytef* source, uLong source_length,
int compression_level, void* (*malloc_fn)(size_t),
void (*free_fn)(void*));
int GzipUncompressHelper(Bytef* dest, uLongf* dest_length, const Bytef* source,
uLong source_length);
int UncompressHelper(WrapperType wrapper_type, Bytef* dest, uLongf* dest_length,
const Bytef* source, uLong source_length);
} // namespace zlib_internal
#endif // THIRD_PARTY_ZLIB_GOOGLE_COMPRESSION_UTILS_PORTABLE_H_

View File

@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/diagnostics/unwinding-info-win64.h"
#include <winnt.h>
#include "src/codegen/macro-assembler.h"
#include "src/utils/allocation.h"
@ -467,7 +469,7 @@ void LoadNtdllUnwindingFunctions() {
base::CallOnce(&load_ntdll_unwinding_functions_once, []() {
// Load functions from the ntdll.dll module.
HMODULE ntdll_module =
LoadLibraryEx(L"ntdll.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
LoadLibraryExW(L"ntdll.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
DCHECK_NOT_NULL(ntdll_module);
// This fails on Windows 7.

View File

@ -1021,7 +1021,7 @@ std::unique_ptr<icu::TimeZone> CreateTimeZone(const char* timezone) {
std::string canonicalized = CanonicalizeTimeZoneID(timezone);
if (canonicalized.empty()) return std::unique_ptr<icu::TimeZone>();
std::unique_ptr<icu::TimeZone> tz(
icu::TimeZone::createTimeZone(canonicalized.c_str()));
icu::TimeZone::createTimeZone(icu::UnicodeString(canonicalized.c_str())));
// 18.b If the result of IsValidTimeZoneName(timeZone) is false, then
// i. Throw a RangeError exception.
if (!IsValidTimeZoneName(*tz)) return std::unique_ptr<icu::TimeZone>();

View File

@ -328,17 +328,17 @@ Handle<String> CurrencyDisplayString(Isolate* isolate,
const icu::UnicodeString& skeleton) {
// Ex: skeleton as
// "currency/TWD .00 rounding-mode-half-up unit-width-iso-code"
if (skeleton.indexOf("unit-width-iso-code") >= 0) {
if (skeleton.indexOf(icu::UnicodeString("unit-width-iso-code")) >= 0) {
return ReadOnlyRoots(isolate).code_string_handle();
}
// Ex: skeleton as
// "currency/TWD .00 rounding-mode-half-up unit-width-full-name;"
if (skeleton.indexOf("unit-width-full-name") >= 0) {
if (skeleton.indexOf(icu::UnicodeString("unit-width-full-name")) >= 0) {
return ReadOnlyRoots(isolate).name_string_handle();
}
// Ex: skeleton as
// "currency/TWD .00 rounding-mode-half-up unit-width-narrow;
if (skeleton.indexOf("unit-width-narrow") >= 0) {
if (skeleton.indexOf(icu::UnicodeString("unit-width-narrow")) >= 0) {
return ReadOnlyRoots(isolate).narrowSymbol_string_handle();
}
// Ex: skeleton as "currency/TWD .00 rounding-mode-half-up"
@ -347,7 +347,7 @@ Handle<String> CurrencyDisplayString(Isolate* isolate,
// Return true if there are no "group-off" in the skeleton.
bool UseGroupingFromSkeleton(const icu::UnicodeString& skeleton) {
return skeleton.indexOf("group-off") == -1;
return skeleton.indexOf(icu::UnicodeString("group-off")) == -1;
}
// Parse currency code from skeleton. For example, skeleton as
@ -355,8 +355,8 @@ bool UseGroupingFromSkeleton(const icu::UnicodeString& skeleton) {
const icu::UnicodeString CurrencyFromSkeleton(
const icu::UnicodeString& skeleton) {
const char currency[] = "currency/";
int32_t index = skeleton.indexOf(currency);
if (index < 0) return "";
int32_t index = skeleton.indexOf(icu::UnicodeString(currency));
if (index < 0) return icu::UnicodeString("");
index += static_cast<int32_t>(std::strlen(currency));
return skeleton.tempSubString(index, 3);
}
@ -364,11 +364,11 @@ const icu::UnicodeString CurrencyFromSkeleton(
const icu::UnicodeString NumberingSystemFromSkeleton(
const icu::UnicodeString& skeleton) {
const char numbering_system[] = "numbering-system/";
int32_t index = skeleton.indexOf(numbering_system);
if (index < 0) return "latn";
int32_t index = skeleton.indexOf(icu::UnicodeString(numbering_system));
if (index < 0) return icu::UnicodeString("latn");
index += static_cast<int32_t>(std::strlen(numbering_system));
const icu::UnicodeString res = skeleton.tempSubString(index);
index = res.indexOf(" ");
index = res.indexOf(icu::UnicodeString(" "));
if (index < 0) return res;
return res.tempSubString(0, index);
}
@ -379,7 +379,7 @@ Handle<String> CurrencySignString(Isolate* isolate,
// Ex: skeleton as
// "currency/TWD .00 rounding-mode-half-up sign-accounting-always" OR
// "currency/TWD .00 rounding-mode-half-up sign-accounting-except-zero"
if (skeleton.indexOf("sign-accounting") >= 0) {
if (skeleton.indexOf(icu::UnicodeString(("sign-accounting"))) >= 0) {
return ReadOnlyRoots(isolate).accounting_string_handle();
}
return ReadOnlyRoots(isolate).standard_string_handle();
@ -390,12 +390,12 @@ Handle<String> UnitDisplayString(Isolate* isolate,
const icu::UnicodeString& skeleton) {
// Ex: skeleton as
// "unit/length-meter .### rounding-mode-half-up unit-width-full-name"
if (skeleton.indexOf("unit-width-full-name") >= 0) {
if (skeleton.indexOf(icu::UnicodeString("unit-width-full-name")) >= 0) {
return ReadOnlyRoots(isolate).long_string_handle();
}
// Ex: skeleton as
// "unit/length-meter .### rounding-mode-half-up unit-width-narrow".
if (skeleton.indexOf("unit-width-narrow") >= 0) {
if (skeleton.indexOf(icu::UnicodeString("unit-width-narrow")) >= 0) {
return ReadOnlyRoots(isolate).narrow_string_handle();
}
// Ex: skeleton as
@ -407,18 +407,18 @@ Handle<String> UnitDisplayString(Isolate* isolate,
Notation NotationFromSkeleton(const icu::UnicodeString& skeleton) {
// Ex: skeleton as
// "scientific .### rounding-mode-half-up"
if (skeleton.indexOf("scientific") >= 0) {
if (skeleton.indexOf(icu::UnicodeString("scientific")) >= 0) {
return Notation::SCIENTIFIC;
}
// Ex: skeleton as
// "engineering .### rounding-mode-half-up"
if (skeleton.indexOf("engineering") >= 0) {
if (skeleton.indexOf(icu::UnicodeString("engineering")) >= 0) {
return Notation::ENGINEERING;
}
// Ex: skeleton as
// "compact-short .### rounding-mode-half-up" or
// "compact-long .### rounding-mode-half-up
if (skeleton.indexOf("compact-") >= 0) {
if (skeleton.indexOf(icu::UnicodeString("compact-")) >= 0) {
return Notation::COMPACT;
}
// Ex: skeleton as
@ -445,12 +445,12 @@ Handle<String> CompactDisplayString(Isolate* isolate,
const icu::UnicodeString& skeleton) {
// Ex: skeleton as
// "compact-long .### rounding-mode-half-up"
if (skeleton.indexOf("compact-long") >= 0) {
if (skeleton.indexOf(icu::UnicodeString("compact-long")) >= 0) {
return ReadOnlyRoots(isolate).long_string_handle();
}
// Ex: skeleton as
// "compact-short .### rounding-mode-half-up"
DCHECK_GE(skeleton.indexOf("compact-short"), 0);
DCHECK_GE(skeleton.indexOf(icu::UnicodeString("compact-short")), 0);
return ReadOnlyRoots(isolate).short_string_handle();
}
@ -459,21 +459,21 @@ Handle<String> SignDisplayString(Isolate* isolate,
const icu::UnicodeString& skeleton) {
// Ex: skeleton as
// "currency/TWD .00 rounding-mode-half-up sign-never"
if (skeleton.indexOf("sign-never") >= 0) {
if (skeleton.indexOf(icu::UnicodeString("sign-never")) >= 0) {
return ReadOnlyRoots(isolate).never_string_handle();
}
// Ex: skeleton as
// ".### rounding-mode-half-up sign-always" or
// "currency/TWD .00 rounding-mode-half-up sign-accounting-always"
if (skeleton.indexOf("sign-always") >= 0 ||
skeleton.indexOf("sign-accounting-always") >= 0) {
if (skeleton.indexOf(icu::UnicodeString("sign-always")) >= 0 ||
skeleton.indexOf(icu::UnicodeString("sign-accounting-always")) >= 0) {
return ReadOnlyRoots(isolate).always_string_handle();
}
// Ex: skeleton as
// "currency/TWD .00 rounding-mode-half-up sign-accounting-except-zero" or
// "currency/TWD .00 rounding-mode-half-up sign-except-zero"
if (skeleton.indexOf("sign-accounting-except-zero") >= 0 ||
skeleton.indexOf("sign-except-zero") >= 0) {
if (skeleton.indexOf(icu::UnicodeString("sign-accounting-except-zero")) >= 0 ||
skeleton.indexOf(icu::UnicodeString("sign-except-zero")) >= 0) {
return ReadOnlyRoots(isolate).exceptZero_string_handle();
}
return ReadOnlyRoots(isolate).auto_string_handle();
@ -603,19 +603,19 @@ std::string UnitFromSkeleton(const icu::UnicodeString& skeleton) {
}
Style StyleFromSkeleton(const icu::UnicodeString& skeleton) {
if (skeleton.indexOf("currency/") >= 0) {
if (skeleton.indexOf(icu::UnicodeString("currency/")) >= 0) {
return Style::CURRENCY;
}
if (skeleton.indexOf("percent") >= 0) {
if (skeleton.indexOf(icu::UnicodeString("percent")) >= 0) {
// percent precision-integer rounding-mode-half-up scale/100
if (skeleton.indexOf("scale/100") >= 0) {
if (skeleton.indexOf(icu::UnicodeString("scale/100")) >= 0) {
return Style::PERCENT;
} else {
return Style::UNIT;
}
}
// Before ICU68: "measure-unit/", since ICU68 "unit/"
if (skeleton.indexOf("unit/") >= 0) {
if (skeleton.indexOf(icu::UnicodeString("unit/")) >= 0) {
return Style::UNIT;
}
return Style::DECIMAL;
@ -1043,7 +1043,7 @@ MaybeHandle<JSNumberFormat> JSNumberFormat::New(Isolate* isolate,
// 14.a. Let currency be the result of converting currency to upper case as
// specified in 6.1
std::transform(currency.begin(), currency.end(), currency.begin(), toupper);
currency_ustr = currency.c_str();
currency_ustr = icu::UnicodeString(currency.c_str());
// 14.b. Set numberFormat.[[Currency]] to currency.
if (!currency_ustr.isEmpty()) {

View File

@ -51,7 +51,7 @@ void PrintSpecial(std::ofstream& out) {
icu::UnicodeSet special_add;
icu::UnicodeSet ignore;
UErrorCode status = U_ZERO_ERROR;
icu::UnicodeSet upper("[\\p{Lu}]", status);
icu::UnicodeSet upper(icu::UnicodeString("[\\p{Lu}]"), status);
CHECK(U_SUCCESS(status));
// Iterate through all chars in BMP except surrogates.

View File

@ -461,7 +461,8 @@ int CompareFirstCharCaseInsensitve(RegExpTree* const* a, RegExpTree* const* b) {
RegExpAtom* atom1 = (*a)->AsAtom();
RegExpAtom* atom2 = (*b)->AsAtom();
icu::UnicodeString character1(atom1->data().at(0));
return character1.caseCompare(atom2->data().at(0), U_FOLD_CASE_DEFAULT);
icu::UnicodeString character2(atom2->data().at(0));
return character1.caseCompare(character2, U_FOLD_CASE_DEFAULT);
}
#else

View File

@ -7,7 +7,7 @@
#include "src/base/platform/elapsed-timer.h"
#include "src/utils/memcopy.h"
#include "src/utils/utils.h"
#include "third_party/zlib/google/compression_utils_portable.h"
#include "src/common/compression_utils_portable.h"
namespace v8 {
namespace internal {

View File

@ -5,7 +5,7 @@
#include "src/snapshot/snapshot-utils.h"
#include "src/sanitizer/msan.h"
#include "third_party/zlib/zlib.h"
#include "zlib.h"
namespace v8 {
namespace internal {

View File

@ -22,11 +22,8 @@
// This file contains most of the code that actually runs in an exception
// handler context. Some additional code is used both inside and outside the
// trap handler. This code can be found in handler-shared.cc.
#include "src/base/win32-headers.h"
#include "src/trap-handler/handler-inside-win.h"
#include <windows.h>
#include "src/trap-handler/trap-handler-internal.h"
#include "src/trap-handler/trap-handler.h"

View File

@ -18,9 +18,7 @@
// For more information, see https://goo.gl/yMeyUY.
//
// For the code that runs in the trap handler itself, see handler-inside.cc.
#include <windows.h>
#include "src/base/win32-headers.h"
#include "src/trap-handler/handler-inside-win.h"
#include "src/trap-handler/trap-handler.h"