зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1658786
- Move KnownClass analysis to a new file. r=jandem
Differential Revision: https://phabricator.services.mozilla.com/D86842
This commit is contained in:
Родитель
08158e2184
Коммит
f1934bf4d4
|
@ -5136,77 +5136,6 @@ bool jit::MakeLoopsContiguous(MIRGraph& graph) {
|
|||
return true;
|
||||
}
|
||||
|
||||
KnownClass jit::GetObjectKnownClass(const MDefinition* def) {
|
||||
MOZ_ASSERT(def->type() == MIRType::Object);
|
||||
|
||||
switch (def->op()) {
|
||||
case MDefinition::Opcode::NewArray:
|
||||
case MDefinition::Opcode::NewArrayCopyOnWrite:
|
||||
return KnownClass::Array;
|
||||
|
||||
case MDefinition::Opcode::NewObject:
|
||||
case MDefinition::Opcode::CreateThis:
|
||||
case MDefinition::Opcode::CreateThisWithTemplate:
|
||||
return KnownClass::PlainObject;
|
||||
|
||||
case MDefinition::Opcode::Lambda:
|
||||
case MDefinition::Opcode::LambdaArrow:
|
||||
case MDefinition::Opcode::FunctionWithProto:
|
||||
return KnownClass::Function;
|
||||
|
||||
case MDefinition::Opcode::RegExp:
|
||||
return KnownClass::RegExp;
|
||||
|
||||
case MDefinition::Opcode::Phi: {
|
||||
if (def->numOperands() == 0) {
|
||||
return KnownClass::None;
|
||||
}
|
||||
|
||||
MDefinition* op = def->getOperand(0);
|
||||
// Check for Phis to avoid recursion for now.
|
||||
if (op->isPhi()) {
|
||||
return KnownClass::None;
|
||||
}
|
||||
|
||||
KnownClass known = GetObjectKnownClass(op);
|
||||
if (known == KnownClass::None) {
|
||||
return KnownClass::None;
|
||||
}
|
||||
|
||||
for (size_t i = 1; i < def->numOperands(); i++) {
|
||||
op = def->getOperand(i);
|
||||
if (op->isPhi() || GetObjectKnownClass(op) != known) {
|
||||
return KnownClass::None;
|
||||
}
|
||||
}
|
||||
|
||||
return known;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return KnownClass::None;
|
||||
}
|
||||
|
||||
const JSClass* jit::GetObjectKnownJSClass(const MDefinition* def) {
|
||||
switch (GetObjectKnownClass(def)) {
|
||||
case KnownClass::PlainObject:
|
||||
return &PlainObject::class_;
|
||||
case KnownClass::Array:
|
||||
return &ArrayObject::class_;
|
||||
case KnownClass::Function:
|
||||
return &JSFunction::class_;
|
||||
case KnownClass::RegExp:
|
||||
return &RegExpObject::class_;
|
||||
case KnownClass::None:
|
||||
break;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MRootList::MRootList(TempAllocator& alloc) {
|
||||
#define INIT_VECTOR(name, _0, _1, _2) roots_[JS::RootKind::name].emplace(alloc);
|
||||
JS_FOR_EACH_TRACEKIND(INIT_VECTOR)
|
||||
|
|
|
@ -175,10 +175,6 @@ bool DeadIfUnused(const MDefinition* def);
|
|||
|
||||
bool IsDiscardable(const MDefinition* def);
|
||||
|
||||
enum class KnownClass { PlainObject, Array, Function, RegExp, None };
|
||||
KnownClass GetObjectKnownClass(const MDefinition* def);
|
||||
const JSClass* GetObjectKnownJSClass(const MDefinition* def);
|
||||
|
||||
class CompileInfo;
|
||||
void DumpMIRExpressions(MIRGraph& graph, const CompileInfo& info,
|
||||
const char* phase);
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* vim: set ts=8 sts=2 et sw=2 tw=80:
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "jit/KnownClass.h"
|
||||
|
||||
#include "jit/MIR.h"
|
||||
#include "vm/ArrayObject.h"
|
||||
#include "vm/JSFunction.h"
|
||||
#include "vm/PlainObject.h" // js::PlainObject
|
||||
#include "vm/RegExpObject.h"
|
||||
|
||||
using namespace js;
|
||||
using namespace js::jit;
|
||||
|
||||
KnownClass jit::GetObjectKnownClass(const MDefinition* def) {
|
||||
MOZ_ASSERT(def->type() == MIRType::Object);
|
||||
|
||||
switch (def->op()) {
|
||||
case MDefinition::Opcode::NewArray:
|
||||
case MDefinition::Opcode::NewArrayCopyOnWrite:
|
||||
return KnownClass::Array;
|
||||
|
||||
case MDefinition::Opcode::NewObject:
|
||||
case MDefinition::Opcode::CreateThis:
|
||||
case MDefinition::Opcode::CreateThisWithTemplate:
|
||||
return KnownClass::PlainObject;
|
||||
|
||||
case MDefinition::Opcode::Lambda:
|
||||
case MDefinition::Opcode::LambdaArrow:
|
||||
case MDefinition::Opcode::FunctionWithProto:
|
||||
return KnownClass::Function;
|
||||
|
||||
case MDefinition::Opcode::RegExp:
|
||||
return KnownClass::RegExp;
|
||||
|
||||
case MDefinition::Opcode::Phi: {
|
||||
if (def->numOperands() == 0) {
|
||||
return KnownClass::None;
|
||||
}
|
||||
|
||||
MDefinition* op = def->getOperand(0);
|
||||
// Check for Phis to avoid recursion for now.
|
||||
if (op->isPhi()) {
|
||||
return KnownClass::None;
|
||||
}
|
||||
|
||||
KnownClass known = GetObjectKnownClass(op);
|
||||
if (known == KnownClass::None) {
|
||||
return KnownClass::None;
|
||||
}
|
||||
|
||||
for (size_t i = 1; i < def->numOperands(); i++) {
|
||||
op = def->getOperand(i);
|
||||
if (op->isPhi() || GetObjectKnownClass(op) != known) {
|
||||
return KnownClass::None;
|
||||
}
|
||||
}
|
||||
|
||||
return known;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return KnownClass::None;
|
||||
}
|
||||
|
||||
const JSClass* jit::GetObjectKnownJSClass(const MDefinition* def) {
|
||||
switch (GetObjectKnownClass(def)) {
|
||||
case KnownClass::PlainObject:
|
||||
return &PlainObject::class_;
|
||||
case KnownClass::Array:
|
||||
return &ArrayObject::class_;
|
||||
case KnownClass::Function:
|
||||
return &JSFunction::class_;
|
||||
case KnownClass::RegExp:
|
||||
return &RegExpObject::class_;
|
||||
case KnownClass::None:
|
||||
break;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* vim: set ts=8 sts=2 et sw=2 tw=80:
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef jit_KnownClass_h
|
||||
#define jit_KnownClass_h
|
||||
|
||||
#include "jspubtd.h"
|
||||
|
||||
namespace js {
|
||||
namespace jit {
|
||||
|
||||
class MDefinition;
|
||||
|
||||
enum class KnownClass { PlainObject, Array, Function, RegExp, None };
|
||||
|
||||
KnownClass GetObjectKnownClass(const MDefinition* def);
|
||||
const JSClass* GetObjectKnownJSClass(const MDefinition* def);
|
||||
|
||||
} // namespace jit
|
||||
} // namespace js
|
||||
|
||||
#endif // jit_KnownClass_h
|
|
@ -21,6 +21,7 @@
|
|||
#include "jit/BaselineInspector.h"
|
||||
#include "jit/IonBuilder.h"
|
||||
#include "jit/JitSpewer.h"
|
||||
#include "jit/KnownClass.h"
|
||||
#include "jit/MIRGraph.h"
|
||||
#include "jit/RangeAnalysis.h"
|
||||
#include "js/Conversions.h"
|
||||
|
|
|
@ -64,6 +64,7 @@ UNIFIED_SOURCES += [
|
|||
'JitSpewer.cpp',
|
||||
'JSJitFrameIter.cpp',
|
||||
'JSONSpewer.cpp',
|
||||
'KnownClass.cpp',
|
||||
'LICM.cpp',
|
||||
'Linker.cpp',
|
||||
'LIR.cpp',
|
||||
|
|
Загрузка…
Ссылка в новой задаче