summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/bytecode/StructureStubInfo.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2016-04-10 09:28:39 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2016-04-10 09:28:39 +0000
commit32761a6cee1d0dee366b885b7b9c777e67885688 (patch)
treed6bec92bebfb216f4126356e55518842c2f476a1 /Source/JavaScriptCore/bytecode/StructureStubInfo.cpp
parenta4e969f4965059196ca948db781e52f7cfebf19e (diff)
downloadWebKitGtk-tarball-32761a6cee1d0dee366b885b7b9c777e67885688.tar.gz
webkitgtk-2.4.11webkitgtk-2.4.11
Diffstat (limited to 'Source/JavaScriptCore/bytecode/StructureStubInfo.cpp')
-rw-r--r--Source/JavaScriptCore/bytecode/StructureStubInfo.cpp218
1 files changed, 78 insertions, 140 deletions
diff --git a/Source/JavaScriptCore/bytecode/StructureStubInfo.cpp b/Source/JavaScriptCore/bytecode/StructureStubInfo.cpp
index ccd42dadc..91413dfbf 100644
--- a/Source/JavaScriptCore/bytecode/StructureStubInfo.cpp
+++ b/Source/JavaScriptCore/bytecode/StructureStubInfo.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008, 2014, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,169 +27,107 @@
#include "StructureStubInfo.h"
#include "JSObject.h"
-#include "PolymorphicAccess.h"
-#include "Repatch.h"
+#include "PolymorphicPutByIdList.h"
+
namespace JSC {
#if ENABLE(JIT)
-StructureStubInfo::StructureStubInfo(AccessType accessType)
- : callSiteIndex(UINT_MAX)
- , accessType(accessType)
- , cacheType(CacheType::Unset)
- , countdown(1) // For a totally clear stub, we'll patch it after the first execution.
- , repatchCount(0)
- , numberOfCoolDowns(0)
- , resetByGC(false)
- , tookSlowPath(false)
- , everConsidered(false)
-{
-}
-
-StructureStubInfo::~StructureStubInfo()
-{
-}
-
-void StructureStubInfo::initGetByIdSelf(CodeBlock* codeBlock, Structure* baseObjectStructure, PropertyOffset offset)
-{
- cacheType = CacheType::GetByIdSelf;
-
- u.byIdSelf.baseObjectStructure.set(
- *codeBlock->vm(), codeBlock, baseObjectStructure);
- u.byIdSelf.offset = offset;
-}
-
-void StructureStubInfo::initPutByIdReplace(CodeBlock* codeBlock, Structure* baseObjectStructure, PropertyOffset offset)
-{
- cacheType = CacheType::PutByIdReplace;
-
- u.byIdSelf.baseObjectStructure.set(
- *codeBlock->vm(), codeBlock, baseObjectStructure);
- u.byIdSelf.offset = offset;
-}
-
-void StructureStubInfo::initStub(CodeBlock*, std::unique_ptr<PolymorphicAccess> stub)
-{
- cacheType = CacheType::Stub;
- u.stub = stub.release();
-}
-
void StructureStubInfo::deref()
{
- switch (cacheType) {
- case CacheType::Stub:
- delete u.stub;
+ switch (accessType) {
+ case access_get_by_id_self_list: {
+ PolymorphicAccessStructureList* polymorphicStructures = u.getByIdSelfList.structureList;
+ delete polymorphicStructures;
return;
- case CacheType::Unset:
- case CacheType::GetByIdSelf:
- case CacheType::PutByIdReplace:
+ }
+ case access_get_by_id_proto_list: {
+ PolymorphicAccessStructureList* polymorphicStructures = u.getByIdProtoList.structureList;
+ delete polymorphicStructures;
return;
}
-
- RELEASE_ASSERT_NOT_REACHED();
-}
-
-void StructureStubInfo::aboutToDie()
-{
- switch (cacheType) {
- case CacheType::Stub:
- u.stub->aboutToDie();
+ case access_put_by_id_list:
+ delete u.putByIdList.list;
return;
- case CacheType::Unset:
- case CacheType::GetByIdSelf:
- case CacheType::PutByIdReplace:
+ case access_in_list: {
+ PolymorphicAccessStructureList* polymorphicStructures = u.inList.structureList;
+ delete polymorphicStructures;
return;
}
-
- RELEASE_ASSERT_NOT_REACHED();
-}
-
-MacroAssemblerCodePtr StructureStubInfo::addAccessCase(
- CodeBlock* codeBlock, const Identifier& ident, std::unique_ptr<AccessCase> accessCase)
-{
- VM& vm = *codeBlock->vm();
-
- if (!accessCase)
- return MacroAssemblerCodePtr();
-
- if (cacheType == CacheType::Stub)
- return u.stub->regenerateWithCase(vm, codeBlock, *this, ident, WTFMove(accessCase));
-
- std::unique_ptr<PolymorphicAccess> access = std::make_unique<PolymorphicAccess>();
-
- Vector<std::unique_ptr<AccessCase>> accessCases;
-
- std::unique_ptr<AccessCase> previousCase =
- AccessCase::fromStructureStubInfo(vm, codeBlock, *this);
- if (previousCase)
- accessCases.append(WTFMove(previousCase));
-
- accessCases.append(WTFMove(accessCase));
-
- MacroAssemblerCodePtr result =
- access->regenerateWithCases(vm, codeBlock, *this, ident, WTFMove(accessCases));
-
- if (!result)
- return MacroAssemblerCodePtr();
-
- initStub(codeBlock, WTFMove(access));
- return result;
-}
-
-void StructureStubInfo::reset(CodeBlock* codeBlock)
-{
- if (cacheType == CacheType::Unset)
+ case access_get_by_id_self:
+ case access_get_by_id_proto:
+ case access_get_by_id_chain:
+ case access_put_by_id_transition_normal:
+ case access_put_by_id_transition_direct:
+ case access_put_by_id_replace:
+ case access_unset:
+ case access_get_by_id_generic:
+ case access_put_by_id_generic:
+ case access_get_array_length:
+ case access_get_string_length:
+ // These instructions don't have to release any allocated memory
return;
-
- if (Options::verboseOSR()) {
- // This can be called from GC destructor calls, so we don't try to do a full dump
- // of the CodeBlock.
- dataLog("Clearing structure cache (kind ", static_cast<int>(accessType), ") in ", RawPointer(codeBlock), ".\n");
+ default:
+ RELEASE_ASSERT_NOT_REACHED();
}
+}
+bool StructureStubInfo::visitWeakReferences()
+{
switch (accessType) {
- case AccessType::Get:
- resetGetByID(codeBlock, *this);
+ case access_get_by_id_self:
+ if (!Heap::isMarked(u.getByIdSelf.baseObjectStructure.get()))
+ return false;
break;
- case AccessType::Put:
- resetPutByID(codeBlock, *this);
+ case access_get_by_id_proto:
+ if (!Heap::isMarked(u.getByIdProto.baseObjectStructure.get())
+ || !Heap::isMarked(u.getByIdProto.prototypeStructure.get()))
+ return false;
break;
- case AccessType::In:
- resetIn(codeBlock, *this);
+ case access_get_by_id_chain:
+ if (!Heap::isMarked(u.getByIdChain.baseObjectStructure.get())
+ || !Heap::isMarked(u.getByIdChain.chain.get()))
+ return false;
+ break;
+ case access_get_by_id_self_list: {
+ PolymorphicAccessStructureList* polymorphicStructures = u.getByIdSelfList.structureList;
+ if (!polymorphicStructures->visitWeak(u.getByIdSelfList.listSize))
+ return false;
break;
}
-
- deref();
- cacheType = CacheType::Unset;
-}
-
-void StructureStubInfo::visitWeakReferences(CodeBlock* codeBlock)
-{
- VM& vm = *codeBlock->vm();
-
- switch (cacheType) {
- case CacheType::GetByIdSelf:
- case CacheType::PutByIdReplace:
- if (Heap::isMarked(u.byIdSelf.baseObjectStructure.get()))
- return;
+ case access_get_by_id_proto_list: {
+ PolymorphicAccessStructureList* polymorphicStructures = u.getByIdProtoList.structureList;
+ if (!polymorphicStructures->visitWeak(u.getByIdProtoList.listSize))
+ return false;
+ break;
+ }
+ case access_put_by_id_transition_normal:
+ case access_put_by_id_transition_direct:
+ if (!Heap::isMarked(u.putByIdTransition.previousStructure.get())
+ || !Heap::isMarked(u.putByIdTransition.structure.get())
+ || !Heap::isMarked(u.putByIdTransition.chain.get()))
+ return false;
break;
- case CacheType::Stub:
- if (u.stub->visitWeak(vm))
- return;
+ case access_put_by_id_replace:
+ if (!Heap::isMarked(u.putByIdReplace.baseObjectStructure.get()))
+ return false;
break;
+ case access_put_by_id_list:
+ if (!u.putByIdList.list->visitWeak())
+ return false;
+ break;
+ case access_in_list: {
+ PolymorphicAccessStructureList* polymorphicStructures = u.inList.structureList;
+ if (!polymorphicStructures->visitWeak(u.inList.listSize))
+ return false;
+ break;
+ }
default:
- return;
+ // The rest of the instructions don't require references, so there is no need to
+ // do anything.
+ break;
}
-
- reset(codeBlock);
- resetByGC = true;
-}
-
-bool StructureStubInfo::containsPC(void* pc) const
-{
- if (cacheType != CacheType::Stub)
- return false;
- return u.stub->containsPC(pc);
+ return true;
}
#endif