Skip to content

Commit 491e7db

Browse files
author
Mark Lam
committed
Refactor LLInt::Data::performAssertions() into assertInvariants().
https://bugs.webkit.org/show_bug.cgi?id=274723 rdar://128746336 Reviewed by Yusuke Suzuki. The intent of LLInt::Data::performAssertions() was to assert some invariants that cannot be expressed as static_asserts, or did not have a convenient place to express the static_asserts because they are about constants used in the LLInt asm files. These asserts need only be executed once. At the time, I added a call to performAssertions() from the VM constructor. The better place to call it would be from JSC::initialize(), which is only executed once per process. Additionally, over time, we started using this function to assert other invariants. Hence, we should rename it and put it in a place not associated with the LLInt specifically. Lastly, replace all uses of the antiquated STATIC_ASSERT macro with static_assert. * Source/JavaScriptCore/CMakeLists.txt: * Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj: * Source/JavaScriptCore/Sources.txt: * Source/JavaScriptCore/interpreter/CallFrame.h: (JSC::CallFrame::argumentOffset): (JSC::CallFrame::argumentOffsetIncludingThis): * Source/JavaScriptCore/llint/LLIntData.cpp: (JSC::LLInt::Data::performAssertions): Deleted. * Source/JavaScriptCore/llint/LLIntData.h: * Source/JavaScriptCore/runtime/AssertInvariants.cpp: Added. (JSC::assertInvariants): * Source/JavaScriptCore/runtime/AssertInvariants.h: Added. * Source/JavaScriptCore/runtime/InitializeThreading.cpp: (JSC::initialize): * Source/JavaScriptCore/runtime/VM.cpp: (JSC::VM::VM): Canonical link: https://commits.webkit.org/279327@main
1 parent 989daa9 commit 491e7db

10 files changed

Lines changed: 201 additions & 133 deletions

File tree

‎Source/JavaScriptCore/CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,7 @@ set(JavaScriptCore_PRIVATE_FRAMEWORK_HEADERS
932932
runtime/ArrayPrototype.h
933933
runtime/ArrayStorage.h
934934
runtime/ArrayStorageInlines.h
935+
runtime/AssertInvariants.h
935936
runtime/AsyncIteratorPrototype.h
936937
runtime/AuxiliaryBarrier.h
937938
runtime/AuxiliaryBarrierInlines.h

‎Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2109,6 +2109,7 @@
21092109
FE1E2C3F2240DD5800F6B729 /* MacroAssemblerARM64E.h in Headers */ = {isa = PBXBuildFile; fileRef = FE1E2C3E2240D30B00F6B729 /* MacroAssemblerARM64E.h */; settings = {ATTRIBUTES = (Private, ); }; };
21102110
FE1E2C402240DD6200F6B729 /* ARM64EAssembler.h in Headers */ = {isa = PBXBuildFile; fileRef = FE1E2C3D2240D2F600F6B729 /* ARM64EAssembler.h */; settings = {ATTRIBUTES = (Private, ); }; };
21112111
FE20CE9E15F04A9500DF3430 /* LLIntCLoop.h in Headers */ = {isa = PBXBuildFile; fileRef = FE20CE9C15F04A9500DF3430 /* LLIntCLoop.h */; settings = {ATTRIBUTES = (Private, ); }; };
2112+
FE265F202C02D39100997B07 /* AssertInvariants.h in Headers */ = {isa = PBXBuildFile; fileRef = FE265F1E2C02D39100997B07 /* AssertInvariants.h */; };
21122113
FE287D02252FB2E800D723F9 /* VerifierSlotVisitor.h in Headers */ = {isa = PBXBuildFile; fileRef = FE287D01252FB2E800D723F9 /* VerifierSlotVisitor.h */; settings = {ATTRIBUTES = (Private, ); }; };
21132114
FE2A87601F02381600EB31B2 /* MinimumReservedZoneSize.h in Headers */ = {isa = PBXBuildFile; fileRef = FE2A875F1F02381600EB31B2 /* MinimumReservedZoneSize.h */; };
21142115
FE2CC9302756B2B9003F5AB8 /* HeapSubspaceTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = FE2CC92F2756B2B9003F5AB8 /* HeapSubspaceTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -5887,6 +5888,8 @@
58875888
FE1E2C3E2240D30B00F6B729 /* MacroAssemblerARM64E.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerARM64E.h; sourceTree = "<group>"; };
58885889
FE20CE9B15F04A9500DF3430 /* LLIntCLoop.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LLIntCLoop.cpp; path = llint/LLIntCLoop.cpp; sourceTree = "<group>"; };
58895890
FE20CE9C15F04A9500DF3430 /* LLIntCLoop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LLIntCLoop.h; path = llint/LLIntCLoop.h; sourceTree = "<group>"; };
5891+
FE265F1E2C02D39100997B07 /* AssertInvariants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AssertInvariants.h; sourceTree = "<group>"; };
5892+
FE265F1F2C02D39100997B07 /* AssertInvariants.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AssertInvariants.cpp; sourceTree = "<group>"; };
58905893
FE287D01252FB2E800D723F9 /* VerifierSlotVisitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VerifierSlotVisitor.h; sourceTree = "<group>"; };
58915894
FE2A875F1F02381600EB31B2 /* MinimumReservedZoneSize.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MinimumReservedZoneSize.h; sourceTree = "<group>"; };
58925895
FE2BD66E25C0DC8200999D3B /* VerifierSlotVisitor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VerifierSlotVisitor.cpp; sourceTree = "<group>"; };
@@ -7899,6 +7902,8 @@
78997902
E3443E3028E9711700C0020C /* ArrayPrototypeInlines.h */,
79007903
0FB7F38A15ED8E3800F167B2 /* ArrayStorage.h */,
79017904
FE1D6D7023625AB0007A5C26 /* ArrayStorageInlines.h */,
7905+
FE265F1F2C02D39100997B07 /* AssertInvariants.cpp */,
7906+
FE265F1E2C02D39100997B07 /* AssertInvariants.h */,
79027907
8B6016F31F3E3CC000F9DE6A /* AsyncFromSyncIteratorPrototype.cpp */,
79037908
8B6016F41F3E3CC000F9DE6A /* AsyncFromSyncIteratorPrototype.h */,
79047909
276B385A2A71D0B500252F4E /* AsyncFromSyncIteratorPrototypeInlines.h */,
@@ -10264,6 +10269,7 @@
1026410269
4BDF3004289324AC00AE1DE3 /* AssemblyComments.h in Headers */,
1026510270
0F24E54117EA9F5900ABB217 /* AssemblyHelpers.h in Headers */,
1026610271
6B767E7B26791F270017F8D1 /* AssemblyHelpersSpoolers.h in Headers */,
10272+
FE265F202C02D39100997B07 /* AssertInvariants.h in Headers */,
1026710273
A784A26111D16622005776AC /* ASTBuilder.h in Headers */,
1026810274
8B6016F61F3E3CC000F9DE6A /* AsyncFromSyncIteratorPrototype.h in Headers */,
1026910275
276B38692A71D0B600252F4E /* AsyncFromSyncIteratorPrototypeInlines.h in Headers */,

‎Source/JavaScriptCore/Sources.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,7 @@ runtime/ArrayConstructor.cpp
756756
runtime/ArrayConventions.cpp
757757
runtime/ArrayIteratorPrototype.cpp
758758
runtime/ArrayPrototype.cpp
759+
runtime/AssertInvariants.cpp
759760
runtime/AsyncFromSyncIteratorPrototype.cpp
760761
runtime/AsyncGeneratorFunctionConstructor.cpp
761762
runtime/AsyncGeneratorFunctionPrototype.cpp

‎Source/JavaScriptCore/interpreter/CallFrame.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
33
* Copyright (C) 2001 Peter Kelly (pmk@post.com)
4-
* Copyright (C) 2003-2022 Apple Inc. All rights reserved.
4+
* Copyright (C) 2003-2024 Apple Inc. All rights reserved.
55
*
66
* This library is free software; you can redistribute it and/or
77
* modify it under the terms of the GNU Library General Public
@@ -259,8 +259,8 @@ using JSInstruction = BaseInstruction<JSOpcodeTraits>;
259259
// Access to arguments as passed. (After capture, arguments may move to a different location.)
260260
size_t argumentCount() const { return argumentCountIncludingThis() - 1; }
261261
size_t argumentCountIncludingThis() const { return this[static_cast<int>(CallFrameSlot::argumentCountIncludingThis)].payload(); }
262-
static int argumentOffset(int argument) { return (CallFrameSlot::firstArgument + argument); }
263-
static int argumentOffsetIncludingThis(int argument) { return (CallFrameSlot::thisArgument + argument); }
262+
static constexpr int argumentOffset(int argument) { return (CallFrameSlot::firstArgument + argument); }
263+
static constexpr int argumentOffsetIncludingThis(int argument) { return (CallFrameSlot::thisArgument + argument); }
264264

265265
// In the following (argument() and setArgument()), the 'argument'
266266
// parameter is the index of the arguments of the target function of

‎Source/JavaScriptCore/llint/LLIntData.cpp‎

Lines changed: 1 addition & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2011-2023 Apple Inc. All rights reserved.
2+
* Copyright (C) 2011-2024 Apple Inc. All rights reserved.
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -26,20 +26,12 @@
2626
#include "config.h"
2727
#include "LLIntData.h"
2828

29-
#include "ArithProfile.h"
30-
#include "BaselineJITCode.h"
31-
#include "CodeBlock.h"
32-
#include "DFGJITCode.h"
3329
#include "JSCConfig.h"
3430
#include "LLIntCLoop.h"
3531
#include "LLIntEntrypoint.h"
36-
#include "LLIntPCRanges.h"
3732
#include "LLIntSlowPaths.h"
3833
#include "LLIntThunks.h"
3934
#include "Opcode.h"
40-
#include "WriteBarrier.h"
41-
42-
#define STATIC_ASSERT(cond) static_assert(cond, "LLInt assumes " #cond)
4335

4436
namespace JSC {
4537

@@ -266,116 +258,4 @@ void initialize()
266258
g_jscConfig.defaultCallThunk = defaultCall().code().taggedPtr();
267259
}
268260

269-
IGNORE_WARNINGS_BEGIN("missing-noreturn")
270-
void Data::performAssertions(VM& vm)
271-
{
272-
UNUSED_PARAM(vm);
273-
274-
// Assertions to match LowLevelInterpreter.asm. If you change any of this code, be
275-
// prepared to change LowLevelInterpreter.asm as well!!
276-
277-
#if USE(JSVALUE64)
278-
const ptrdiff_t CallFrameHeaderSlots = 5;
279-
#else // USE(JSVALUE64) // i.e. 32-bit version
280-
const ptrdiff_t CallFrameHeaderSlots = 4;
281-
#endif
282-
const ptrdiff_t MachineRegisterSize = sizeof(CPURegister);
283-
const ptrdiff_t SlotSize = 8;
284-
285-
STATIC_ASSERT(sizeof(Register) == SlotSize);
286-
STATIC_ASSERT(CallFrame::headerSizeInRegisters == CallFrameHeaderSlots);
287-
288-
ASSERT(!CallFrame::callerFrameOffset());
289-
STATIC_ASSERT(CallerFrameAndPC::sizeInRegisters == (MachineRegisterSize * 2) / SlotSize);
290-
static_assert(CallFrame::returnPCOffset() == CallFrame::callerFrameOffset() + MachineRegisterSize);
291-
static_assert(static_cast<std::underlying_type_t<CallFrameSlot>>(CallFrameSlot::codeBlock) * sizeof(Register) == CallFrame::returnPCOffset() + MachineRegisterSize);
292-
STATIC_ASSERT(CallFrameSlot::callee * sizeof(Register) == CallFrameSlot::codeBlock * sizeof(Register) + SlotSize);
293-
STATIC_ASSERT(CallFrameSlot::argumentCountIncludingThis * sizeof(Register) == CallFrameSlot::callee * sizeof(Register) + SlotSize);
294-
STATIC_ASSERT(CallFrameSlot::thisArgument * sizeof(Register) == CallFrameSlot::argumentCountIncludingThis * sizeof(Register) + SlotSize);
295-
STATIC_ASSERT(CallFrame::headerSizeInRegisters == CallFrameSlot::thisArgument);
296-
297-
ASSERT(CallFrame::argumentOffsetIncludingThis(0) == CallFrameSlot::thisArgument);
298-
299-
#if CPU(BIG_ENDIAN)
300-
STATIC_ASSERT(TagOffset == 0);
301-
STATIC_ASSERT(PayloadOffset == 4);
302-
#else
303-
STATIC_ASSERT(TagOffset == 4);
304-
STATIC_ASSERT(PayloadOffset == 0);
305-
#endif
306-
307-
#if ENABLE(C_LOOP)
308-
ASSERT(CodeBlock::llintBaselineCalleeSaveSpaceAsVirtualRegisters() == 1);
309-
#elif USE(JSVALUE32_64)
310-
ASSERT(CodeBlock::llintBaselineCalleeSaveSpaceAsVirtualRegisters() == 1);
311-
#elif (CPU(X86_64) && !OS(WINDOWS)) || CPU(ARM64)
312-
ASSERT(CodeBlock::llintBaselineCalleeSaveSpaceAsVirtualRegisters() == 4);
313-
#elif (CPU(X86_64) && OS(WINDOWS))
314-
ASSERT(CodeBlock::llintBaselineCalleeSaveSpaceAsVirtualRegisters() == 4);
315-
#endif
316-
317-
ASSERT(!(reinterpret_cast<ptrdiff_t>((reinterpret_cast<WriteBarrier<JSCell>*>(0x4000)->slot())) - 0x4000));
318-
319-
// FIXME: make these assertions less horrible.
320-
#if ASSERT_ENABLED
321-
Vector<int> testVector;
322-
testVector.resize(42);
323-
ASSERT(bitwise_cast<uint32_t*>(&testVector)[sizeof(void*)/sizeof(uint32_t) + 1] == 42);
324-
ASSERT(bitwise_cast<int**>(&testVector)[0] == testVector.begin());
325-
#endif
326-
327-
{
328-
UnaryArithProfile arithProfile;
329-
arithProfile.argSawInt32();
330-
ASSERT(arithProfile.bits() == UnaryArithProfile::observedIntBits());
331-
ASSERT(arithProfile.argObservedType().isOnlyInt32());
332-
}
333-
{
334-
UnaryArithProfile arithProfile;
335-
arithProfile.argSawNumber();
336-
ASSERT(arithProfile.bits() == UnaryArithProfile::observedNumberBits());
337-
ASSERT(arithProfile.argObservedType().isOnlyNumber());
338-
}
339-
340-
{
341-
BinaryArithProfile arithProfile;
342-
arithProfile.lhsSawInt32();
343-
arithProfile.rhsSawInt32();
344-
ASSERT(arithProfile.bits() == BinaryArithProfile::observedIntIntBits());
345-
ASSERT(arithProfile.lhsObservedType().isOnlyInt32());
346-
ASSERT(arithProfile.rhsObservedType().isOnlyInt32());
347-
}
348-
{
349-
BinaryArithProfile arithProfile;
350-
arithProfile.lhsSawNumber();
351-
arithProfile.rhsSawInt32();
352-
ASSERT(arithProfile.bits() == BinaryArithProfile::observedNumberIntBits());
353-
ASSERT(arithProfile.lhsObservedType().isOnlyNumber());
354-
ASSERT(arithProfile.rhsObservedType().isOnlyInt32());
355-
}
356-
{
357-
BinaryArithProfile arithProfile;
358-
arithProfile.lhsSawNumber();
359-
arithProfile.rhsSawNumber();
360-
ASSERT(arithProfile.bits() == BinaryArithProfile::observedNumberNumberBits());
361-
ASSERT(arithProfile.lhsObservedType().isOnlyNumber());
362-
ASSERT(arithProfile.rhsObservedType().isOnlyNumber());
363-
}
364-
{
365-
BinaryArithProfile arithProfile;
366-
arithProfile.lhsSawInt32();
367-
arithProfile.rhsSawNumber();
368-
ASSERT(arithProfile.bits() == BinaryArithProfile::observedIntNumberBits());
369-
ASSERT(arithProfile.lhsObservedType().isOnlyInt32());
370-
ASSERT(arithProfile.rhsObservedType().isOnlyNumber());
371-
}
372-
373-
#if ENABLE(DFG_JIT)
374-
// We share the same layout for particular fields in all JITData to make our data IC assume this.
375-
RELEASE_ASSERT(BaselineJITData::offsetOfGlobalObject() == DFG::JITData::offsetOfGlobalObject());
376-
RELEASE_ASSERT(BaselineJITData::offsetOfStackOffset() == DFG::JITData::offsetOfStackOffset());
377-
#endif
378-
}
379-
IGNORE_WARNINGS_END
380-
381261
} } // namespace JSC::LLInt

‎Source/JavaScriptCore/llint/LLIntData.h‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2011-2021 Apple Inc. All rights reserved.
2+
* Copyright (C) 2011-2024 Apple Inc. All rights reserved.
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -48,11 +48,6 @@ extern "C" JS_EXPORT_PRIVATE JSC::Opcode g_opcodeMapWide16[numOpcodeIDs + numWas
4848
extern "C" JS_EXPORT_PRIVATE JSC::Opcode g_opcodeMapWide32[numOpcodeIDs + numWasmOpcodeIDs];
4949

5050
class Data {
51-
52-
public:
53-
static void performAssertions(VM&);
54-
55-
private:
5651
friend void initialize();
5752

5853
friend JSInstruction* exceptionInstructions();
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
/*
2+
* Copyright (C) 2024 Apple Inc. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
* 1. Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* 2. Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
*
13+
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21+
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
26+
#include "config.h"
27+
#include "AssertInvariants.h"
28+
29+
#include "ArithProfile.h"
30+
#include "BaselineJITCode.h"
31+
#include "CodeBlock.h"
32+
#include "DFGJITCode.h"
33+
34+
namespace JSC {
35+
36+
void assertInvariants()
37+
{
38+
// Assertions to match LowLevelInterpreter.asm. If you change any of this code, be
39+
// prepared to change LowLevelInterpreter.asm as well!!
40+
{
41+
#if USE(JSVALUE64)
42+
const ptrdiff_t CallFrameHeaderSlots = 5;
43+
#else // USE(JSVALUE64) // i.e. 32-bit version
44+
const ptrdiff_t CallFrameHeaderSlots = 4;
45+
#endif
46+
const ptrdiff_t MachineRegisterSize = sizeof(CPURegister);
47+
const ptrdiff_t SlotSize = 8;
48+
49+
static_assert(sizeof(Register) == SlotSize);
50+
static_assert(CallFrame::headerSizeInRegisters == CallFrameHeaderSlots);
51+
52+
static_assert(!CallFrame::callerFrameOffset());
53+
static_assert(CallerFrameAndPC::sizeInRegisters == (MachineRegisterSize * 2) / SlotSize);
54+
static_assert(CallFrame::returnPCOffset() == CallFrame::callerFrameOffset() + MachineRegisterSize);
55+
static_assert(static_cast<std::underlying_type_t<CallFrameSlot>>(CallFrameSlot::codeBlock) * sizeof(Register) == CallFrame::returnPCOffset() + MachineRegisterSize);
56+
static_assert(CallFrameSlot::callee * sizeof(Register) == CallFrameSlot::codeBlock * sizeof(Register) + SlotSize);
57+
static_assert(CallFrameSlot::argumentCountIncludingThis * sizeof(Register) == CallFrameSlot::callee * sizeof(Register) + SlotSize);
58+
static_assert(CallFrameSlot::thisArgument * sizeof(Register) == CallFrameSlot::argumentCountIncludingThis * sizeof(Register) + SlotSize);
59+
static_assert(CallFrame::headerSizeInRegisters == CallFrameSlot::thisArgument);
60+
61+
static_assert(CallFrame::argumentOffsetIncludingThis(0) == CallFrameSlot::thisArgument);
62+
63+
#if CPU(BIG_ENDIAN)
64+
static_assert(TagOffset == 0);
65+
static_assert(PayloadOffset == 4);
66+
#else
67+
static_assert(TagOffset == 4);
68+
static_assert(PayloadOffset == 0);
69+
#endif
70+
71+
#if ENABLE(C_LOOP)
72+
ASSERT(CodeBlock::llintBaselineCalleeSaveSpaceAsVirtualRegisters() == 1);
73+
#elif USE(JSVALUE32_64)
74+
ASSERT(CodeBlock::llintBaselineCalleeSaveSpaceAsVirtualRegisters() == 1);
75+
#elif (CPU(X86_64) && !OS(WINDOWS)) || CPU(ARM64)
76+
ASSERT(CodeBlock::llintBaselineCalleeSaveSpaceAsVirtualRegisters() == 4);
77+
#elif (CPU(X86_64) && OS(WINDOWS))
78+
ASSERT(CodeBlock::llintBaselineCalleeSaveSpaceAsVirtualRegisters() == 4);
79+
#endif
80+
81+
ASSERT(!(reinterpret_cast<ptrdiff_t>((reinterpret_cast<WriteBarrier<JSCell>*>(0x4000)->slot())) - 0x4000));
82+
}
83+
84+
// FIXME: make these assertions less horrible.
85+
#if ASSERT_ENABLED
86+
Vector<int> testVector;
87+
testVector.resize(42);
88+
ASSERT(bitwise_cast<uint32_t*>(&testVector)[sizeof(void*) / sizeof(uint32_t) + 1] == 42);
89+
ASSERT(bitwise_cast<int**>(&testVector)[0] == testVector.begin());
90+
#endif
91+
92+
{
93+
UnaryArithProfile arithProfile;
94+
arithProfile.argSawInt32();
95+
ASSERT(arithProfile.bits() == UnaryArithProfile::observedIntBits());
96+
ASSERT(arithProfile.argObservedType().isOnlyInt32());
97+
}
98+
{
99+
UnaryArithProfile arithProfile;
100+
arithProfile.argSawNumber();
101+
ASSERT(arithProfile.bits() == UnaryArithProfile::observedNumberBits());
102+
ASSERT(arithProfile.argObservedType().isOnlyNumber());
103+
}
104+
105+
{
106+
BinaryArithProfile arithProfile;
107+
arithProfile.lhsSawInt32();
108+
arithProfile.rhsSawInt32();
109+
ASSERT(arithProfile.bits() == BinaryArithProfile::observedIntIntBits());
110+
ASSERT(arithProfile.lhsObservedType().isOnlyInt32());
111+
ASSERT(arithProfile.rhsObservedType().isOnlyInt32());
112+
}
113+
{
114+
BinaryArithProfile arithProfile;
115+
arithProfile.lhsSawNumber();
116+
arithProfile.rhsSawInt32();
117+
ASSERT(arithProfile.bits() == BinaryArithProfile::observedNumberIntBits());
118+
ASSERT(arithProfile.lhsObservedType().isOnlyNumber());
119+
ASSERT(arithProfile.rhsObservedType().isOnlyInt32());
120+
}
121+
{
122+
BinaryArithProfile arithProfile;
123+
arithProfile.lhsSawNumber();
124+
arithProfile.rhsSawNumber();
125+
ASSERT(arithProfile.bits() == BinaryArithProfile::observedNumberNumberBits());
126+
ASSERT(arithProfile.lhsObservedType().isOnlyNumber());
127+
ASSERT(arithProfile.rhsObservedType().isOnlyNumber());
128+
}
129+
{
130+
BinaryArithProfile arithProfile;
131+
arithProfile.lhsSawInt32();
132+
arithProfile.rhsSawNumber();
133+
ASSERT(arithProfile.bits() == BinaryArithProfile::observedIntNumberBits());
134+
ASSERT(arithProfile.lhsObservedType().isOnlyInt32());
135+
ASSERT(arithProfile.rhsObservedType().isOnlyNumber());
136+
}
137+
138+
#if ENABLE(DFG_JIT)
139+
// We share the same layout for particular fields in all JITData to make our data IC assume this.
140+
static_assert(BaselineJITData::offsetOfGlobalObject() == DFG::JITData::offsetOfGlobalObject());
141+
static_assert(BaselineJITData::offsetOfStackOffset() == DFG::JITData::offsetOfStackOffset());
142+
#endif
143+
}
144+
145+
} // namespace JSC

0 commit comments

Comments
 (0)