Skip to content

Commit cde6759

Browse files
committed
Merge branch 'windows-port' into webreplay-release
2 parents 42d55fe + a411349 commit cde6759

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+459
-102
lines changed

browser/app/splash.rc

+3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66
#include <windows.h>
77
#include "nsNativeAppSupportWin.h"
88

9+
/* These icons are disabled to avoid build breaks when using non-standard branding. */
10+
/*
911
IDI_APPICON ICON FIREFOX_ICO
1012
IDI_DOCUMENT ICON DOCUMENT_ICO
1113
IDI_APPLICATION ICON FIREFOX_ICO
1214
IDI_NEWWINDOW ICON NEWWINDOW_ICO
1315
IDI_NEWTAB ICON NEWTAB_ICO
1416
IDI_PBMODE ICON PBMODE_ICO
17+
*/
1518

1619
STRINGTABLE DISCARDABLE
1720
BEGIN
37.7 KB
Binary file not shown.
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
body {
6+
color: white;
7+
}
8+
9+
#label,
10+
#progress_background,
11+
#blurb {
12+
text-align: center;
13+
margin: 20px 30px;
14+
}
15+
16+
#label {
17+
font-size: 40px;
18+
margin-top: 100px;
19+
margin-bottom: 20px;
20+
}
21+
22+
#progress_background {
23+
margin: 0 auto;
24+
width: 60%;
25+
height: 24px;
26+
background-color: white;
27+
}
28+
29+
body.high-contrast #progress_background {
30+
outline: solid;
31+
}
32+
33+
#progress_bar {
34+
margin: 0;
35+
width: 0%;
36+
height: 100%;
37+
background-color: #00AAFF;
38+
}
39+
40+
/* In high contrast mode, fill the entire progress bar with its border. */
41+
body.high-contrast #progress_bar {
42+
/* This border should be the height of progress_background. */
43+
border-top: 24px solid;
44+
box-sizing: border-box;
45+
}
46+
47+
/* This layout doesn't want the header or content text. */
48+
#header, #content {
49+
display: none;
50+
}
51+
52+
#blurb {
53+
font-size: 20px;
54+
}
55+
56+
/* The footer goes in the bottom right corner. */
57+
#footer {
58+
position: fixed;
59+
right: 50px;
60+
bottom: 59px;
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
body {
6+
color: white;
7+
}
8+
9+
#header,
10+
#refreshCheckboxContainer,
11+
#refreshButtonContainer {
12+
text-align: center;
13+
margin-left: 40px;
14+
margin-right: 40px;
15+
margin-bottom: 30px;
16+
}
17+
18+
#header {
19+
font-size: 35px;
20+
font-weight: normal;
21+
margin-top: 45px;
22+
}
23+
24+
#refreshCheckbox {
25+
vertical-align: middle;
26+
}
27+
28+
#checkboxLabel {
29+
font-size: 13px;
30+
}
31+
32+
#refreshButton {
33+
padding: 8px 40px;
34+
font-size: 15px;
35+
}
36+
37+
/* The footer goes in the bottom right corner. */
38+
#footer {
39+
position: fixed;
40+
right: 50px;
41+
bottom: 59px;
42+
}
25.2 KB
Binary file not shown.
25.2 KB
Binary file not shown.
151 KB
Binary file not shown.

build.js

+33-17
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,42 @@ const os = require("os");
33
const { spawnSync } = require("child_process");
44
const gecko = __dirname;
55

6-
// Download the latest record/replay driver.
7-
const driverFile = `${currentPlatform()}-recordreplay.so`;
8-
spawnChecked("curl", [`https://replay.io/downloads/${driverFile}`, "-o", driverFile], { stdio: "inherit" });
9-
10-
// Embed the driver in the source.
11-
const driverContents = fs.readFileSync(driverFile);
12-
fs.unlinkSync(driverFile);
13-
let driverString = "";
14-
for (let i = 0; i < driverContents.length; i++) {
15-
driverString += `\\${driverContents[i].toString(8)}`;
16-
}
17-
fs.writeFileSync(
18-
`${gecko}/toolkit/recordreplay/RecordReplayDriver.cpp`,
19-
`
6+
if (process.platform != "win32") {
7+
// Download the latest record/replay driver.
8+
const driverFile = `${currentPlatform()}-recordreplay.so`;
9+
spawnChecked("curl", [`https://replay.io/downloads/${driverFile}`, "-o", driverFile], { stdio: "inherit" });
10+
11+
// Embed the driver in the source.
12+
const driverContents = fs.readFileSync(driverFile);
13+
fs.unlinkSync(driverFile);
14+
let driverString = "";
15+
for (let i = 0; i < driverContents.length; i++) {
16+
driverString += `\\${driverContents[i].toString(8)}`;
17+
}
18+
fs.writeFileSync(
19+
`${gecko}/toolkit/recordreplay/RecordReplayDriver.cpp`,
20+
`
21+
>>>>>>> windows-port
2022
namespace mozilla::recordreplay {
2123
char gRecordReplayDriver[] = "${driverString}";
2224
int gRecordReplayDriverSize = ${driverContents.length};
2325
}
24-
`
25-
);
26+
`
27+
);
28+
} else {
29+
fs.writeFileSync(
30+
`${gecko}/toolkit/recordreplay/RecordReplayDriver.cpp`,
31+
""
32+
);
33+
}
2634

27-
spawnChecked("./mach", ["build"], { stdio: "inherit" });
35+
spawnChecked("bash", ["./mach", "build"], {
36+
stdio: "inherit",
37+
env: {
38+
...process.env,
39+
RUSTC_BOOTSTRAP: "qcms",
40+
},
41+
});
2842

2943
function spawnChecked(cmd, args, options) {
3044
const prettyCmd = [cmd].concat(args).join(" ");
@@ -46,6 +60,8 @@ function currentPlatform() {
4660
return "macOS";
4761
case "linux":
4862
return "linux";
63+
case "win32":
64+
return "windows";
4965
default:
5066
throw new Error(`Platform ${process.platform} not supported`);
5167
}

build/moz.configure/toolchain.configure

+1-1
Original file line numberDiff line numberDiff line change
@@ -1876,7 +1876,7 @@ set_config("MOZ_HARDENING_LDFLAGS_JS", security_hardening_cflags.js_ldflags)
18761876
def frame_pointer_flags(compiler):
18771877
if compiler.type == "clang-cl":
18781878
return namespace(
1879-
enable=["-Oy-"],
1879+
enable=["-Oy-", "-clang:-fno-omit-frame-pointer"],
18801880
disable=["-Oy"],
18811881
)
18821882
return namespace(

gfx/skia/skia/src/ports/SkFontHost_win.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
#include <usp10.h>
4343
#include <objbase.h>
4444

45+
#include "mozilla/RecordReplay.h"
46+
4547
static void (*gEnsureLOGFONTAccessibleProc)(const LOGFONT&);
4648

4749
void SkTypeface_SetEnsureLOGFONTAccessibleProc(void (*proc)(const LOGFONT&)) {
@@ -557,6 +559,11 @@ const void* HDCOffscreen::draw(const SkGlyph& glyph, bool isBW,
557559
uint16_t glyphID = glyph.getGlyphID();
558560
BOOL ret = ExtTextOutW(fDC, 0, 0, ETO_GLYPH_INDEX, nullptr, reinterpret_cast<LPCWSTR>(&glyphID), 1, nullptr);
559561
GdiFlush();
562+
563+
// For now we record/replay the drawn text manually, instead of handling this
564+
// within the recording driver.
565+
mozilla::recordreplay::RecordReplayBytes("HDCOffscreen::draw", fBits, size);
566+
560567
if (0 == ret) {
561568
return nullptr;
562569
}

intl/icu/source/common/umutex.cpp

+16-5
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,19 @@ std::condition_variable *initCondition;
5151
// Used when ICU implementation code passes nullptr for the mutex pointer.
5252
UMutex globalMutex;
5353

54-
pthread_once_t initFlag = PTHREAD_ONCE_INIT;
55-
pthread_once_t *pInitFlag = &initFlag;
54+
std::atomic<int> initFlag{0};
55+
std::atomic<int> *pInitFlag = &initFlag;
56+
57+
static void call_once(std::atomic<int>* init, void (*callback)()) {
58+
int v = 0;
59+
bool rv = std::atomic_compare_exchange_strong(init, &v, 1);
60+
if (rv) {
61+
callback();
62+
*init = 2;
63+
} else {
64+
while (*init != 2) {}
65+
}
66+
}
5667

5768
} // Anonymous namespace
5869

@@ -64,7 +75,7 @@ static UBool U_CALLCONV umtx_cleanup() {
6475

6576
// Reset the once_flag, by destructing it and creating a fresh one in its place.
6677
// Do not use this trick anywhere else in ICU; use umtx_initOnce, not std::call_once().
67-
*pInitFlag = PTHREAD_ONCE_INIT;
78+
*pInitFlag = 0;
6879
return true;
6980
}
7081

@@ -79,7 +90,7 @@ U_CDECL_END
7990
std::mutex *UMutex::getMutex() {
8091
std::mutex *retPtr = fMutex.load(std::memory_order_acquire);
8192
if (retPtr == nullptr) {
82-
pthread_once(pInitFlag, umtx_init);
93+
call_once(pInitFlag, umtx_init);
8394
std::lock_guard<std::mutex> guard(*initMutex);
8495
retPtr = fMutex.load(std::memory_order_acquire);
8596
if (retPtr == nullptr) {
@@ -142,7 +153,7 @@ umtx_unlock(UMutex* mutex)
142153
//
143154
U_COMMON_API UBool U_EXPORT2
144155
umtx_initImplPreInit(UInitOnce &uio) {
145-
pthread_once(pInitFlag, umtx_init);
156+
call_once(pInitFlag, umtx_init);
146157
std::unique_lock<std::mutex> lock(*initMutex);
147158
if (umtx_loadAcquire(uio.fState) == 0) {
148159
umtx_storeRelease(uio.fState, 1);

ipc/chromium/src/base/lock.h

+4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ class Lock {
1919
// Optimized wrapper implementation
2020
Lock(bool ordered = false) : lock_() {
2121
if (ordered) {
22+
#ifndef XP_WIN
2223
mozilla::recordreplay::AddOrderedPthreadMutex("Lock", lock_.native_handle());
24+
#else
25+
mozilla::recordreplay::AddOrderedSRWLock("Lock", lock_.native_handle());
26+
#endif
2327
}
2428
}
2529
~Lock() {}

ipc/chromium/src/base/message_pump_win.cc

+7-5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "base/message_loop.h"
1212
#include "base/histogram.h"
1313
#include "base/win_util.h"
14+
#include "mozilla/RecordReplay.h"
1415
#include "WinUtils.h"
1516
#include "GeckoProfiler.h"
1617

@@ -94,7 +95,7 @@ MessagePumpForUI::~MessagePumpForUI() {
9495
}
9596

9697
void MessagePumpForUI::ScheduleWork() {
97-
if (InterlockedExchange(&have_work_, 1))
98+
if (have_work_.exchange(1))
9899
return; // Someone else continued the pumping.
99100

100101
// Make sure the MessagePump does some work for us.
@@ -257,7 +258,7 @@ void MessagePumpForUI::HandleWorkMessage() {
257258
// sort.
258259
if (!state_) {
259260
// Since we handled a kMsgHaveWork message, we must still update this flag.
260-
InterlockedExchange(&have_work_, 0);
261+
have_work_ = 0;
261262
return;
262263
}
263264

@@ -355,7 +356,7 @@ bool MessagePumpForUI::ProcessPumpReplacementMessage() {
355356
msg.hwnd != message_hwnd_);
356357

357358
// Since we discarded a kMsgHaveWork message, we must update the flag.
358-
int old_have_work = InterlockedExchange(&have_work_, 0);
359+
int old_have_work = have_work_.exchange(0);
359360
DCHECK(old_have_work);
360361

361362
// We don't need a special time slice if we didn't have_message to process.
@@ -378,8 +379,9 @@ MessagePumpForIO::MessagePumpForIO() {
378379
}
379380

380381
void MessagePumpForIO::ScheduleWork() {
381-
if (InterlockedExchange(&have_work_, 1))
382+
if (have_work_.exchange(1)) {
382383
return; // Someone else continued the pumping.
384+
}
383385

384386
// Make sure the MessagePump does some work for us.
385387
BOOL ret =
@@ -498,7 +500,7 @@ bool MessagePumpForIO::ProcessInternalIOItem(const IOItem& item) {
498500
this == reinterpret_cast<MessagePumpForIO*>(item.handler)) {
499501
// This is our internal completion.
500502
DCHECK(!item.bytes_transfered);
501-
InterlockedExchange(&have_work_, 0);
503+
have_work_ = 0;
502504
return true;
503505
}
504506
return false;

ipc/chromium/src/base/message_pump_win.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "base/observer_list.h"
1616
#include "base/scoped_handle.h"
1717
#include "base/time.h"
18+
#include "mozilla/RecordReplay.h"
1819

1920
namespace base {
2021

@@ -102,7 +103,7 @@ class MessagePumpWin : public MessagePump {
102103
// A boolean value used to indicate if there is a kMsgDoWork message pending
103104
// in the Windows Message queue. There is at most one such message, and it
104105
// can drive execution of tasks when a native message pump is running.
105-
LONG have_work_;
106+
mozilla::recordreplay::OrderedAtomic<LONG> have_work_;
106107

107108
// State for the current invocation of Run.
108109
RunState* state_;

ipc/chromium/src/base/shared_memory_win.cc

+18-14
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "base/string_util.h"
1212
#include "mozilla/ipc/ProtocolUtils.h"
1313
#include "mozilla/RandomNum.h"
14+
#include "mozilla/RecordReplay.h"
1415
#include "mozilla/WindowsVersion.h"
1516
#include "nsDebug.h"
1617
#include "nsString.h"
@@ -37,21 +38,24 @@ typedef ULONG(__stdcall* NtQuerySectionType)(
3738
// Checks if the section object is safe to map. At the moment this just means
3839
// it's not an image section.
3940
bool IsSectionSafeToMap(HANDLE handle) {
40-
static NtQuerySectionType nt_query_section_func =
41-
reinterpret_cast<NtQuerySectionType>(
42-
::GetProcAddress(::GetModuleHandle(L"ntdll.dll"), "NtQuerySection"));
43-
DCHECK(nt_query_section_func);
44-
45-
// The handle must have SECTION_QUERY access for this to succeed.
46-
SECTION_BASIC_INFORMATION basic_information = {};
47-
ULONG status =
48-
nt_query_section_func(handle, SectionBasicInformation, &basic_information,
49-
sizeof(basic_information), nullptr);
50-
if (status) {
51-
return false;
41+
// Avoid calling NtQuerySection when replaying, as intercepting this function
42+
// causes crashes inside ntdll when recording for some reason.
43+
bool rv = false;
44+
if (!mozilla::recordreplay::IsReplaying()) {
45+
mozilla::recordreplay::AutoPassThroughThreadEvents pt;
46+
static NtQuerySectionType nt_query_section_func =
47+
reinterpret_cast<NtQuerySectionType>(
48+
::GetProcAddress(::GetModuleHandle(L"ntdll.dll"), "NtQuerySection"));
49+
DCHECK(nt_query_section_func);
50+
51+
// The handle must have SECTION_QUERY access for this to succeed.
52+
SECTION_BASIC_INFORMATION basic_information = {};
53+
ULONG status =
54+
nt_query_section_func(handle, SectionBasicInformation, &basic_information,
55+
sizeof(basic_information), nullptr);
56+
rv = status ? false : ((basic_information.Attributes & SEC_IMAGE) != SEC_IMAGE);
5257
}
53-
54-
return (basic_information.Attributes & SEC_IMAGE) != SEC_IMAGE;
58+
return mozilla::recordreplay::RecordReplayValue("IsSectionSafeToMap", rv);
5559
}
5660

5761
} // namespace

0 commit comments

Comments
 (0)