Created
December 19, 2016 22:48
-
-
Save evilpie/214068dcdd841830645dc7db23857345 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# HG changeset patch | |
# Parent 77d22efb44b189d4ec0d0e25ae04195f3cbf86a9 | |
diff --git a/js/src/jit/BaselineCacheIR.cpp b/js/src/jit/BaselineCacheIR.cpp | |
--- a/js/src/jit/BaselineCacheIR.cpp | |
+++ b/js/src/jit/BaselineCacheIR.cpp | |
@@ -1854,6 +1854,15 @@ BaselineCacheIRCompiler::emitLoadProto() | |
} | |
bool | |
+BaselineCacheIRCompiler::emitLoadEnclosingEnv() | |
+{ | |
+ Register obj = allocator.useRegister(masm, reader.objOperandId()); | |
+ Register reg = allocator.defineRegister(masm, reader.objOperandId()); | |
+ masm.extractObject(Address(obj, EnvironmentObject::offsetOfEnclosingEnvironment()), reg); | |
+ return true; | |
+} | |
+ | |
+bool | |
BaselineCacheIRCompiler::emitLoadDOMExpandoValue() | |
{ | |
Register obj = allocator.useRegister(masm, reader.objOperandId()); | |
diff --git a/js/src/jit/BaselineIC.cpp b/js/src/jit/BaselineIC.cpp | |
--- a/js/src/jit/BaselineIC.cpp | |
+++ b/js/src/jit/BaselineIC.cpp | |
@@ -2719,6 +2719,14 @@ DoGetNameFallback(JSContext* cx, Baselin | |
if (attached) | |
return true; | |
+ if (!attached && !JitOptions.disableCacheIR) { | |
+ ICStubEngine engine = ICStubEngine::Baseline; | |
+ GetNameIRGenerator gen(cx, script, pc, engine, &isTemporarilyUnoptimizable, envChain, | |
+ name); | |
+ if (gen.tryAttachStub()) { | |
+ } | |
+ } | |
+ | |
if (IsGlobalOp(JSOp(*pc)) && !script->hasNonSyntacticScope()) { | |
Handle<LexicalEnvironmentObject*> globalLexical = envChain.as<LexicalEnvironmentObject>(); | |
if (!TryAttachGlobalNameValueStub(cx, script, pc, stub, globalLexical, name, &attached)) | |
diff --git a/js/src/jit/CacheIR.cpp b/js/src/jit/CacheIR.cpp | |
--- a/js/src/jit/CacheIR.cpp | |
+++ b/js/src/jit/CacheIR.cpp | |
@@ -1072,3 +1072,85 @@ GetPropIRGenerator::maybeEmitIdGuard(jsi | |
writer.guardSpecificAtom(strId, JSID_TO_ATOM(id)); | |
} | |
} | |
+ | |
+GetNameIRGenerator::GetNameIRGenerator(JSContext* cx, HandleScript script, jsbytecode* pc, | |
+ ICStubEngine engine, bool* isTemporarilyUnoptimizable, | |
+ HandleObject env, HandlePropertyName name) | |
+ : writer(cx), | |
+ cx_(cx), | |
+ script_(script), | |
+ pc_(pc), | |
+ env_(env), | |
+ name_(name), | |
+ engine_(engine), | |
+ isTemporarilyUnoptimizable_(isTemporarilyUnoptimizable) | |
+{} | |
+ | |
+bool | |
+GetNameIRGenerator::tryAttachStub() | |
+{ | |
+ AutoAssertNoPendingException aanpe(cx_); | |
+ | |
+ ObjOperandId envId = writer.loadObject(env_); | |
+ | |
+ if (tryAttachEnvironmentName(envId)) | |
+ return true; | |
+ | |
+ return false; | |
+} | |
+ | |
+bool | |
+GetNameIRGenerator::tryAttachEnvironmentName(ObjOperandId objId) | |
+{ | |
+ if (script_->hasNonSyntacticScope()) | |
+ return false; | |
+ | |
+ Rooted<ShapeVector> shapes(cx_, ShapeVector(cx_)); | |
+ RootedId id(cx_, NameToId(name_)); | |
+ RootedObject env(cx_, env_); | |
+ RootedShape shape(cx_); | |
+ while (env) { | |
+ if (!shapes.append(env->maybeShape())) | |
+ return false; | |
+ | |
+ if (env->is<GlobalObject>()) { | |
+ shape = env->as<GlobalObject>().lookup(cx_, id); | |
+ if (shape) | |
+ break; | |
+ return false; | |
+ } | |
+ | |
+ if (!env->is<EnvironmentObject>() || env->is<WithEnvironmentObject>()) | |
+ return false; | |
+ | |
+ // Check for an 'own' property on the env. There is no need to | |
+ // check the prototype as non-with scopes do not inherit properties | |
+ // from any prototype. | |
+ shape = env->as<NativeObject>().lookup(cx_, id); | |
+ if (shape) | |
+ break; | |
+ | |
+ env = env->enclosingEnvironment(); | |
+ } | |
+ | |
+ if (!IsCacheableGetPropReadSlotForIonOrCacheIR(env, env, shape)) | |
+ return false; | |
+ | |
+ for (size_t index = 0; index < shapes.length(); index++) { | |
+ writer.guardShape(objId, shapes[index]); | |
+ | |
+ if (index < (shapes.length() - 1)) | |
+ objId = writer.loadEnclosingEnv(objId); | |
+ } | |
+ | |
+ RootedNativeObject holder(cx_, &env->as<NativeObject>()); | |
+ if (holder->isFixedSlot(shape->slot())) { | |
+ // writer.loadEnvNameFixedSlotResult(objId, NativeObject::getFixedSlotOffset(shape->slot())); | |
+ } else { | |
+ size_t dynamicSlotOffset = holder->dynamicSlotIndex(shape->slot()) * sizeof(Value); | |
+ // writer.loadEnvNameDynamicSlotResult(objId, dynamicSlotOffset); | |
+ } | |
+ | |
+ writer.typeMonitorResult(); | |
+ return true; | |
+} | |
\ No newline at end of file | |
diff --git a/js/src/jit/CacheIR.h b/js/src/jit/CacheIR.h | |
--- a/js/src/jit/CacheIR.h | |
+++ b/js/src/jit/CacheIR.h | |
@@ -150,6 +150,7 @@ enum class CacheKind : uint8_t | |
_(GuardAndLoadUnboxedExpando) \ | |
_(LoadObject) \ | |
_(LoadProto) \ | |
+ _(LoadEnclosingEnv) \ | |
\ | |
_(LoadDOMExpandoValue) \ | |
_(GuardDOMExpandoObject) \ | |
@@ -173,6 +174,8 @@ enum class CacheKind : uint8_t | |
_(LoadFrameCalleeResult) \ | |
_(LoadFrameNumActualArgsResult) \ | |
_(LoadFrameArgumentResult) \ | |
+ _(LoadEnvNameFixedSlotResult) \ | |
+ _(LoadEnvNameDynamicSlotResult) \ | |
_(CallScriptedGetterResult) \ | |
_(CallNativeGetterResult) \ | |
_(CallProxyGetResult) \ | |
@@ -478,6 +481,13 @@ class MOZ_RAII CacheIRWriter : public JS | |
return res; | |
} | |
+ ObjOperandId loadEnclosingEnv(ObjOperandId obj) { | |
+ ObjOperandId res(nextOperandId_++); | |
+ writeOpWithOperandId(CacheOp::LoadEnclosingEnv, obj); | |
+ writeOperandId(res); | |
+ return res; | |
+ } | |
+ | |
ValOperandId loadDOMExpandoValue(ObjOperandId obj) { | |
ValOperandId res(nextOperandId_++); | |
writeOpWithOperandId(CacheOp::LoadDOMExpandoValue, obj); | |
@@ -725,6 +735,36 @@ class MOZ_RAII GetPropIRGenerator | |
CacheKind cacheKind() const { return cacheKind_; } | |
}; | |
+// GetPropIRGenerator generates CacheIR for a GerName IC. | |
+class MOZ_RAII GetNameIRGenerator | |
+{ | |
+ CacheIRWriter writer; | |
+ JSContext* cx_; | |
+ HandleScript script_; | |
+ jsbytecode* pc_; | |
+ HandleObject env_; | |
+ HandlePropertyName name_; | |
+ ICStubEngine engine_; | |
+ bool* isTemporarilyUnoptimizable_; | |
+ | |
+ GetNameIRGenerator(const GetNameIRGenerator&) = delete; | |
+ GetNameIRGenerator& operator=(const GetNameIRGenerator&) = delete; | |
+ | |
+ bool tryAttachEnvironmentName(ObjOperandId objId); | |
+ | |
+ public: | |
+ GetNameIRGenerator(JSContext* cx, HandleScript script, jsbytecode* pc, ICStubEngine engine, | |
+ bool* isTemporarilyUnoptimizable, | |
+ HandleObject env, HandlePropertyName name); | |
+ | |
+ bool tryAttachStub(); | |
+ | |
+ const CacheIRWriter& writerRef() const { return writer; } | |
+ // CacheKind cacheKind() const { return cacheKind_; } | |
+}; | |
+ | |
+ | |
+ | |
} // namespace jit | |
} // namespace js | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment