Skip to content

Commit

Permalink
#375, #391: branch hint malloc and recursion checks, clean up MAsm ty…
Browse files Browse the repository at this point in the history
…pe barrier spooge
  • Loading branch information
classilla committed May 13, 2017
1 parent a6a0b89 commit a008a19
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
9 changes: 3 additions & 6 deletions js/src/jit/MacroAssembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -1064,26 +1064,23 @@ class MacroAssembler : public MacroAssemblerSpecific

// All barriers are off by default.
// They are enabled if necessary at the end of CodeGenerator::generate().
CodeOffset nopJump = toggledJump(&done);
CodeOffset nopJump = toggledJump(&done); // SHORT
writePrebarrierOffset(nopJump);

callPreBarrier(address, type);
jump(&done);

haltingAlign(8);
bind(&done);
}

void canonicalizeDouble(FloatRegister reg) {
Label notNaN;
branchDouble(DoubleOrdered, reg, reg, &notNaN);
branchDouble(DoubleOrdered, reg, reg, &notNaN); // SHORT
loadConstantDouble(JS::GenericNaN(), reg);
bind(&notNaN);
}

void canonicalizeFloat(FloatRegister reg) {
Label notNaN;
branchFloat(DoubleOrdered, reg, reg, &notNaN);
branchFloat(DoubleOrdered, reg, reg, &notNaN); // SHORT
loadConstantFloat32(float(JS::GenericNaN()), reg);
bind(&notNaN);
}
Expand Down
12 changes: 6 additions & 6 deletions js/src/jsfriendapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ IsObjectInContextCompartment(JSObject* obj, const JSContext* cx);
JS_FRIEND_API(bool)
RunningWithTrustedPrincipals(JSContext* cx);

inline uintptr_t
MOZ_ALWAYS_INLINE uintptr_t
GetNativeStackLimit(JSContext* cx, StackKind kind, int extraAllowance = 0)
{
PerThreadDataFriendFields* mainThread =
Expand All @@ -983,7 +983,7 @@ GetNativeStackLimit(JSContext* cx, StackKind kind, int extraAllowance = 0)
return limit;
}

inline uintptr_t
MOZ_ALWAYS_INLINE uintptr_t
GetNativeStackLimit(JSContext* cx, int extraAllowance = 0)
{
StackKind kind = RunningWithTrustedPrincipals(cx) ? StackForTrustedScript
Expand All @@ -1003,7 +1003,7 @@ GetNativeStackLimit(JSContext* cx, int extraAllowance = 0)
#define JS_CHECK_RECURSION_LIMIT(cx, limit, onerror) \
JS_BEGIN_MACRO \
int stackDummy_; \
if (!JS_CHECK_STACK_SIZE(limit, &stackDummy_)) { \
if (MOZ_UNLIKELY(!JS_CHECK_STACK_SIZE(limit, &stackDummy_))) { \
js::ReportOverRecursed(cx); \
onerror; \
} \
Expand All @@ -1015,7 +1015,7 @@ GetNativeStackLimit(JSContext* cx, int extraAllowance = 0)
#define JS_CHECK_RECURSION_LIMIT_DONT_REPORT(cx, limit, onerror) \
JS_BEGIN_MACRO \
int stackDummy_; \
if (!JS_CHECK_STACK_SIZE(limit, &stackDummy_)) { \
if (MOZ_UNLIKELY(!JS_CHECK_STACK_SIZE(limit, &stackDummy_))) { \
onerror; \
} \
JS_END_MACRO
Expand All @@ -1025,14 +1025,14 @@ GetNativeStackLimit(JSContext* cx, int extraAllowance = 0)

#define JS_CHECK_RECURSION_WITH_SP_DONT_REPORT(cx, sp, onerror) \
JS_BEGIN_MACRO \
if (!JS_CHECK_STACK_SIZE(js::GetNativeStackLimit(cx), sp)) { \
if (MOZ_UNLIKELY(!JS_CHECK_STACK_SIZE(js::GetNativeStackLimit(cx), sp))) { \
onerror; \
} \
JS_END_MACRO

#define JS_CHECK_RECURSION_WITH_SP(cx, sp, onerror) \
JS_BEGIN_MACRO \
if (!JS_CHECK_STACK_SIZE(js::GetNativeStackLimit(cx), sp)) { \
if (MOZ_UNLIKELY(!JS_CHECK_STACK_SIZE(js::GetNativeStackLimit(cx), sp))) { \
js::ReportOverRecursed(cx); \
onerror; \
} \
Expand Down

0 comments on commit a008a19

Please sign in to comment.