- Revision
- 281321
- Author
- [email protected]
- Date
- 2021-08-20 10:01:00 -0700 (Fri, 20 Aug 2021)
Log Message
Add some offlineasm enhancements.
https://bugs.webkit.org/show_bug.cgi?id=229332
rdar://82163923
Reviewed by Keith Miller.
1. Enhance "include" offlineasm Instruction to always attempt to include an asm
file from <build-products>/usr/local/include/WebKitAdditions/ first. If the
specified file is not available there, then it will attempt to include the file
from the same directory as the current source file (which in practice, means
Source/_javascript_Core/llint/).
2. Enhance "include" offlineasm Instruction to allow an optional file to be
included if it exists. For example, the following offlineasm code:
include? LowLevelInterpreterAdditions
... will attempt to include a file LowLevelInterpreterAdditions.asm. If the
file does not exist, this will be a no-op. Note: the "?" after the "include"
means the include is optional.
3. Enhanced "emit" offlineasm Instruction to be able to take more than one operand.
"emit" used to just copy the string operand that follows into the generated
LLIntAssembly.h. Now, "emit" can take multiple comma separated operands, and
will concatenate all the operands.
Additionally, "emit" can now take a LocalLabelReference as an operand. For
example, this offline asm code:
emit "b ", .done
...
.done:
... will generate this inline asm code in LLIntAssembly.h:
"b " LOCAL_LABEL_STRING(_offlineasm_someLabel_done) "\n"
This makes it easier to emit branches to local labels.
4. Also fixed LLInt code alignment for ARM_THUMB2 and ARM64.
Previously, it was aligned using ".align 4" which means aligned on a 4
instruction boundary. Note: the interpretation of .align varies for different
target CPU architectures.
Now, we do the alignment using ".balign 4" which means align on a 4 byte
boundary. This is the intended alignment because ARM64 instruction size is
4 bytes, and ARM_THUMB2 instruction size is either 2 bytes or 4 bytes.
Using .align before was potentially wasting some code space.
* llint/LowLevelInterpreter.asm:
* llint/LowLevelInterpreter.cpp:
* offlineasm/ast.rb:
* offlineasm/parser.rb:
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (281320 => 281321)
--- trunk/Source/_javascript_Core/ChangeLog 2021-08-20 16:22:25 UTC (rev 281320)
+++ trunk/Source/_javascript_Core/ChangeLog 2021-08-20 17:01:00 UTC (rev 281321)
@@ -1,5 +1,63 @@
2021-08-20 Mark Lam <[email protected]>
+ Add some offlineasm enhancements.
+ https://bugs.webkit.org/show_bug.cgi?id=229332
+ rdar://82163923
+
+ Reviewed by Keith Miller.
+
+ 1. Enhance "include" offlineasm Instruction to always attempt to include an asm
+ file from <build-products>/usr/local/include/WebKitAdditions/ first. If the
+ specified file is not available there, then it will attempt to include the file
+ from the same directory as the current source file (which in practice, means
+ Source/_javascript_Core/llint/).
+
+ 2. Enhance "include" offlineasm Instruction to allow an optional file to be
+ included if it exists. For example, the following offlineasm code:
+
+ include? LowLevelInterpreterAdditions
+
+ ... will attempt to include a file LowLevelInterpreterAdditions.asm. If the
+ file does not exist, this will be a no-op. Note: the "?" after the "include"
+ means the include is optional.
+
+ 3. Enhanced "emit" offlineasm Instruction to be able to take more than one operand.
+
+ "emit" used to just copy the string operand that follows into the generated
+ LLIntAssembly.h. Now, "emit" can take multiple comma separated operands, and
+ will concatenate all the operands.
+
+ Additionally, "emit" can now take a LocalLabelReference as an operand. For
+ example, this offline asm code:
+
+ emit "b ", .done
+ ...
+ .done:
+
+ ... will generate this inline asm code in LLIntAssembly.h:
+
+ "b " LOCAL_LABEL_STRING(_offlineasm_someLabel_done) "\n"
+
+ This makes it easier to emit branches to local labels.
+
+ 4. Also fixed LLInt code alignment for ARM_THUMB2 and ARM64.
+
+ Previously, it was aligned using ".align 4" which means aligned on a 4
+ instruction boundary. Note: the interpretation of .align varies for different
+ target CPU architectures.
+
+ Now, we do the alignment using ".balign 4" which means align on a 4 byte
+ boundary. This is the intended alignment because ARM64 instruction size is
+ 4 bytes, and ARM_THUMB2 instruction size is either 2 bytes or 4 bytes.
+ Using .align before was potentially wasting some code space.
+
+ * llint/LowLevelInterpreter.asm:
+ * llint/LowLevelInterpreter.cpp:
+ * offlineasm/ast.rb:
+ * offlineasm/parser.rb:
+
+2021-08-20 Mark Lam <[email protected]>
+
Reduce StructureID entropy bits to 5 to make room for more StructureIDs.
https://bugs.webkit.org/show_bug.cgi?id=229326
rdar://60141624
Modified: trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm (281320 => 281321)
--- trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm 2021-08-20 16:22:25 UTC (rev 281320)
+++ trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm 2021-08-20 17:01:00 UTC (rev 281321)
@@ -1964,6 +1964,8 @@
_js_trampoline_llint_function_for_construct_arity_check_tag_wide32:
crash()
+include? LowLevelInterpreterAdditions
+
# Value-representation-specific code.
if JSVALUE64
include LowLevelInterpreter64
Modified: trunk/Source/_javascript_Core/llint/LowLevelInterpreter.cpp (281320 => 281321)
--- trunk/Source/_javascript_Core/llint/LowLevelInterpreter.cpp 2021-08-20 16:22:25 UTC (rev 281320)
+++ trunk/Source/_javascript_Core/llint/LowLevelInterpreter.cpp 2021-08-20 17:01:00 UTC (rev 281321)
@@ -495,7 +495,7 @@
#if CPU(ARM_THUMB2)
#define OFFLINE_ASM_GLOBAL_LABEL(label) \
".text\n" \
- ".align 4\n" \
+ ".balign 4\n" \
".globl " SYMBOL_STRING(label) "\n" \
HIDE_SYMBOL(label) "\n" \
".thumb\n" \
@@ -504,7 +504,7 @@
#elif CPU(ARM64)
#define OFFLINE_ASM_GLOBAL_LABEL(label) \
".text\n" \
- ".align 4\n" \
+ ".balign 4\n" \
".globl " SYMBOL_STRING(label) "\n" \
HIDE_SYMBOL(label) "\n" \
SYMBOL_STRING(label) ":\n"
Modified: trunk/Source/_javascript_Core/offlineasm/ast.rb (281320 => 281321)
--- trunk/Source/_javascript_Core/offlineasm/ast.rb 2021-08-20 16:22:25 UTC (rev 281320)
+++ trunk/Source/_javascript_Core/offlineasm/ast.rb 2021-08-20 17:01:00 UTC (rev 281321)
@@ -944,7 +944,15 @@
when "globalAnnotation"
$asm.putGlobalAnnotation
when "emit"
- $asm.puts "#{operands[0].dump}"
+ str = "";
+ for operand in operands do
+ if (operand.is_a? LocalLabelReference)
+ str += operand.asmLabel
+ else
+ str += "#{operand.dump}"
+ end
+ end
+ $asm.puts "#{str}"
when "tagCodePtr", "tagReturnAddress", "untagReturnAddress", "removeCodePtrTag", "untagArrayPtr", "removeArrayPtrTag"
else
raise "Unhandled opcode #{opcode} at #{codeOriginString}"
Modified: trunk/Source/_javascript_Core/offlineasm/parser.rb (281320 => 281321)
--- trunk/Source/_javascript_Core/offlineasm/parser.rb 2021-08-20 16:22:25 UTC (rev 281320)
+++ trunk/Source/_javascript_Core/offlineasm/parser.rb 2021-08-20 17:01:00 UTC (rev 281321)
@@ -200,6 +200,8 @@
result << Token.new(CodeOrigin.new(file, lineNumber), $&)
when /\A".*"/
result << Token.new(CodeOrigin.new(file, lineNumber), $&)
+ when /\?/
+ result << Token.new(CodeOrigin.new(file, lineNumber), $&)
else
raise "Lexer error at #{CodeOrigin.new(file, lineNumber).to_s}, unexpected sequence #{str[0..20].inspect}"
end
@@ -261,6 +263,9 @@
@tokens = lex(data, fileName)
@idx = 0
@annotation = nil
+ # FIXME: CMake does not currently set BUILT_PRODUCTS_DIR.
+ # https://bugs.webkit.org/show_bug.cgi?id=229340
+ @buildProductsDirectory = ENV['BUILT_PRODUCTS_DIR'];
end
def parseError(*comment)
@@ -817,11 +822,22 @@
@idx += 1
elsif @tokens[@idx] == "include"
@idx += 1
+ isOptional = false
+ if @tokens[@idx] == "?"
+ isOptional = true
+ @idx += 1
+ end
parseError unless isIdentifier(@tokens[@idx])
moduleName = @tokens[@idx].string
- fileName = IncludeFile.new(moduleName, @tokens[@idx].codeOrigin.fileName.dirname).fileName
@idx += 1
- list << parse(fileName)
+ additionsDirectoryName = "#{@buildProductsDirectory}/usr/local/include/WebKitAdditions/"
+ fileName = IncludeFile.new(moduleName, additionsDirectoryName).fileName
+ if not File.exists?(fileName)
+ fileName = IncludeFile.new(moduleName, @tokens[@idx].codeOrigin.fileName.dirname).fileName
+ end
+ fileExists = File.exists?(fileName)
+ raise "File not found: #{fileName}" if not fileExists and not isOptional
+ list << parse(fileName) if fileExists
else
parseError "Expecting terminal #{final} #{comment}"
end
@@ -838,12 +854,22 @@
break
elsif @tokens[@idx] == "include"
@idx += 1
+ isOptional = false
+ if @tokens[@idx] == "?"
+ isOptional = true
+ @idx += 1
+ end
parseError unless isIdentifier(@tokens[@idx])
moduleName = @tokens[@idx].string
- fileName = IncludeFile.new(moduleName, @tokens[@idx].codeOrigin.fileName.dirname).fileName
@idx += 1
-
- fileList << fileName
+ additionsDirectoryName = "#{@buildProductsDirectory}/usr/local/include/WebKitAdditions/"
+ fileName = IncludeFile.new(moduleName, additionsDirectoryName).fileName
+ if not File.exists?(fileName)
+ fileName = IncludeFile.new(moduleName, @tokens[@idx].codeOrigin.fileName.dirname).fileName
+ end
+ fileExists = File.exists?(fileName)
+ raise "File not found: #{fileName}" if not fileExists and not isOptional
+ fileList << fileName if fileExists
else
@idx += 1
end