-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only keep semantic fields in Java, i.e. skip location fields
* Add $YARP_SERIALIZE_ONLY_SEMANTICS_FIELDS to control where to serialize location fields at templating time, this way there is no overhead for either case and nothing to check at runtime. * Add a byte in the header to indicate whether location fields are included as expected. * Fixes #807 * Simplify the build-java CI job now that the FFI backend is available so JRuby can serialize. * Support keeping some location fields which are still needed until there is a replacement
- Loading branch information
Showing
13 changed files
with
88 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ | |
/doc/ | ||
/pkg/ | ||
/spec/reports/ | ||
/test/yarp/serialized/ | ||
/top-100-gems/ | ||
/tmp/ | ||
/vendor/bundle | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
fixtures = File.expand_path("../test/yarp/fixtures", __dir__) | ||
serialized_dir = File.expand_path("../serialized", fixtures) | ||
task "test:java_loader" do | ||
# Recompile with YARP_SERIALIZE_ONLY_SEMANTICS_FIELDS=1 | ||
# Due to some JRuby bug this does not get propagated to the compile task, so require the caller to set the env var | ||
# ENV["YARP_SERIALIZE_ONLY_SEMANTICS_FIELDS"] = "1" | ||
raise "this task requires $SERIALIZE_ONLY_SEMANTICS_FIELDS to be set" unless ENV["YARP_SERIALIZE_ONLY_SEMANTICS_FIELDS"] | ||
|
||
Rake::Task["clobber"].invoke | ||
Rake::Task["test:java_loader:internal"].invoke | ||
end | ||
|
||
task "test:java_loader:internal" => :compile do | ||
fixtures = File.expand_path("../test/yarp/fixtures", __dir__) | ||
|
||
desc "Serialize test fixtures and save it to .serialized files" | ||
task "test:serialize_fixtures" do | ||
$:.unshift(File.expand_path("../lib", __dir__)) | ||
require "yarp" | ||
raise "this task requires the FFI backend" unless YARP::BACKEND == :FFI | ||
require "fileutils" | ||
|
||
Dir["**/*.txt", base: fixtures].each do |relative| | ||
path = "#{fixtures}/#{relative}" | ||
serialized_path = "#{serialized_dir}/#{relative}" | ||
|
||
serialized = YARP.dump_file(path) | ||
FileUtils.mkdir_p(File.dirname(serialized_path)) | ||
File.write(serialized_path, serialized) | ||
end | ||
end | ||
|
||
task "test:java_loader" do | ||
require 'java' | ||
require_relative '../tmp/yarp.jar' | ||
java_import 'org.yarp.Nodes$Source' | ||
|
||
Dir["**/*.txt", base: fixtures].each do |relative| | ||
path = "#{fixtures}/#{relative}" | ||
serialized_path = "#{serialized_dir}/#{relative}" | ||
serialized = File.binread(serialized_path).unpack('c*') | ||
|
||
puts | ||
puts path | ||
serialized = YARP.dump_file(path) | ||
source_bytes = File.binread(path).unpack('c*') | ||
source = Source.new(source_bytes.to_java(:byte)) | ||
parse_result = org.yarp.Loader.load(serialized, source) | ||
parse_result = org.yarp.Loader.load(serialized.unpack('c*'), source) | ||
puts parse_result.value | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters