Skip to content

Commit

Permalink
Merge r181828 - Make UnlinkedFunctionExecutable fit in a 128-byte cell.
Browse files Browse the repository at this point in the history
<https://webkit.org/b/142939>

Reviewed by Mark Hahnenberg.

Re-arrange the members of UnlinkedFunctionExecutable so it can fit inside
a 128-byte heap cell instead of requiring a 256-byte one.

Threw in a static_assert to catch anyone pushing it over the limit again.

* bytecode/UnlinkedCodeBlock.cpp:
(JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):
* bytecode/UnlinkedCodeBlock.h:
(JSC::UnlinkedFunctionExecutable::functionMode):
  • Loading branch information
Andreas Kling authored and carlosgcampos committed Mar 25, 2015
1 parent 2b52f0d commit dcda522
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
17 changes: 17 additions & 0 deletions Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,20 @@
2015-03-21 Andreas Kling <akling@apple.com>

Make UnlinkedFunctionExecutable fit in a 128-byte cell.
<https://webkit.org/b/142939>

Reviewed by Mark Hahnenberg.

Re-arrange the members of UnlinkedFunctionExecutable so it can fit inside
a 128-byte heap cell instead of requiring a 256-byte one.

Threw in a static_assert to catch anyone pushing it over the limit again.

* bytecode/UnlinkedCodeBlock.cpp:
(JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):
* bytecode/UnlinkedCodeBlock.h:
(JSC::UnlinkedFunctionExecutable::functionMode):

2015-03-20 Yusuke Suzuki <utatane.tea@gmail.com>

REGRESSION (r179429): Potential Use after free in JavaScriptCore`WTF::StringImpl::ref + 83
Expand Down
8 changes: 5 additions & 3 deletions Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp
Expand Up @@ -42,6 +42,8 @@

namespace JSC {

static_assert(sizeof(UnlinkedFunctionExecutable) <= 128, "UnlinkedFunctionExecutable should fit in a 128-byte cell.");

const ClassInfo UnlinkedFunctionExecutable::s_info = { "UnlinkedFunctionExecutable", 0, 0, CREATE_METHOD_TABLE(UnlinkedFunctionExecutable) };
const ClassInfo UnlinkedCodeBlock::s_info = { "UnlinkedCodeBlock", 0, 0, CREATE_METHOD_TABLE(UnlinkedCodeBlock) };
const ClassInfo UnlinkedGlobalCodeBlock::s_info = { "UnlinkedGlobalCodeBlock", &Base::s_info, 0, CREATE_METHOD_TABLE(UnlinkedGlobalCodeBlock) };
Expand Down Expand Up @@ -81,9 +83,6 @@ unsigned UnlinkedCodeBlock::addOrFindConstant(JSValue v)

UnlinkedFunctionExecutable::UnlinkedFunctionExecutable(VM* vm, Structure* structure, const SourceCode& source, FunctionBodyNode* node, UnlinkedFunctionKind kind)
: Base(*vm, structure)
, m_isInStrictContext(node->isInStrictContext())
, m_hasCapturedVariables(false)
, m_isBuiltinFunction(kind == UnlinkedBuiltinFunction)
, m_name(node->ident())
, m_inferredName(node->inferredName())
, m_parameters(node->parameters())
Expand All @@ -97,6 +96,9 @@ UnlinkedFunctionExecutable::UnlinkedFunctionExecutable(VM* vm, Structure* struct
, m_typeProfilingStartOffset(node->functionKeywordStart())
, m_typeProfilingEndOffset(node->startStartOffset() + node->source().length() - 1)
, m_features(0)
, m_isInStrictContext(node->isInStrictContext())
, m_hasCapturedVariables(false)
, m_isBuiltinFunction(kind == UnlinkedBuiltinFunction)
, m_functionMode(node->functionMode())
{
}
Expand Down
11 changes: 5 additions & 6 deletions Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h
Expand Up @@ -108,7 +108,7 @@ class UnlinkedFunctionExecutable : public JSCell {
}
size_t parameterCount() const;
bool isInStrictContext() const { return m_isInStrictContext; }
FunctionMode functionMode() const { return m_functionMode; }
FunctionMode functionMode() const { return static_cast<FunctionMode>(m_functionMode); }
JSParserStrictness toStrictness() const
{
if (m_isBuiltinFunction)
Expand Down Expand Up @@ -166,10 +166,6 @@ class UnlinkedFunctionExecutable : public JSCell {
WriteBarrier<UnlinkedFunctionCodeBlock> m_codeBlockForCall;
WriteBarrier<UnlinkedFunctionCodeBlock> m_codeBlockForConstruct;

bool m_isInStrictContext : 1;
bool m_hasCapturedVariables : 1;
bool m_isBuiltinFunction : 1;

Identifier m_name;
Identifier m_inferredName;
WriteBarrier<JSString> m_nameValue;
Expand All @@ -188,7 +184,10 @@ class UnlinkedFunctionExecutable : public JSCell {

CodeFeatures m_features;

FunctionMode m_functionMode;
unsigned m_isInStrictContext : 1;
unsigned m_hasCapturedVariables : 1;
unsigned m_isBuiltinFunction : 1;
unsigned m_functionMode : 1; // FunctionMode

protected:
void finishCreation(VM& vm)
Expand Down

0 comments on commit dcda522

Please sign in to comment.