Skip to content

Commit

Permalink
Merge r228402 - Miscellaneous refactoring of offlineasm.
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=182702
<rdar://problem/37467887>

Reviewed by Filip Pizlo.

1. Refactor out the emission of $asm.comment, $asm.codeOrigin, $asm.annotation,
   and $asm.debugAnnotation into a recordMetaData method.  This standardizes how
   we emit this metadata and makes all backends do it the same way.

2. Add the ability to include custom offlineasm scripts from WebKitAdditions in
   the future.

* offlineasm/arm.rb:
* offlineasm/arm64.rb:
* offlineasm/ast.rb:
* offlineasm/backends.rb:
* offlineasm/cloop.rb:
* offlineasm/config.rb:
* offlineasm/mips.rb:
* offlineasm/risc.rb:
* offlineasm/x86.rb:
  • Loading branch information
Mark Lam authored and carlosgcampos committed Feb 20, 2018
1 parent 3c984f5 commit a6369b0
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 27 deletions.
25 changes: 25 additions & 0 deletions Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,28 @@
2018-02-12 Mark Lam <mark.lam@apple.com>

Miscellaneous refactoring of offlineasm.
https://bugs.webkit.org/show_bug.cgi?id=182702
<rdar://problem/37467887>

Reviewed by Filip Pizlo.

1. Refactor out the emission of $asm.comment, $asm.codeOrigin, $asm.annotation,
and $asm.debugAnnotation into a recordMetaData method. This standardizes how
we emit this metadata and makes all backends do it the same way.

2. Add the ability to include custom offlineasm scripts from WebKitAdditions in
the future.

* offlineasm/arm.rb:
* offlineasm/arm64.rb:
* offlineasm/ast.rb:
* offlineasm/backends.rb:
* offlineasm/cloop.rb:
* offlineasm/config.rb:
* offlineasm/mips.rb:
* offlineasm/risc.rb:
* offlineasm/x86.rb:

2018-02-12 Saam Barati <sbarati@apple.com>

DFG::emitCodeToGetArgumentsArrayLength needs to handle NewArrayBuffer/PhantomNewArrayBuffer
Expand Down
6 changes: 1 addition & 5 deletions Source/JavaScriptCore/offlineasm/arm.rb
@@ -1,4 +1,4 @@
# Copyright (C) 2011, 2012, 2015-2016 Apple Inc. All rights reserved.
# Copyright (C) 2011-2018 Apple Inc. All rights reserved.
# Copyright (C) 2013 University of Szeged. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -348,10 +348,6 @@ def lowerARMv7_TRADITIONAL
end

def lowerARMCommon
$asm.codeOrigin codeOriginString if $enableCodeOriginComments
$asm.annotation annotation if $enableInstrAnnotations
$asm.debugAnnotation codeOrigin.debugDirective if $enableDebugAnnotations

case opcode
when "addi", "addp", "addis", "addps"
if opcode == "addis" or opcode == "addps"
Expand Down
6 changes: 1 addition & 5 deletions Source/JavaScriptCore/offlineasm/arm64.rb
@@ -1,4 +1,4 @@
# Copyright (C) 2011, 2012, 2014-2016 Apple Inc. All rights reserved.
# Copyright (C) 2011-2018 Apple Inc. All rights reserved.
# Copyright (C) 2014 University of Szeged. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -511,10 +511,6 @@ def emitARM64MoveImmediate(value, target)

class Instruction
def lowerARM64
$asm.comment codeOriginString
$asm.annotation annotation if $enableInstrAnnotations
$asm.debugAnnotation codeOrigin.debugDirective if $enableDebugAnnotations

case opcode
when 'addi'
emitARM64Add("add", operands, :int)
Expand Down
16 changes: 15 additions & 1 deletion Source/JavaScriptCore/offlineasm/ast.rb
@@ -1,4 +1,4 @@
# Copyright (C) 2011 Apple Inc. All rights reserved.
# Copyright (C) 2011-2018 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -933,6 +933,20 @@ def lowerDefault
raise "Unhandled opcode #{opcode} at #{codeOriginString}"
end
end

def prepareToLower(backendName)
if respond_to?("recordMetaData#{backendName}")
send("recordMetaData#{backendName}")
else
recordMetaDataDefault
end
end

def recordMetaDataDefault
$asm.codeOrigin codeOriginString if $enableCodeOriginComments
$asm.annotation annotation if $enableInstrAnnotations
$asm.debugAnnotation codeOrigin.debugDirective if $enableDebugAnnotations
end
end

class Error < NoChildren
Expand Down
5 changes: 3 additions & 2 deletions Source/JavaScriptCore/offlineasm/backends.rb
@@ -1,4 +1,4 @@
# Copyright (C) 2011, 2016 Apple Inc. All rights reserved.
# Copyright (C) 2011-2018 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -124,7 +124,8 @@ class Node
def lower(name)
begin
$activeBackend = name
send("lower" + name)
send("prepareToLower", name)
send("lower#{name}")
rescue => e
raise LoweringError.new(e, codeOriginString)
end
Expand Down
11 changes: 7 additions & 4 deletions Source/JavaScriptCore/offlineasm/cloop.rb
@@ -1,4 +1,4 @@
# Copyright (C) 2012-2017 Apple Inc. All rights reserved.
# Copyright (C) 2012-2018 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -567,9 +567,6 @@ class Instruction
@@didReturnFromJSLabelCounter = 0

def lowerC_LOOP
$asm.codeOrigin codeOriginString if $enableCodeOriginComments
$asm.annotation annotation if $enableInstrAnnotations && (opcode != "cloopDo")

case opcode
when "addi"
cloopEmitOperation(operands, :int32, "+")
Expand Down Expand Up @@ -1165,4 +1162,10 @@ def lowerC_LOOP
lowerDefault
end
end

def recordMetaDataC_LOOP
$asm.codeOrigin codeOriginString if $enableCodeOriginComments
$asm.annotation annotation if $enableInstrAnnotations && (opcode != "cloopDo")
$asm.debugAnnotation codeOrigin.debugDirective if $enableDebugAnnotations
end
end
12 changes: 11 additions & 1 deletion Source/JavaScriptCore/offlineasm/config.rb
@@ -1,4 +1,4 @@
# Copyright (C) 2012, 2016 Apple Inc. All rights reserved.
# Copyright (C) 2012-2018 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand All @@ -21,6 +21,16 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
# THE POSSIBILITY OF SUCH DAMAGE.

buildProductsDirectory = ENV['BUILT_PRODUCTS_DIR'];
if buildProductsDirectory and File.exists?(buildProductsDirectory)
$: << "#{buildProductsDirectory}/usr/local/include/WebKitAdditions/Scripts"
end
sdkRootDirectory = ENV['SDKROOT'];
if sdkRootDirectory and File.exists?(sdkRootDirectory)
$: << "#{sdkRootDirectory}/usr/local/include/WebKitAdditions/Scripts"
end


$preferredCommentStartColumn = 60


Expand Down
3 changes: 1 addition & 2 deletions Source/JavaScriptCore/offlineasm/mips.rb
@@ -1,4 +1,4 @@
# Copyright (C) 2012 Apple Inc. All rights reserved.
# Copyright (C) 2012-2018 Apple Inc. All rights reserved.
# Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -825,7 +825,6 @@ def emitMIPSJumpOrCall(opcode, operand)

class Instruction
def lowerMIPS
$asm.comment codeOriginString
case opcode
when "addi", "addp", "addis"
if operands.size == 3 and operands[0].is_a? Immediate
Expand Down
4 changes: 2 additions & 2 deletions Source/JavaScriptCore/offlineasm/risc.rb
@@ -1,4 +1,4 @@
# Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
# Copyright (C) 2011-2018 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -575,7 +575,7 @@ def riscLowerNot(list)
if node.is_a? Instruction
case node.opcode
when "noti", "notp"
raise "Wrong nubmer of operands at #{node.codeOriginString}" unless node.operands.size == 1
raise "Wrong number of operands at #{node.codeOriginString}" unless node.operands.size == 1
suffix = node.opcode[-1..-1]
newList << Instruction.new(node.codeOrigin, "xor" + suffix,
[Immediate.new(node.codeOrigin, -1), node.operands[0]])
Expand Down
6 changes: 1 addition & 5 deletions Source/JavaScriptCore/offlineasm/x86.rb
@@ -1,4 +1,4 @@
# Copyright (C) 2012, 2014-2016 Apple Inc. All rights reserved.
# Copyright (C) 2012-2018 Apple Inc. All rights reserved.
# Copyright (C) 2013 Digia Plc. and/or its subsidiary(-ies)
#
# Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -890,10 +890,6 @@ def lowerX86_64_WIN
end

def lowerX86Common
$asm.codeOrigin codeOriginString if $enableCodeOriginComments
$asm.annotation annotation if $enableInstrAnnotations
$asm.debugAnnotation codeOrigin.debugDirective if $enableDebugAnnotations

case opcode
when "addi"
handleX86Add(:int)
Expand Down

0 comments on commit a6369b0

Please sign in to comment.