X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/9dae56ea45a0f5f8136a5c93d6f3a7f99399ca73..2d39b0e377c0896910ee49ae70082ba665faf986:/bytecode/StructureStubInfo.cpp diff --git a/bytecode/StructureStubInfo.cpp b/bytecode/StructureStubInfo.cpp index bf3fdc4..4615a3c 100644 --- a/bytecode/StructureStubInfo.cpp +++ b/bytecode/StructureStubInfo.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 Apple Inc. All rights reserved. + * Copyright (C) 2008, 2014 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,54 +26,85 @@ #include "config.h" #include "StructureStubInfo.h" +#include "JSObject.h" +#include "PolymorphicGetByIdList.h" +#include "PolymorphicPutByIdList.h" + namespace JSC { #if ENABLE(JIT) void StructureStubInfo::deref() { - switch (opcodeID) { - case op_get_by_id_self: - u.getByIdSelf.baseObjectStructure->deref(); - return; - case op_get_by_id_proto: - u.getByIdProto.baseObjectStructure->deref(); - u.getByIdProto.prototypeStructure->deref(); + switch (accessType) { + case access_get_by_id_list: { + delete u.getByIdList.list; return; - case op_get_by_id_chain: - u.getByIdChain.baseObjectStructure->deref(); - u.getByIdChain.chain->deref(); + } + case access_put_by_id_list: + delete u.putByIdList.list; return; - case op_get_by_id_self_list: { - PolymorphicAccessStructureList* polymorphicStructures = u.getByIdSelfList.structureList; - polymorphicStructures->derefStructures(u.getByIdSelfList.listSize); + case access_in_list: { + PolymorphicAccessStructureList* polymorphicStructures = u.inList.structureList; delete polymorphicStructures; return; } - case op_get_by_id_proto_list: { - PolymorphicAccessStructureList* polymorphicStructures = u.getByIdProtoList.structureList; - polymorphicStructures->derefStructures(u.getByIdProtoList.listSize); - delete polymorphicStructures; + case access_get_by_id_self: + 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: + // These instructions don't have to release any allocated memory return; + default: + RELEASE_ASSERT_NOT_REACHED(); + } +} + +bool StructureStubInfo::visitWeakReferences(RepatchBuffer& repatchBuffer) +{ + switch (accessType) { + case access_get_by_id_self: + if (!Heap::isMarked(u.getByIdSelf.baseObjectStructure.get())) + return false; + break; + 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_list: { + if (!u.getByIdList.list->visitWeak(repatchBuffer)) + 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 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(repatchBuffer)) + return false; + break; + case access_in_list: { + PolymorphicAccessStructureList* polymorphicStructures = u.inList.structureList; + if (!polymorphicStructures->visitWeak(u.inList.listSize)) + return false; + break; } - case op_put_by_id_transition: - u.putByIdTransition.previousStructure->deref(); - u.putByIdTransition.structure->deref(); - u.putByIdTransition.chain->deref(); - return; - case op_put_by_id_replace: - u.putByIdReplace.baseObjectStructure->deref(); - return; - case op_get_by_id: - case op_put_by_id: - case op_get_by_id_generic: - case op_put_by_id_generic: - case op_get_array_length: - case op_get_string_length: - // These instructions don't ref their Structures. - return; default: - ASSERT_NOT_REACHED(); + // The rest of the instructions don't require references, so there is no need to + // do anything. + break; } + return true; } #endif