Ignore:
Timestamp:
Oct 12, 2017, 9:02:45 AM (8 years ago)
Author:
[email protected]
Message:

Enable gigacage on iOS
https://bugs.webkit.org/show_bug.cgi?id=177586

Reviewed by JF Bastien.
JSTests:


Add tests for when Gigacage gets runtime disabled.

  • stress/disable-gigacage-arrays.js: Added.

(foo):

  • stress/disable-gigacage-strings.js: Added.

(foo):

  • stress/disable-gigacage-typed-arrays.js: Added.

(foo):

Source/bmalloc:


Introduce the ability to disable gigacage at runtime if allocation fails. If any step of gigacage
allocation fails, we free all of the gigacages and turn off gigacage support.

Roll this back in after discussion.

  • CMakeLists.txt:
  • bmalloc.xcodeproj/project.pbxproj:
  • bmalloc/Cache.cpp:

(bmalloc::Cache::scavenge):

  • bmalloc/Cache.h:

(bmalloc::Cache::tryAllocate):
(bmalloc::Cache::allocate):
(bmalloc::Cache::deallocate):
(bmalloc::Cache::reallocate):

  • bmalloc/Gigacage.cpp:

(Gigacage::ensureGigacage):
(Gigacage::runway):
(Gigacage::totalSize):
(Gigacage::shouldBeEnabled):
(): Deleted.
(Gigacage::Callback::Callback): Deleted.
(Gigacage::Callback::function): Deleted.
(Gigacage::PrimitiveDisableCallbacks::PrimitiveDisableCallbacks): Deleted.

  • bmalloc/Gigacage.h:

(Gigacage::wasEnabled):
(Gigacage::isEnabled):
(Gigacage::runway): Deleted.
(Gigacage::totalSize): Deleted.

  • bmalloc/HeapKind.cpp: Added.

(bmalloc::isActiveHeapKind):
(bmalloc::mapToActiveHeapKind):

  • bmalloc/HeapKind.h:

(bmalloc::isActiveHeapKindAfterEnsuringGigacage):
(bmalloc::mapToActiveHeapKindAfterEnsuringGigacage):

  • bmalloc/Scavenger.cpp:

(bmalloc::Scavenger::scavenge):

  • bmalloc/bmalloc.h:

(bmalloc::api::tryLargeMemalignVirtual):
(bmalloc::api::freeLargeVirtual):
(bmalloc::api::isEnabled):

Source/JavaScriptCore:

The hardest part of enabling Gigacage on iOS is that it requires loading global variables while
executing JS, so the LLInt needs to know how to load from global variables on all platforms that
have Gigacage. So, this teaches ARM64 how to load from global variables.

Also, this makes the code handle disabling the gigacage a bit better.

  • ftl/FTLLowerDFGToB3.cpp:

(JSC::FTL::DFG::LowerDFGToB3::caged):

  • jit/AssemblyHelpers.h:

(JSC::AssemblyHelpers::cage):
(JSC::AssemblyHelpers::cageConditionally):

  • offlineasm/arm64.rb:
  • offlineasm/asm.rb:
  • offlineasm/instructions.rb:

Tools:


Add a mode to test disabling Gigacage.

  • Scripts/run-jsc-stress-tests:
  • Scripts/webkitruby/jsc-stress-test-writer-default.rb:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/offlineasm/arm64.rb

    r223202 r223239  
    261261end
    262262
     263def arm64LowerLabelReferences(list)
     264    newList = []
     265    list.each {
     266        | node |
     267        if node.is_a? Instruction
     268            case node.opcode
     269            when "loadi", "loadis", "loadp", "loadq", "loadb", "loadbs", "loadh", "loadhs"
     270                labelRef = node.operands[0]
     271                if labelRef.is_a? LabelReference
     272                    tmp = Tmp.new(node.codeOrigin, :gpr)
     273                    newList << Instruction.new(codeOrigin, "globaladdr", [LabelReference.new(node.codeOrigin, labelRef.label), tmp])
     274                    newList << Instruction.new(codeOrigin, node.opcode, [Address.new(node.codeOrigin, tmp, Immediate.new(node.codeOrigin, labelRef.offset)), node.operands[1]])
     275                else
     276                    newList << node
     277                end
     278            else
     279                newList << node
     280            end
     281        else
     282            newList << node
     283        end
     284    }
     285    newList
     286end
     287
    263288# Workaround for Cortex-A53 erratum (835769)
    264289def arm64CortexA53Fix835769(list)
     
    297322        result = riscLowerShiftOps(result)
    298323        result = arm64LowerMalformedLoadStoreAddresses(result)
     324        result = arm64LowerLabelReferences(result)
    299325        result = riscLowerMalformedAddresses(result) {
    300326            | node, address |
     
    905931            $asm.puts "nop"
    906932            $asm.putStr("#endif")
     933        when "globaladdr"
     934            uid = $asm.newUID
     935            $asm.puts "L_offlineasm_loh_adrp_#{uid}:"
     936            $asm.puts "adrp #{operands[1].arm64Operand(:ptr)}, #{operands[0].asmLabel}@GOTPAGE"
     937            $asm.puts "L_offlineasm_loh_ldr_#{uid}:"
     938            $asm.puts "ldr #{operands[1].arm64Operand(:ptr)}, [#{operands[1].arm64Operand(:ptr)}, #{operands[0].asmLabel}@GOTPAGEOFF]"
     939            $asm.deferAction {
     940                $asm.puts ".loh AdrpLdrGot L_offlineasm_loh_adrp_#{uid}, L_offlineasm_loh_ldr_#{uid}"
     941            }
    907942        else
    908943            lowerDefault
Note: See TracChangeset for help on using the changeset viewer.