Changeset 229481 in webkit


Ignore:
Timestamp:
Mar 9, 2018 1:35:17 PM (6 years ago)
Author:
mark.lam@apple.com
Message:

[Re-landing] Prepare LLInt code to support pointer profiling.
https://bugs.webkit.org/show_bug.cgi?id=183387
<rdar://problem/38199678>

Reviewed by JF Bastien.

Source/JavaScriptCore:

  1. Introduced PtrTag enums for supporting pointer profiling later.
  1. Also introduced tagging, untagging, retagging, and tag removal placeholder template functions for the same purpose.
  1. Prepare the offlineasm for supporting pointer profiling later.
  1. Tagged some pointers in LLInt asm code. Currently, these should have no effect on behavior.
  1. Removed returnToThrowForThrownException() because it is not used anywhere.
  1. Added the offlineasm folder to JavaScriptCore Xcode project so that it's easier to view and edit these files in Xcode.
  • CMakeLists.txt:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • bytecode/LLIntCallLinkInfo.h:

(JSC::LLIntCallLinkInfo::unlink):

  • llint/LLIntData.cpp:

(JSC::LLInt::initialize):

  • llint/LLIntData.h:
  • llint/LLIntExceptions.cpp:

(JSC::LLInt::returnToThrowForThrownException): Deleted.

  • llint/LLIntExceptions.h:
  • llint/LLIntOfflineAsmConfig.h:
  • llint/LLIntOffsetsExtractor.cpp:
  • llint/LLIntPCRanges.h:

(JSC::LLInt::isLLIntPC):

  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::LLINT_SLOW_PATH_DECL):
(JSC::LLInt::handleHostCall):
(JSC::LLInt::setUpCall):

  • llint/LowLevelInterpreter.asm:
  • llint/LowLevelInterpreter32_64.asm:
  • llint/LowLevelInterpreter64.asm:
  • offlineasm/ast.rb:
  • offlineasm/instructions.rb:
  • offlineasm/risc.rb:
  • runtime/PtrTag.h: Added.

(JSC::uniquePtrTagID):
(JSC::ptrTag):
(JSC::tagCodePtr):
(JSC::untagCodePtr):
(JSC::retagCodePtr):
(JSC::removeCodePtrTag):

Source/WTF:

  • wtf/Platform.h:
Location:
trunk/Source
Files:
1 added
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/CMakeLists.txt

    r229447 r229481  
    839839    runtime/Options.h
    840840    runtime/ParseInt.h
     841    runtime/PtrTag.h
    841842    runtime/PrivateName.h
    842843    runtime/ProgramExecutable.h
  • trunk/Source/JavaScriptCore/ChangeLog

    r229478 r229481  
     12018-03-09  Mark Lam  <mark.lam@apple.com>
     2
     3        [Re-landing] Prepare LLInt code to support pointer profiling.
     4        https://bugs.webkit.org/show_bug.cgi?id=183387
     5        <rdar://problem/38199678>
     6
     7        Reviewed by JF Bastien.
     8
     9        1. Introduced PtrTag enums for supporting pointer profiling later.
     10
     11        2. Also introduced tagging, untagging, retagging, and tag removal placeholder
     12           template functions for the same purpose.
     13
     14        3. Prepare the offlineasm for supporting pointer profiling later.
     15
     16        4. Tagged some pointers in LLInt asm code.  Currently, these should have no
     17           effect on behavior.
     18
     19        5. Removed returnToThrowForThrownException() because it is not used anywhere.
     20
     21        6. Added the offlineasm folder to JavaScriptCore Xcode project so that it's
     22           easier to view and edit these files in Xcode.
     23
     24        * CMakeLists.txt:
     25        * JavaScriptCore.xcodeproj/project.pbxproj:
     26        * bytecode/LLIntCallLinkInfo.h:
     27        (JSC::LLIntCallLinkInfo::unlink):
     28        * llint/LLIntData.cpp:
     29        (JSC::LLInt::initialize):
     30        * llint/LLIntData.h:
     31        * llint/LLIntExceptions.cpp:
     32        (JSC::LLInt::returnToThrowForThrownException): Deleted.
     33        * llint/LLIntExceptions.h:
     34        * llint/LLIntOfflineAsmConfig.h:
     35        * llint/LLIntOffsetsExtractor.cpp:
     36        * llint/LLIntPCRanges.h:
     37        (JSC::LLInt::isLLIntPC):
     38        * llint/LLIntSlowPaths.cpp:
     39        (JSC::LLInt::LLINT_SLOW_PATH_DECL):
     40        (JSC::LLInt::handleHostCall):
     41        (JSC::LLInt::setUpCall):
     42        * llint/LowLevelInterpreter.asm:
     43        * llint/LowLevelInterpreter32_64.asm:
     44        * llint/LowLevelInterpreter64.asm:
     45        * offlineasm/ast.rb:
     46        * offlineasm/instructions.rb:
     47        * offlineasm/risc.rb:
     48        * runtime/PtrTag.h: Added.
     49        (JSC::uniquePtrTagID):
     50        (JSC::ptrTag):
     51        (JSC::tagCodePtr):
     52        (JSC::untagCodePtr):
     53        (JSC::retagCodePtr):
     54        (JSC::removeCodePtrTag):
     55
    1562018-03-09  Mark Lam  <mark.lam@apple.com>
    257
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r229447 r229481  
    17681768                FE6491371D78F01D00A694D4 /* ExceptionScope.h in Headers */ = {isa = PBXBuildFile; fileRef = FE6491361D78F01300A694D4 /* ExceptionScope.h */; settings = {ATTRIBUTES = (Private, ); }; };
    17691769                FE68C6371B90DE040042BCB3 /* MacroAssemblerPrinter.h in Headers */ = {isa = PBXBuildFile; fileRef = FE68C6361B90DDD90042BCB3 /* MacroAssemblerPrinter.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1770                FE6C1E4A20366F0100BDC2B7 /* PtrTag.h in Headers */ = {isa = PBXBuildFile; fileRef = FE9AE1C82032C887002B6934 /* PtrTag.h */; settings = {ATTRIBUTES = (Private, ); }; };
    17701771                FE6F56DE1E64EAD600D17801 /* VMTraps.h in Headers */ = {isa = PBXBuildFile; fileRef = FE6F56DD1E64E92000D17801 /* VMTraps.h */; settings = {ATTRIBUTES = (Private, ); }; };
    17711772                FE7C41961B97FC4B00F4D598 /* PingPongStackOverflowTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEDA50D41B97F442009A3B4F /* PingPongStackOverflowTest.cpp */; };
     
    47064707                FE99B2471C24B6D300C82159 /* JITNegGenerator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JITNegGenerator.cpp; sourceTree = "<group>"; };
    47074708                FE99B2481C24B6D300C82159 /* JITNegGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITNegGenerator.h; sourceTree = "<group>"; };
     4709                FE9AE1C82032C887002B6934 /* PtrTag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PtrTag.h; sourceTree = "<group>"; };
    47084710                FEA0861E182B7A0400F6D851 /* Breakpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Breakpoint.h; sourceTree = "<group>"; };
    47094711                FEA0861F182B7A0400F6D851 /* DebuggerPrimitives.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DebuggerPrimitives.h; sourceTree = "<group>"; };
     
    47264728                FEF040501AAE662D00BD28B0 /* CompareAndSwapTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CompareAndSwapTest.cpp; path = API/tests/CompareAndSwapTest.cpp; sourceTree = "<group>"; };
    47274729                FEF040521AAEC4ED00BD28B0 /* CompareAndSwapTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CompareAndSwapTest.h; path = API/tests/CompareAndSwapTest.h; sourceTree = "<group>"; };
     4730                FEF3475220362B1B00B7C0EF /* parser.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = parser.rb; sourceTree = "<group>"; };
     4731                FEF3475320362B1B00B7C0EF /* risc.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = risc.rb; sourceTree = "<group>"; };
     4732                FEF3475420362B1B00B7C0EF /* self_hash.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = self_hash.rb; sourceTree = "<group>"; };
     4733                FEF3475520362B1C00B7C0EF /* arm.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = arm.rb; sourceTree = "<group>"; };
     4734                FEF3475620362B1C00B7C0EF /* backends.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = backends.rb; sourceTree = "<group>"; };
     4735                FEF3475720362B1D00B7C0EF /* registers.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = registers.rb; sourceTree = "<group>"; };
     4736                FEF3475820362B1D00B7C0EF /* ast.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = ast.rb; sourceTree = "<group>"; };
     4737                FEF3475920362B1D00B7C0EF /* asm.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = asm.rb; sourceTree = "<group>"; };
     4738                FEF3475A20362B1E00B7C0EF /* cloop.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = cloop.rb; sourceTree = "<group>"; };
     4739                FEF3475B20362B1E00B7C0EF /* x86.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = x86.rb; sourceTree = "<group>"; };
     4740                FEF3475C20362B1E00B7C0EF /* mips.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = mips.rb; sourceTree = "<group>"; };
     4741                FEF3475D20362B1F00B7C0EF /* config.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = config.rb; sourceTree = "<group>"; };
     4742                FEF3475E20362B1F00B7C0EF /* instructions.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = instructions.rb; sourceTree = "<group>"; };
     4743                FEF3475F20362B2000B7C0EF /* opt.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = opt.rb; sourceTree = "<group>"; };
     4744                FEF3476020362B2100B7C0EF /* transform.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = transform.rb; sourceTree = "<group>"; };
     4745                FEF3476120362B2100B7C0EF /* offsets.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = offsets.rb; sourceTree = "<group>"; };
     4746                FEF3476220362B2200B7C0EF /* arm64.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = arm64.rb; sourceTree = "<group>"; };
     4747                FEF3476320362B2300B7C0EF /* settings.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = settings.rb; sourceTree = "<group>"; };
     4748                FEF3476420362B2300B7C0EF /* generate_offset_extractor.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = generate_offset_extractor.rb; sourceTree = "<group>"; };
    47284749                FEF49AA91EB947FE00653BDB /* MultithreadedMultiVMExecutionTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MultithreadedMultiVMExecutionTest.cpp; path = API/tests/MultithreadedMultiVMExecutionTest.cpp; sourceTree = "<group>"; };
    47294750                FEF49AAA1EB947FE00653BDB /* MultithreadedMultiVMExecutionTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MultithreadedMultiVMExecutionTest.h; path = API/tests/MultithreadedMultiVMExecutionTest.h; sourceTree = "<group>"; };
     
    48814902                                1429D92C0ED22D7000B89619 /* jit */,
    48824903                                0F46809C14BA7F4D00BFE272 /* llint */,
     4904                                FEF347512036291300B7C0EF /* offlineasm */,
    48834905                                7E39D8370EC3A388003AF11A /* parser */,
    48844906                                034768DFFF38A50411DB9C8B /* Products */,
     
    68526874                                79160DBB1C8E3EC8008C085A /* ProxyRevoke.cpp */,
    68536875                                79160DBC1C8E3EC8008C085A /* ProxyRevoke.h */,
     6876                                FE9AE1C82032C887002B6934 /* PtrTag.h */,
    68546877                                0F5780A118FE1E98001E72D9 /* PureNaN.h */,
    68556878                                0F0CD4C015F1A6040032F1C0 /* PutDirectIndexMode.h */,
     
    80328055                        sourceTree = "<group>";
    80338056                };
     8057                FEF347512036291300B7C0EF /* offlineasm */ = {
     8058                        isa = PBXGroup;
     8059                        children = (
     8060                                FEF3475520362B1C00B7C0EF /* arm.rb */,
     8061                                FEF3476220362B2200B7C0EF /* arm64.rb */,
     8062                                FEF3475920362B1D00B7C0EF /* asm.rb */,
     8063                                FEF3475820362B1D00B7C0EF /* ast.rb */,
     8064                                FEF3475620362B1C00B7C0EF /* backends.rb */,
     8065                                FEF3475A20362B1E00B7C0EF /* cloop.rb */,
     8066                                FEF3475D20362B1F00B7C0EF /* config.rb */,
     8067                                FEF3476420362B2300B7C0EF /* generate_offset_extractor.rb */,
     8068                                FEF3475E20362B1F00B7C0EF /* instructions.rb */,
     8069                                FEF3475C20362B1E00B7C0EF /* mips.rb */,
     8070                                FEF3476120362B2100B7C0EF /* offsets.rb */,
     8071                                FEF3475F20362B2000B7C0EF /* opt.rb */,
     8072                                FEF3475220362B1B00B7C0EF /* parser.rb */,
     8073                                FEF3475720362B1D00B7C0EF /* registers.rb */,
     8074                                FEF3475320362B1B00B7C0EF /* risc.rb */,
     8075                                FEF3475420362B1B00B7C0EF /* self_hash.rb */,
     8076                                FEF3476320362B2300B7C0EF /* settings.rb */,
     8077                                FEF3476020362B2100B7C0EF /* transform.rb */,
     8078                                FEF3475B20362B1E00B7C0EF /* x86.rb */,
     8079                        );
     8080                        path = offlineasm;
     8081                        sourceTree = "<group>";
     8082                };
    80348083/* End PBXGroup section */
    80358084
     
    80688117                                0F2C63BC1E63440C00C13839 /* AirBlockInsertionSet.h in Headers */,
    80698118                                0FB3878E1BFBC44D00E3AB1E /* AirBlockWorklist.h in Headers */,
     8119                                FE6C1E4A20366F0100BDC2B7 /* PtrTag.h in Headers */,
    80708120                                0F79C7CA1E74C93B00EB34D1 /* AirBreakCriticalEdges.h in Headers */,
    80718121                                0F61832A1C45BF070072450B /* AirCCallingConvention.h in Headers */,
  • trunk/Source/JavaScriptCore/bytecode/LLIntCallLinkInfo.h

    r229447 r229481  
    11/*
    2  * Copyright (C) 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2828#include "JSFunction.h"
    2929#include "MacroAssemblerCodeRef.h"
     30#include "PtrTag.h"
    3031#include <wtf/SentinelLinkedList.h>
    3132
     
    5152        callee.clear();
    5253        machineCodeTarget = MacroAssemblerCodePtr();
     54        callPtrTag = NoPtrTag;
    5355        if (isOnList())
    5456            remove();
     
    5860    WriteBarrier<JSObject> lastSeenCallee;
    5961    MacroAssemblerCodePtr machineCodeTarget;
     62    PtrTag callPtrTag { NoPtrTag };
    6063};
    6164
  • trunk/Source/JavaScriptCore/llint/LLIntData.cpp

    r229478 r229481  
    5959    llint_entry(&Data::s_opcodeMap);
    6060
     61    for (int i = 0; i < NUMBER_OF_BYTECODE_IDS; ++i) {
     62        PtrTag tag = (i == op_catch) ? ExceptionHandlerPtrTag : BytecodePtrTag;
     63        Data::s_opcodeMap[i] = tagCodePtr(Data::s_opcodeMap[i], tag);
     64    }
     65
     66    if (VM::canUseJIT()) {
     67        for (int i = NUMBER_OF_BYTECODE_IDS; i < NUMBER_OF_BYTECODE_IDS + NUMBER_OF_BYTECODE_HELPER_IDS; ++i)
     68            Data::s_opcodeMap[i] = tagCodePtr(Data::s_opcodeMap[i], ptrTag(BytecodeHelperPtrTag, i));
     69    } else {
     70        static const PtrTag tagsForOpcode[] = {
     71            CodeEntryPtrTag, // llint_program_prologue
     72            CodeEntryPtrTag, // llint_eval_prologue
     73            CodeEntryPtrTag, // llint_module_program_prologue
     74            CodeEntryPtrTag, // llint_function_for_call_prologue
     75            CodeEntryPtrTag, // llint_function_for_construct_prologue
     76            CodeEntryWithArityCheckPtrTag, // llint_function_for_call_arity_check
     77            CodeEntryWithArityCheckPtrTag, // llint_function_for_construct_arity_check
     78            CodeEntryPtrTag, // llint_generic_return_point
     79            BytecodePtrTag, // llint_throw_from_slow_path_trampoline
     80            CodeEntryPtrTag, // llint_throw_during_call_trampoline
     81            NativeCodePtrTag, // llint_native_call_trampoline
     82            NativeCodePtrTag, // llint_native_construct_trampoline
     83            InternalFunctionPtrTag, // llint_internal_function_call_trampoline
     84            InternalFunctionPtrTag, // llint_internal_function_construct_trampoline
     85            ExceptionHandlerPtrTag, // handleUncaughtException
     86        };
     87
     88        static_assert(sizeof(tagsForOpcode) / sizeof(tagsForOpcode[0]) == NUMBER_OF_BYTECODE_HELPER_IDS, "");
     89        static_assert(static_cast<uintptr_t>(llint_program_prologue) == NUMBER_OF_BYTECODE_IDS, "");
     90
     91        for (int i = 0; i < NUMBER_OF_BYTECODE_HELPER_IDS; ++i) {
     92            int opcodeID = i + NUMBER_OF_BYTECODE_IDS;
     93            Data::s_opcodeMap[opcodeID] = tagCodePtr(Data::s_opcodeMap[opcodeID], tagsForOpcode[i]);
     94        }
     95    }
     96
     97    void* handler = LLInt::getCodePtr(llint_throw_from_slow_path_trampoline);
    6198    for (int i = 0; i < maxOpcodeLength + 1; ++i)
    62         Data::s_exceptionInstructions[i].u.pointer =
    63             LLInt::getCodePtr(llint_throw_from_slow_path_trampoline);
     99        Data::s_exceptionInstructions[i].u.pointer = handler;
     100
    64101#endif // ENABLE(JIT)
    65102}
  • trunk/Source/JavaScriptCore/llint/LLIntData.h

    r229478 r229481  
    2828#include "JSCJSValue.h"
    2929#include "Opcode.h"
    30 #include <wtf/PointerPreparations.h>
     30#include "PtrTag.h"
    3131
    3232namespace JSC {
  • trunk/Source/JavaScriptCore/llint/LLIntExceptions.cpp

    r229447 r229481  
    11/*
    2  * Copyright (C) 2011, 2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2011-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4040namespace JSC { namespace LLInt {
    4141
    42 Instruction* returnToThrowForThrownException(ExecState* exec)
    43 {
    44     UNUSED_PARAM(exec);
    45     return LLInt::exceptionInstructions();
    46 }
    47 
    4842Instruction* returnToThrow(ExecState* exec)
    4943{
  • trunk/Source/JavaScriptCore/llint/LLIntExceptions.h

    r229447 r229481  
    11/*
    2  * Copyright (C) 2011 Apple Inc. All rights reserved.
     2 * Copyright (C) 2011-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3535namespace LLInt {
    3636
    37 // Tells you where to jump to if you want to return-to-throw, after you've already
    38 // set up all information needed to throw the exception.
    39 Instruction* returnToThrowForThrownException(ExecState*);
    40 
    4137// Gives you a PC that you can tell the interpreter to go to, which when advanced
    4238// between 1 and 9 slots will give you an "instruction" that threads to the
  • trunk/Source/JavaScriptCore/llint/LLIntOfflineAsmConfig.h

    r229478 r229481  
    168168#endif
    169169
     170#if USE(POINTER_PROFILING)
     171#define OFFLINE_ASM_POINTER_PROFILING 1
     172#else
     173#define OFFLINE_ASM_POINTER_PROFILING 0
     174#endif
     175
    170176#define OFFLINE_ASM_GIGACAGE_ENABLED GIGACAGE_ENABLED
  • trunk/Source/JavaScriptCore/llint/LLIntOffsetsExtractor.cpp

    r229447 r229481  
    11/*
    2  * Copyright (C) 2012, 2015-2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5252#include "NativeExecutable.h"
    5353#include "ProtoCallFrame.h"
     54#include "PtrTag.h"
    5455#include "ShadowChicken.h"
    5556#include "Structure.h"
  • trunk/Source/JavaScriptCore/llint/LLIntPCRanges.h

    r229447 r229481  
    2626#pragma once
    2727
    28 #include <wtf/PointerPreparations.h>
     28#include "PtrTag.h"
    2929
    3030namespace JSC {
     
    4141{
    4242    uintptr_t pcAsInt = bitwise_cast<uintptr_t>(pc);
    43     uintptr_t llintStart = bitwise_cast<uintptr_t>(WTF_PREPARE_FUNCTION_POINTER_FOR_EXECUTION(llintPCRangeStart));
    44     uintptr_t llintEnd = bitwise_cast<uintptr_t>(WTF_PREPARE_FUNCTION_POINTER_FOR_EXECUTION(llintPCRangeEnd));
     43    uintptr_t llintStart = untagCodePtr<uintptr_t>(llintPCRangeStart, CFunctionPtrTag);
     44    uintptr_t llintEnd = untagCodePtr<uintptr_t>(llintPCRangeEnd, CFunctionPtrTag);
    4545    RELEASE_ASSERT(llintStart < llintEnd);
    4646    return llintStart <= pcAsInt && pcAsInt <= llintEnd;
  • trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp

    r229478 r229481  
    11/*
    2  * Copyright (C) 2011-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2011-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    160160    } while (false)
    161161
    162 #define LLINT_CALL_END_IMPL(exec, callTarget) LLINT_RETURN_TWO((callTarget), (exec))
     162#define LLINT_CALL_END_IMPL(exec, callTarget, callTargetTag) \
     163    LLINT_RETURN_TWO(retagCodePtr((callTarget), callTargetTag, SlowPathPtrTag), (exec))
    163164
    164165#define LLINT_CALL_THROW(exec, exceptionToThrow) do {                   \
    165166        ExecState* __ct_exec = (exec);                                  \
    166167        throwException(__ct_exec, throwScope, exceptionToThrow);        \
    167         LLINT_CALL_END_IMPL(0, callToThrow(__ct_exec));                 \
     168        LLINT_CALL_END_IMPL(0, callToThrow(__ct_exec), ExceptionHandlerPtrTag);                 \
    168169    } while (false)
    169170
     
    173174        doExceptionFuzzingIfEnabled(__cce_exec, throwScope, "LLIntSlowPaths/call", nullptr); \
    174175        if (UNLIKELY(throwScope.exception()))                           \
    175             LLINT_CALL_END_IMPL(0, callToThrow(__cce_execCallee));      \
     176            LLINT_CALL_END_IMPL(0, callToThrow(__cce_execCallee), ExceptionHandlerPtrTag); \
    176177    } while (false)
    177178
    178 #define LLINT_CALL_RETURN(exec, execCallee, callTarget) do {            \
     179#define LLINT_CALL_RETURN(exec, execCallee, callTarget, callTargetTag) do { \
    179180        ExecState* __cr_exec = (exec);                                  \
    180181        ExecState* __cr_execCallee = (execCallee);                      \
    181182        void* __cr_callTarget = (callTarget);                           \
    182183        LLINT_CALL_CHECK_EXCEPTION(__cr_exec, __cr_execCallee);         \
    183         LLINT_CALL_END_IMPL(__cr_execCallee, __cr_callTarget);          \
     184        LLINT_CALL_END_IMPL(__cr_execCallee, __cr_callTarget, callTargetTag); \
    184185    } while (false)
    185186
     
    284285    if (opcodeID == op_enter) {
    285286        dataLogF("Frame will eventually return to %p\n", exec->returnPC().value());
    286         *bitwise_cast<volatile char*>(exec->returnPC().value());
     287        *removeCodePtrTag<volatile char*>(exec->returnPC().value());
    287288    }
    288289    if (opcodeID == op_ret) {
     
    13261327           
    13271328            PoisonedMasmPtr::assertIsNotPoisoned(LLInt::getCodePtr(getHostCallReturnValue));
    1328             LLINT_CALL_RETURN(execCallee, execCallee, LLInt::getCodePtr(getHostCallReturnValue));
     1329            LLINT_CALL_RETURN(execCallee, execCallee, LLInt::getCodePtr(getHostCallReturnValue), CFunctionPtrTag);
    13291330        }
    13301331       
     
    13501351
    13511352        PoisonedMasmPtr::assertIsNotPoisoned(LLInt::getCodePtr(getHostCallReturnValue));
    1352         LLINT_CALL_RETURN(execCallee, execCallee, LLInt::getCodePtr(getHostCallReturnValue));
     1353        LLINT_CALL_RETURN(execCallee, execCallee, LLInt::getCodePtr(getHostCallReturnValue), CFunctionPtrTag);
    13531354    }
    13541355   
     
    13871388                callLinkInfo->lastSeenCallee.set(vm, callerCodeBlock, internalFunction);
    13881389                callLinkInfo->machineCodeTarget = codePtr;
     1390                callLinkInfo->callPtrTag = InternalFunctionPtrTag;
    13891391            }
    13901392
    13911393            PoisonedMasmPtr::assertIsNotPoisoned(codePtr.executableAddress());
    1392             LLINT_CALL_RETURN(exec, execCallee, codePtr.executableAddress());
     1394            LLINT_CALL_RETURN(exec, execCallee, codePtr.executableAddress(), InternalFunctionPtrTag);
    13931395        }
    13941396        throwScope.release();
     
    13991401    ExecutableBase* executable = callee->executable();
    14001402
     1403    PtrTag callPtrTag = NoPtrTag;
    14011404    MacroAssemblerCodePtr codePtr;
    14021405    CodeBlock* codeBlock = 0;
    14031406    if (executable->isHostFunction()) {
    14041407        codePtr = executable->entrypointFor(kind, MustCheckArity);
     1408        callPtrTag = NativeCodePtrTag;
    14051409    } else {
    14061410        FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable);
     
    14171421        ASSERT(codeBlock);
    14181422        ArityCheckMode arity;
    1419         if (execCallee->argumentCountIncludingThis() < static_cast<size_t>(codeBlock->numParameters()))
     1423        if (execCallee->argumentCountIncludingThis() < static_cast<size_t>(codeBlock->numParameters())) {
    14201424            arity = MustCheckArity;
    1421         else
     1425            callPtrTag = CodeEntryWithArityCheckPtrTag;
     1426        } else {
    14221427            arity = ArityCheckNotRequired;
     1428            callPtrTag = CodeEntryPtrTag;
     1429        }
    14231430        codePtr = functionExecutable->entrypointFor(kind, arity);
    14241431    }
     
    14361443        callLinkInfo->lastSeenCallee.set(vm, callerCodeBlock, callee);
    14371444        callLinkInfo->machineCodeTarget = codePtr;
     1445        RELEASE_ASSERT(callPtrTag != NoPtrTag);
     1446        callLinkInfo->callPtrTag = callPtrTag;
    14381447        if (codeBlock)
    14391448            codeBlock->linkIncomingCall(exec, callLinkInfo);
     
    14411450
    14421451    PoisonedMasmPtr::assertIsNotPoisoned(codePtr.executableAddress());
    1443     LLINT_CALL_RETURN(exec, execCallee, codePtr.executableAddress());
     1452    LLINT_CALL_RETURN(exec, execCallee, codePtr.executableAddress(), callPtrTag);
    14441453}
    14451454
     
    15811590   
    15821591    vm.hostCallReturnValue = eval(execCallee);
    1583     LLINT_CALL_RETURN(exec, execCallee, LLInt::getCodePtr(getHostCallReturnValue));
     1592    LLINT_CALL_RETURN(exec, execCallee, LLInt::getCodePtr(getHostCallReturnValue), CFunctionPtrTag);
    15841593}
    15851594
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm

    r229478 r229481  
    260260const ArithProfileNumberNumber = 0x900000
    261261const ArithProfileIntNumber = 0x500000
     262
     263# Pointer Tags
     264const BytecodePtrTag = constexpr BytecodePtrTag
     265const CodeEntryPtrTag = constexpr CodeEntryPtrTag
     266const CodeEntryWithArityCheckPtrTag = constexpr CodeEntryWithArityCheckPtrTag
     267const ExceptionHandlerPtrTag = constexpr ExceptionHandlerPtrTag
     268const InternalFunctionPtrTag = constexpr InternalFunctionPtrTag
     269const NativeCodePtrTag = constexpr NativeCodePtrTag
     270const NoPtrTag = constexpr NoPtrTag
     271const SlowPathPtrTag = constexpr SlowPathPtrTag
    262272
    263273# Some register conventions.
     
    786796
    787797macro functionPrologue()
     798    tagReturnAddress sp
    788799    if X86 or X86_WIN or X86_64 or X86_64_WIN
    789800        push cfr
     
    835846end
    836847
    837 macro callTargetFunction(callee)
     848macro callTargetFunction(callee, callPtrTag)
    838849    if C_LOOP
    839850        cloopCallJSFunction callee
    840851    else
    841         call callee
     852        call callee, callPtrTag
    842853    end
    843854    restoreStackPointerAfterCall()
     
    845856end
    846857
    847 macro prepareForRegularCall(callee, temp1, temp2, temp3)
     858macro prepareForRegularCall(callee, temp1, temp2, temp3, prepareCallPtrTag)
    848859    addp CallerFrameAndPCSize, sp
    849860end
    850861
    851862# sp points to the new frame
    852 macro prepareForTailCall(callee, temp1, temp2, temp3)
     863macro prepareForTailCall(callee, temp1, temp2, temp3, prepareCallPtrTag)
    853864    restoreCalleeSavesUsedByLLInt()
    854865
     
    885896    end
    886897
     898    if POINTER_PROFILING
     899        addp 16, cfr, temp3
     900        untagReturnAddress temp3
     901    end
     902
    887903    subp temp2, temp1
    888904    loadp [cfr], cfr
     
    894910    btinz temp2, .copyLoop
    895911
     912    prepareCallPtrTag(temp2)
    896913    move temp1, sp
    897     jmp callee
     914    jmp callee, temp2
    898915end
    899916
     
    905922            btpz calleeFramePtr, .dontUpdateSP
    906923            move calleeFramePtr, sp
    907             prepareCall(callee, t2, t3, t4)
     924            prepareCall(callee, t2, t3, t4, macro (callPtrTagReg)
     925                if POINTER_PROFILING
     926                    move SlowPathPtrTag, callPtrTagReg
     927                end
     928            end)
    908929        .dontUpdateSP:
    909             callTargetFunction(callee)
     930            callTargetFunction(callee, SlowPathPtrTag)
    910931        end)
    911932end
     
    9891010macro prologue(codeBlockGetter, codeBlockSetter, osrSlowPath, traceSlowPath)
    9901011    # Set up the call frame and check if we should OSR.
     1012    tagReturnAddress sp
    9911013    preserveCallerPCAndCFR()
    9921014
     
    10231045            pop cfr
    10241046        end
    1025         jmp r0
     1047        jmp r0, CodeEntryPtrTag
    10261048    .recover:
    10271049        codeBlockGetter(t1, t2)
     
    11411163    _vmEntryToJavaScript:
    11421164end
    1143     doVMEntry(makeJavaScriptCall)
     1165    doVMEntry(makeJavaScriptCall, CodeEntryPtrTag, CodeEntryWithArityCheckPtrTag)
    11441166
    11451167
     
    11501172    _vmEntryToNative:
    11511173end
    1152     doVMEntry(makeHostFunctionCall)
     1174    doVMEntry(makeHostFunctionCall, NativeCodePtrTag, NativeCodePtrTag)
    11531175
    11541176
     
    11571179    global _sanitizeStackForVMImpl
    11581180    _sanitizeStackForVMImpl:
     1181        tagReturnAddress sp
    11591182        # We need three non-aliased caller-save registers. We are guaranteed
    11601183        # this for a0, a1 and a2 on all architectures.
     
    11741197        addp PtrSize, address
    11751198        bpa sp, address, .zeroFillLoop
    1176    
     1199
    11771200    .zeroFillDone:
    11781201        move sp, address
     
    11831206    global _vmEntryRecord
    11841207    _vmEntryRecord:
     1208        tagReturnAddress sp
    11851209        if X86 or X86_WIN
    11861210            loadp 4[sp], a0
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm

    r229478 r229481  
    9797end
    9898
    99 macro doVMEntry(makeCall)
     99macro doVMEntry(makeCall, unused1, unused2)
    100100    functionPrologue()
    101101    pushCalleeSaves()
     
    19581958    storei CellTag, Callee + TagOffset[t3]
    19591959    move t3, sp
    1960     prepareCall(LLIntCallLinkInfo::machineCodeTarget[t1], t2, t3, t4)
    1961     callTargetFunction(LLIntCallLinkInfo::machineCodeTarget[t1])
     1960    prepareCall(LLIntCallLinkInfo::machineCodeTarget[t1], t2, t3, t4, macro (callPtrTag) end)
     1961    callTargetFunction(LLIntCallLinkInfo::machineCodeTarget[t1], NoPtrTag)
    19621962
    19631963.opCallSlow:
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm

    r229478 r229481  
    2525# Utilities.
    2626macro jumpToInstruction()
    27     jmp [PB, PC, 8]
     27    jmp [PB, PC, 8], BytecodePtrTag
    2828end
    2929
     
    9393        subp 32, sp
    9494        call function
    95         addp 32, sp 
     95        addp 32, sp
    9696    else
    9797        cCall2(function)
     
    116116end
    117117
    118 macro doVMEntry(makeCall)
     118macro doVMEntry(makeCall, callTag, callWithArityCheckTag)
    119119    functionPrologue()
    120120    pushCalleeSaves()
     
    226226    checkStackPointerAlignment(extraTempReg, 0xbad0dc02)
    227227
    228     makeCall(entry, t3)
     228    if POINTER_PROFILING
     229        btbnz ProtoCallFrame::hasArityMismatch[protoCallFrame], .doCallWithArityCheck
     230        move callTag, t2
     231        jmp .readyToCall
     232    .doCallWithArityCheck:
     233        move callWithArityCheckTag, t2
     234    .readyToCall:
     235    end
     236
     237    makeCall(entry, t3, t2)
    229238
    230239    # We may have just made a call into a JS function, so we can't rely on sp
     
    250259
    251260
    252 macro makeJavaScriptCall(entry, temp)
     261macro makeJavaScriptCall(entry, temp, callTag)
    253262    addp 16, sp
    254263    if C_LOOP
    255264        cloopCallJSFunction entry
    256265    else
    257         call entry
     266        call entry, callTag
    258267    end
    259268    subp 16, sp
     
    261270
    262271
    263 macro makeHostFunctionCall(entry, temp)
     272macro makeHostFunctionCall(entry, temp, callTag)
    264273    move entry, temp
    265274    storep cfr, [sp]
     
    271280        # We need to allocate 32 bytes on the stack for the shadow space.
    272281        subp 32, sp
    273         call temp
     282        call temp, callTag
    274283        addp 32, sp
    275284    else
    276         call temp
     285        call temp, callTag
    277286    end
    278287end
     
    371380            btpz r0, .recover
    372381            move r1, sp
    373             jmp r0
     382            jmp r0, CodeEntryPtrTag
    374383        .recover:
    375384            loadi ArgumentCount + TagOffset[cfr], PC
     
    544553
    545554.noExtraSlot:
     555    if POINTER_PROFILING
     556        if ARM64
     557            loadp 8[cfr], lr
     558        end
     559
     560        addp 16, cfr, t3
     561        untagReturnAddress t3
     562    end
     563
    546564    // Move frame up t1 slots
    547565    negq t1
     
    566584    addp 8, t3
    567585    baddinz 1, t2, .fillLoop
     586
     587    if POINTER_PROFILING
     588        addp 16, cfr, t1
     589        tagReturnAddress t1
     590
     591        if ARM64
     592            storep lr, 8[cfr]
     593        end
     594    end
    568595
    569596.continue:
     
    19571984    loadisFromInstruction(2, t0)
    19581985    loadpFromInstruction(5, t1)
     1986    if POINTER_PROFILING
     1987        move t1, t5
     1988    end
    19591989    loadp LLIntCallLinkInfo::callee[t1], t2
    19601990    loadConstantOrVariable(t0, t3)
     
    19722002        loadp _g_JITCodePoison, t2
    19732003        xorp LLIntCallLinkInfo::machineCodeTarget[t1], t2
    1974         prepareCall(t2, t1, t3, t4)
    1975         callTargetFunction(t2)
     2004        prepareCall(t2, t1, t3, t4, macro (callPtrTag)
     2005            if POINTER_PROFILING
     2006                loadp LLIntCallLinkInfo::callPtrTag[t5], callPtrTag
     2007            end
     2008        end)
     2009        if POINTER_PROFILING
     2010            loadp LLIntCallLinkInfo::callPtrTag[t5], t3
     2011        end
     2012        callTargetFunction(t2, t3)
    19762013    else
    1977         prepareCall(LLIntCallLinkInfo::machineCodeTarget[t1], t2, t3, t4)
    1978         callTargetFunction(LLIntCallLinkInfo::machineCodeTarget[t1])
     2014        prepareCall(LLIntCallLinkInfo::machineCodeTarget[t1], t2, t3, t4, macro (callPtrTag)
     2015            if POINTER_PROFILING
     2016                loadp LLIntCallLinkInfo::callPtrTag[t5], callPtrTag
     2017            end
     2018        end)
     2019        if POINTER_PROFILING
     2020            loadp LLIntCallLinkInfo::callPtrTag[t5], t3
     2021        end
     2022        callTargetFunction(LLIntCallLinkInfo::machineCodeTarget[t1], t3)
    19792023    end
    19802024
     
    20762120    andp MarkedBlockMask, t1
    20772121    loadp MarkedBlockFooterOffset + MarkedBlock::Footer::m_vm[t1], t1
    2078     jmp VM::targetMachinePCForThrow[t1]
     2122    jmp VM::targetMachinePCForThrow[t1], ExceptionHandlerPtrTag
    20792123
    20802124
     
    21072151        if X86_64_WIN
    21082152            subp 32, sp
    2109             call executableOffsetToFunction[t1]
     2153            call executableOffsetToFunction[t1], NativeCodePtrTag
    21102154            addp 32, sp
    21112155        else
    21122156            loadp _g_NativeCodePoison, t2
    21132157            xorp executableOffsetToFunction[t1], t2
    2114             call t2
     2158            call t2, NativeCodePtrTag
    21152159        end
    21162160    end
     
    21502194        if X86_64_WIN
    21512195            subp 32, sp
    2152             call offsetOfFunction[t1]
     2196            call offsetOfFunction[t1], InternalFunctionPtrTag
    21532197            addp 32, sp
    21542198        else
    21552199            loadp _g_NativeCodePoison, t2
    21562200            xorp offsetOfFunction[t1], t2
    2157             call t2
     2201            call t2, InternalFunctionPtrTag
    21582202        end
    21592203    end
  • trunk/Source/JavaScriptCore/offlineasm/ast.rb

    r229447 r229481  
    930930        when "emit"
    931931            $asm.puts "#{operands[0].dump}"
     932        when "tagReturnAddress", "untagReturnAddress"
    932933        else
    933934            raise "Unhandled opcode #{opcode} at #{codeOriginString}"
  • trunk/Source/JavaScriptCore/offlineasm/instructions.rb

    r229447 r229481  
    1 # Copyright (C) 2011 Apple Inc. All rights reserved.
     1# Copyright (C) 2011-2018 Apple Inc. All rights reserved.
    22#
    33# Redistribution and use in source and binary forms, with or without
     
    250250     "leai",
    251251     "leap",
    252      "memfence"
     252     "memfence",
     253     "tagReturnAddress",
     254     "untagReturnAddress",
     255     "removeCodePtrTag"
    253256    ]
    254257
  • trunk/Source/JavaScriptCore/offlineasm/risc.rb

    r229447 r229481  
    449449def riscLowerMisplacedAddresses(list)
    450450    newList = []
    451     list.each {
    452         | node |
    453         if node.is_a? Instruction
     451    hasBackendSpecificLowering = Instruction.respond_to? "lowerMisplacedAddresses#{$activeBackend}"
     452    list.each {
     453        | node |
     454        if node.is_a? Instruction
     455            if hasBackendSpecificLowering
     456                wasHandled, newList = Instruction.send("lowerMisplacedAddresses#{$activeBackend}", node, newList)
     457                next if wasHandled
     458            end
     459
    454460            postInstructions = []
    455461            annotation = node.annotation
  • trunk/Source/WTF/ChangeLog

    r229447 r229481  
     12018-03-09  Mark Lam  <mark.lam@apple.com>
     2
     3        [Re-landing] Prepare LLInt code to support pointer profiling.
     4        https://bugs.webkit.org/show_bug.cgi?id=183387
     5        <rdar://problem/38199678>
     6
     7        Reviewed by JF Bastien.
     8
     9        * wtf/Platform.h:
     10
    1112018-03-08  Commit Queue  <commit-queue@webkit.org>
    212
  • trunk/Source/WTF/wtf/Platform.h

    r229447 r229481  
    10131013#endif
    10141014
     1015#if !defined(USE_POINTER_PROFILING) || USE(JSVALUE32_64) || !ENABLE(JIT)
     1016#undef USE_POINTER_PROFILING
     1017#define USE_POINTER_PROFILING 0
     1018#endif
     1019
    10151020/* CSS Selector JIT Compiler */
    10161021#if !defined(ENABLE_CSS_SELECTOR_JIT)
Note: See TracChangeset for help on using the changeset viewer.