Skip to content

Commit

Permalink
Merge pull request mozilla#12 from bytecodealliance/cfallin/fix-stubd…
Browse files Browse the repository at this point in the history
…ata-align

Fix some debug-asserts in PBL.
  • Loading branch information
cfallin authored Aug 24, 2023
2 parents 52c032c + 8fa5a4a commit 05045b6
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 15 deletions.
2 changes: 1 addition & 1 deletion js/src/jit-test/tests/arguments/bug1827073.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function f1(a2, a3, a4, a5) {
f2();
}
function f2() {
if (depth++ > 100) {
if (depth++ > 75) {
return;
}
f1(1, 2);
Expand Down
6 changes: 3 additions & 3 deletions js/src/jit-test/tests/asm.js/testJumpRange.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ load(libdir + "asm.js");
load(libdir + "asserts.js");

var fatFunc = USE_ASM + '\n';
for (var i = 0; i < 100; i++)
for (var i = 0; i < 75; i++)
fatFunc += "function f" + i + "() { return ((f" + (i+1) + "()|0)+1)|0 }\n";
fatFunc += "function f100() { return 42 }\n";
fatFunc += "function f75() { return 42 }\n";
fatFunc += "return f0";

for (let threshold of [0, 50, 100, 5000, -1]) {
Expand All @@ -22,5 +22,5 @@ for (let threshold of [0, 50, 100, 5000, -1]) {
asmLink(asmCompile(USE_ASM + 'function f() {} function g() { f() } function h() { g() } return h'))();
disableGeckoProfiling();

assertEq(asmCompile(fatFunc)()(), 142);
assertEq(asmCompile(fatFunc)()(), 117);
}
2 changes: 1 addition & 1 deletion js/src/jit-test/tests/auto-regress/bug743094.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var i = 0;

gczeal(2);
function test() {
if (i++ > 200)
if (i++ > 75)
return "function";
var res = typeof (new test("1")) != 'function';
return res ? "function" : "string";
Expand Down
2 changes: 1 addition & 1 deletion js/src/jit-test/tests/environments/bug1710089.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// |jit-test| skip-if: getBuildConfiguration()['wasi']

var iters = 100;
var iters = 75;

// Generate a deeply nested version of:
// function outer() {
Expand Down
4 changes: 2 additions & 2 deletions js/src/jit-test/tests/regexp/bug1697077.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// |jit-test| skip-if: !('interruptRegexp' in this)
// |jit-test| skip-if: !('interruptRegexp' in this) || getBuildConfiguration()['pbl']
var s0 = "A".repeat(10*1024);
var interrupted = false;
gczeal(0);
Expand All @@ -8,4 +8,4 @@ setInterruptCallback(() => {
return true;
});
assertEq(interruptRegexp(/a(bc|bd)/, s0), null);
assertEq(interrupted, true);
assertEq(interrupted, true);
2 changes: 1 addition & 1 deletion js/src/jit/CacheIRCompiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,7 @@ inline uintptr_t CacheIRStubInfo::getStubRawWord(ICCacheIRStub* stub,

inline int32_t CacheIRStubInfo::getStubRawInt32(const uint8_t* stubData,
uint32_t offset) const {
MOZ_ASSERT(uintptr_t(stubData + offset) % sizeof(int64_t) == 0);
MOZ_ASSERT(uintptr_t(stubData + offset) % sizeof(int32_t) == 0);
return *reinterpret_cast<const int32_t*>(stubData + offset);
}

Expand Down
6 changes: 6 additions & 0 deletions js/src/vm/HelperThreads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ void js::FinishOffThreadIonCompile(jit::IonCompileTask* task,
->numFinishedOffThreadTasksRef(lock)++;
}

#ifndef ENABLE_PORTABLE_BASELINE_INTERP
static JSRuntime* GetSelectorRuntime(const CompilationSelector& selector) {
struct Matcher {
JSRuntime* operator()(JSScript* script) {
Expand All @@ -329,6 +330,7 @@ static JSRuntime* GetSelectorRuntime(const CompilationSelector& selector) {

return selector.match(Matcher());
}
#endif

static bool JitDataStructuresExist(const CompilationSelector& selector) {
struct Matcher {
Expand All @@ -342,6 +344,7 @@ static bool JitDataStructuresExist(const CompilationSelector& selector) {
return selector.match(Matcher());
}

#ifndef ENABLE_PORTABLE_BASELINE_INTERP
static bool IonCompileTaskMatches(const CompilationSelector& selector,
jit::IonCompileTask* task) {
struct TaskMatches {
Expand All @@ -363,9 +366,11 @@ static bool IonCompileTaskMatches(const CompilationSelector& selector,

return selector.match(TaskMatches{task});
}
#endif

static void CancelOffThreadIonCompileLocked(const CompilationSelector& selector,
AutoLockHelperThreadState& lock) {
#ifndef ENABLE_PORTABLE_BASELINE_INTERP
if (!HelperThreadState().isInitialized(lock)) {
return;
}
Expand Down Expand Up @@ -434,6 +439,7 @@ static void CancelOffThreadIonCompileLocked(const CompilationSelector& selector,
task = next;
}
}
#endif // ENABLE_PORTABLE_BASELINE_INTERP
}

void js::CancelOffThreadIonCompile(const CompilationSelector& selector) {
Expand Down
21 changes: 15 additions & 6 deletions js/src/vm/PortableBaselineInterpret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "builtin/DataViewObject.h"
#include "builtin/MapObject.h"
#include "debugger/DebugAPI.h"
#include "jit/BaselineFrame.h"
#include "jit/BaselineIC.h"
#include "jit/BaselineJIT.h"
Expand All @@ -41,6 +42,7 @@
#include "vm/PlainObject.h"
#include "vm/Shape.h"

#include "debugger/DebugAPI-inl.h"
#include "jit/BaselineFrame-inl.h"
#include "jit/JitScript-inl.h"
#include "vm/EnvironmentObject-inl.h"
Expand Down Expand Up @@ -1605,7 +1607,8 @@ ICInterpretOps(BaselineFrame* frame, VMFrameManager& frameMgr, State& state,
return ICInterpretOpResult::NextIC;
}
Value val = Value::fromRawBits(icregs.icVals[valId.id()]);
slot->set(nobj, HeapSlot::Element, index, val);
slot->set(nobj, HeapSlot::Element, index + elems->numShiftedElements(),
val);
PREDICT_NEXT(ReturnFromIC);
DISPATCH_CACHEOP();
}
Expand Down Expand Up @@ -3377,6 +3380,9 @@ static PBIResult PortableBaselineInterpret(JSContext* cx_, State& state,
{
PUSH_EXIT_FRAME();
obj = ObjectWithProtoOperation(cx, value0);
if (!obj) {
goto error;
}
}
sp[0] = StackVal(ObjectValue(*obj));
}
Expand Down Expand Up @@ -4489,7 +4495,8 @@ static PBIResult PortableBaselineInterpret(JSContext* cx_, State& state,
if (script->isDebuggee()) {
TRACE_PRINTF("doing DebugAfterYield\n");
PUSH_EXIT_FRAME();
if (!HandleDebugTrap(cx, frame, pc)) {
if (DebugAPI::hasAnyBreakpointsOrStepMode(script) &&
!HandleDebugTrap(cx, frame, pc)) {
TRACE_PRINTF("HandleDebugTrap returned error\n");
goto error;
}
Expand Down Expand Up @@ -5289,11 +5296,13 @@ static PBIResult PortableBaselineInterpret(JSContext* cx_, State& state,
debug : {
TRACE_PRINTF("hit debug point\n");
PUSH_EXIT_FRAME();
if (!HandleDebugTrap(cx, frame, pc)) {
TRACE_PRINTF("HandleDebugTrap returned error\n");
goto error;
if (DebugAPI::hasAnyBreakpointsOrStepMode(script)) {
if (!HandleDebugTrap(cx, frame, pc)) {
TRACE_PRINTF("HandleDebugTrap returned error\n");
goto error;
}
pc = frame->interpreterPC();
}
pc = frame->interpreterPC();
TRACE_PRINTF("HandleDebugTrap done\n");
}
goto dispatch;
Expand Down

0 comments on commit 05045b6

Please sign in to comment.