Presentation from JVMLS 2015
One bottleneck in the Nashorn JavaScript engine is startup time. Nashorn, as it works currently in Java 8, JITs everything to Java bytecode, accruing overhead in code generation and class installation. Nashorn in Java 9, can in unfortunate cases, increase this compilation workload significantly, as the new optimistic type system, which has greatly increased steady state performance, requires more code invalidation on warmup. Based on our optimistic type compilation framework, which contains all the mechanisms for quick code replacement and on stack replacement on the bytecode level, I will present the new execution architecture we are developing. It will minimizes compile time intelligently, while maintaining or possible even increasing code performance, due to extra profiling and execution frequency information being passed to the JIT. I will also talk about what the future will bring in terms of other dynamic languages on the Nashorn engine, partial method compilation of hot paths and other intriguing possibilities that our new execution model opens up.
Kotlin is new JVM language still cooking in Jetbrains kitchen. It looks awesome compared to Java 7, but now, with Java 8 in the field, the question arises: “Does Kotlin still have enough advantages over Java to attract Java developers?” Similar questions could be asked for other JVM languages like Scala, Ceylon, Clojure. We tried to compare new features of Java 8 with corresponding features of Kotlin and see what Kotlin offers beyond features existing in latest Java release.
Akka is using the Actors together with STM to create a unified runtime and programming model for scaling both UP (multi-core) and OUT (grid/cloud). Akka provides location transparency by abstracting away both these tangents of scalability by turning them into an ops task. This gives the Akka runtime freedom to do adaptive automatic load-balancing, cluster rebalancing, replication & partitioning
Are you tired of java.lang.OutOfMemoryError: PermGen space? Then this talk is for you! We'll begin with a crash course in the Java memory model in order to understand what the error message means. Then we'll look at different causes of the error and how to avoid them. We may glance at a few interesting mistakes from the Open Source world. Last but not least you'll learn how you can get rid of java.lang.OutOfMemoryError: PermGen space once and for all.
This session talks about how unit testing of Spark applications is done, as well as tells the best way to do it. This includes writing unit tests with and without Spark Testing Base package, which is a spark package containing base classes to use when writing tests with Spark.
A presentation at Twitter's official developer conference, Chirp, about why we use the Scala programming language and how we build services in it. Provides a tour of a number of libraries and tools, both developed at Twitter and otherwise.
Look past the square braces and the damned header files and Objective-C -- the essential language of iOS development -- really isn't that different from other object-oriented languages. Classes, single-inheritance, polymorphism, implementation hiding... check, check, check, and check. So it's really not that difficult for old Java / Python / Ruby / C++ dogs to learn new tricks once they install Xcode, right?
To be a competent Obj-C programmer, not that hard.
To be a great Obj-C programmer... now that's another story.
In this session, we will look at traits that are unique to Objective-C, the tricks that bring out the expressiveness and power of the language. We'll also look at how to write idiomatic code that will be easily understood and maintained by other Objective-C developers. We'll look at how Automatic Reference Counting resembles but is really nothing like Garbage Collection, how properties put plain old instance variables to shame, how we loosely couple classes with delegates and notification, how blocks help us un-block our code by simplifying asynchronicity, and more.
OSGi ecosystems compared on Apache Karaf - Christian Schneidermfrancis
OSGi Community Event 2015
A look at three competing OSGi ecosystems (Declarative Services, Blueprint, CDI). Capabilities of each DI framework. Comparison of support for EE technologies like JPA, Security, SOAP and REST services, UIs. Looking into some of the recent advancements like Aries JPA 2 featuring closure based transactions, JAAS Security, JSP and JSF on OSGi. Attendees will get a good overview about the stacks as well as recommendations where each is most applicable.
Asynchronous web apps with the Play Framework 2.0Oscar Renalias
Brief introduction to the asynchronous and reactive IO capabilities available in Play 2.0.
Source code of the demos available here: https://github.com/oscarrenalias/wjax-2012-play-async-apps
Kotlin is new JVM language still cooking in Jetbrains kitchen. It looks awesome compared to Java 7, but now, with Java 8 in the field, the question arises: “Does Kotlin still have enough advantages over Java to attract Java developers?” Similar questions could be asked for other JVM languages like Scala, Ceylon, Clojure. We tried to compare new features of Java 8 with corresponding features of Kotlin and see what Kotlin offers beyond features existing in latest Java release.
Akka is using the Actors together with STM to create a unified runtime and programming model for scaling both UP (multi-core) and OUT (grid/cloud). Akka provides location transparency by abstracting away both these tangents of scalability by turning them into an ops task. This gives the Akka runtime freedom to do adaptive automatic load-balancing, cluster rebalancing, replication & partitioning
Are you tired of java.lang.OutOfMemoryError: PermGen space? Then this talk is for you! We'll begin with a crash course in the Java memory model in order to understand what the error message means. Then we'll look at different causes of the error and how to avoid them. We may glance at a few interesting mistakes from the Open Source world. Last but not least you'll learn how you can get rid of java.lang.OutOfMemoryError: PermGen space once and for all.
This session talks about how unit testing of Spark applications is done, as well as tells the best way to do it. This includes writing unit tests with and without Spark Testing Base package, which is a spark package containing base classes to use when writing tests with Spark.
A presentation at Twitter's official developer conference, Chirp, about why we use the Scala programming language and how we build services in it. Provides a tour of a number of libraries and tools, both developed at Twitter and otherwise.
Look past the square braces and the damned header files and Objective-C -- the essential language of iOS development -- really isn't that different from other object-oriented languages. Classes, single-inheritance, polymorphism, implementation hiding... check, check, check, and check. So it's really not that difficult for old Java / Python / Ruby / C++ dogs to learn new tricks once they install Xcode, right?
To be a competent Obj-C programmer, not that hard.
To be a great Obj-C programmer... now that's another story.
In this session, we will look at traits that are unique to Objective-C, the tricks that bring out the expressiveness and power of the language. We'll also look at how to write idiomatic code that will be easily understood and maintained by other Objective-C developers. We'll look at how Automatic Reference Counting resembles but is really nothing like Garbage Collection, how properties put plain old instance variables to shame, how we loosely couple classes with delegates and notification, how blocks help us un-block our code by simplifying asynchronicity, and more.
OSGi ecosystems compared on Apache Karaf - Christian Schneidermfrancis
OSGi Community Event 2015
A look at three competing OSGi ecosystems (Declarative Services, Blueprint, CDI). Capabilities of each DI framework. Comparison of support for EE technologies like JPA, Security, SOAP and REST services, UIs. Looking into some of the recent advancements like Aries JPA 2 featuring closure based transactions, JAAS Security, JSP and JSF on OSGi. Attendees will get a good overview about the stacks as well as recommendations where each is most applicable.
Asynchronous web apps with the Play Framework 2.0Oscar Renalias
Brief introduction to the asynchronous and reactive IO capabilities available in Play 2.0.
Source code of the demos available here: https://github.com/oscarrenalias/wjax-2012-play-async-apps
RingoJS: Server-Side Javascript When Only Java Will DoDarren Cruse
Slides for a talk I gave at the St. Louis Javascript User Group about server-side javascript, Ringo, and a preview of my work-in-progress project EtherealJS which aims for easy interop between ringo, browser, and node.js.
Helping Organizations Realize the Value of DevOps with Continuous Software De...IBM UrbanCode Products
The IBM UrbanCode solution enables continuous release and application deployment allowing organizations to deliver applications rapidly and improve overall time to market.
Keynote that I gave at JavaLand 2015, in Brühl, Germany. Talks about 20 years of Java and JVM technology from my subjective perspective. "What have I been doing with my life for the last 20 years".
Creating strong & passionate agile communities of practiceAllison Pollard
Everyone hits a challenge at some point in adopting agile and belonging to a larger community can help you overcome those challenges. Whether you call it a tribe, a user group, or a community of practice, having a group of people to share ideas with and learn from is a valuable tool to further your personal development and maintain your sanity. Learn about what communities of practice are, how to start them, and why they’re an important part of growing agile.
All new features, expected features and speculations regarding the upcoming Java 9 release: the Jigsaw project, performance improvements and long awaited APIs:
www.takipiblog.com/java-9-the-ultimate-feature-list/
How to measure a product development organization? Lean/Agile provides a fresh view on this. Kanban goes further and makes it VERY easy to measure. Learn what to look at and how.
Object-Oriented Programming has well established design principles, such as SOLID. For many developers architecture and functional programming are at odds with each other: they don’t know how their existing tricks of the trade convert into functional design. This problem becomes worse as hybrid languages such as Scala, Java 8 and Ruby become common. I will talk about how functional programming helps you implement the SOLID principles, and how a functional mindset can actually help you achieve the holy grail of OO, encapsulation.
In this talk we will take a deep dive into the inner workings of JavaScript. Scopes, functions, closures, and prototypes are just some of the most misunderstood terms in the JavaScript world. We will take a tour "behind the scenes" of JavaScript to learn how to write better code.
Video and slides synchronized, mp3 and slide download available at URL http://bit.ly/254wkpw.
Aaron Bedra focuses on describing a system as a series of models that can be used to systematically and automatically generate input data and ensure that a code is behaving as expected. Bedra discusses property based testing and how it can help one build more resilient systems and even reduce the time needed to maintain a test suite. Filmed at qconlondon.com.
Aaron Bedra is Chief Security Officer at eligible.com. He is the creator of Repsheet, an open source threat intelligence framework. Bedra is the co-author of Programming Clojure, 2nd Edition and a frequent contributor to open source software.
Talk from JVMLS2014 on Nashorn moving towards a generic execution architecture for dynamic languages on the JVM. Explains the optimistic type architecture that is the basis for this. Also covers the last year's large leaps in performance.
JavaFX 8 est disponible depuis mars 2014 et apporte son lot de nouveautés. Gradle est en version 2 depuis juillet 2014. Deux technologies plus que prometteuses: JavaFX donne un coup de jeune au développement d’applications desktop en Java en apportant un navigateur web intégré, le support des WebSockets, de la 3D, et bien d’autres. Gradle est l’outil de d’automatisation de build à la mode, apportant de superbes possibilités par rapport rapport à maven, outil vieillissant, grâce à l’engouement de la communauté vis à vis de cet outil mais aussi par le fait de la technologie utilisée en son sein: groovy. Venez découvrir comment il est possible de réaliser rapidement une application à la mode en JavaFX avec un outil à la mode également. Bref venez à une session trendy.
Dev Day 2019: Mike Sperber – Software Design für die SeeleDevDay Dresden
Ein Großteil der praktizierten Software-Entwicklung ist Wartung, also das Herumbasteln an Software, die eigentlich schon fertig sein sollte, aber trotzdem irgendwie noch nicht ganz so funktioniert wie sie soll. "Bastelorientiertes Programmieren" ist so ziemlich das Gegenteil von robuster und sicherer Entwicklung, aber die meisten heutigen Informatik-Systeme werden genauso entwickelt. (Inbesondere die allgegenwärtigen IoT-Geräte, denen wir immer mehr Aspekte unseres Lebens anvertrauen.) Wie also bekommen wir die Kontrolle über die Software der Zukunft zurück, die zunehmend außer Kontrolle gerät? Nicht mit objektorientierter Programmierung: Veränderbarer Zustand, die Abwesenheit von uniformen Abstraktionsmechanismen und vererbungsbedingte Komplexität machen es für Menschen schwer, korrekte und robuste Software zu entwickeln. Während agile Methoden Entwicklerinnen und Entwickler von den seelensaugenden Prozessen der Vergangenheit befreit haben, ist die vorherrschende Technologie - Objektorientierung - immer noch Teil des Problems, nicht der Lösung. Es ist an der Zeit, sich davon zu verabschieden: Wir sollten die systematische Konstruktion korrekter Software propagieren. Im Zentrum dieser Revolution steht die konsequente Anwendung funktionaler Programmierung - also unveränderlicher Datenstrukturen, systematischer Abstraktion und Datenmodellierung. Weg mit den toten techologieorientierten Objekten der Vergangenheit, her mit geschmeidigen Modellen, die unsere Domänen bereichern und unsere Seele!
Finally Java SE 7 is GA and you can start using it. This talk will cover the most important new features of the language and the virtual machine. It will also cover some features that did not make it in to the SE 7 release. Finally we will discuss current state of Java as an ecosystem and my analysis and hopes for the future.
Presentation to the MIT IAP HTML5 Game Development Class on Debugging and Optimizing Javascript, Local storage, Offline Storage and Server side Javascript with Node.js
JavaScript basics
JavaScript event loop
Ajax and promises
DOM interaction
JavaScript object orientation
Web Workers
Useful Microframeworks
This presentation has been developed in the context of the Mobile Applications Development course, DISIM, University of L'Aquila (Italy), Spring 2016.
http://www.ivanomalavolta.com
Fullstack Conference - Proxies before proxies: The hidden gems of Javascript...Tim Chaplin
Tired of console.logging your way through applications? Want a way to slice through your application without adding complexity? AOP has been the answer to these questions for object oriented languages, such as Java and C#, but is not available in Javascript. ScarletJS(https://github.com/scarletjs/scarlet) is a project that tackles AOP using a clean, fluent, performant interface.
The ScarletJS project provides Javascript developers a different way of thinking about traditional javascript problems. The project is still growing and looking into the future of what ES6 proxies will open up to the Javascript community.
The talk will highlight the problems that javascript developers face with logging application behavior, security, and more. It will discuss the benefits of identifying a cross cutting concern, and programming using aspects. The talk will highlight how thinking about a project and cross cutting concerns can lead to cleaner more SOLID code. It will also discuss the future of ES6 proxies and the benefits that they will bring.
Kerberizing Spark: Spark Summit East talk by Abel Rincon and Jorge Lopez-MallaSpark Summit
Spark had been elected, deservedly, as the main massive parallel processing framework, and HDFS is the one of the most popular Big Data storage technologies. Therefore its combination is one of the most usual Big Data’s use cases. But, what happens with the security? Can these two technologies coexist in a secure environment? Furthermore, with the proliferation of BI technologies adapted to Big Data environments, that demands that several users interacts with the same cluster concurrently, can we continue to ensure that our Big Data environments are still secure? In this lecture, Abel and Jorge will explain which adaptations of Spark´s core they had to perform in order to guarantee the security of multiple concurrent users using a single Spark cluster, which can use any of its cluster managers, without degrading the outstanding Spark’s performance.
Similar to A new execution model for Nashorn in Java 9 (20)
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptxBrad Spiegel Macon GA
Brad Spiegel Macon GA’s journey exemplifies the profound impact that one individual can have on their community. Through his unwavering dedication to digital inclusion, he’s not only bridging the gap in Macon but also setting an example for others to follow.
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdfFlorence Consulting
Quattordicesimo Meetup di Milano, tenutosi a Milano il 23 Maggio 2024 dalle ore 17:00 alle ore 18:30 in presenza e da remoto.
Abbiamo parlato di come Axpo Italia S.p.A. ha ridotto il technical debt migrando le proprie APIs da Mule 3.9 a Mule 4.4 passando anche da on-premises a CloudHub 1.0.
Understanding User Behavior with Google Analytics.pdfSEO Article Boost
Unlocking the full potential of Google Analytics is crucial for understanding and optimizing your website’s performance. This guide dives deep into the essential aspects of Google Analytics, from analyzing traffic sources to understanding user demographics and tracking user engagement.
Traffic Sources Analysis:
Discover where your website traffic originates. By examining the Acquisition section, you can identify whether visitors come from organic search, paid campaigns, direct visits, social media, or referral links. This knowledge helps in refining marketing strategies and optimizing resource allocation.
User Demographics Insights:
Gain a comprehensive view of your audience by exploring demographic data in the Audience section. Understand age, gender, and interests to tailor your marketing strategies effectively. Leverage this information to create personalized content and improve user engagement and conversion rates.
Tracking User Engagement:
Learn how to measure user interaction with your site through key metrics like bounce rate, average session duration, and pages per session. Enhance user experience by analyzing engagement metrics and implementing strategies to keep visitors engaged.
Conversion Rate Optimization:
Understand the importance of conversion rates and how to track them using Google Analytics. Set up Goals, analyze conversion funnels, segment your audience, and employ A/B testing to optimize your website for higher conversions. Utilize ecommerce tracking and multi-channel funnels for a detailed view of your sales performance and marketing channel contributions.
Custom Reports and Dashboards:
Create custom reports and dashboards to visualize and interpret data relevant to your business goals. Use advanced filters, segments, and visualization options to gain deeper insights. Incorporate custom dimensions and metrics for tailored data analysis. Integrate external data sources to enrich your analytics and make well-informed decisions.
This guide is designed to help you harness the power of Google Analytics for making data-driven decisions that enhance website performance and achieve your digital marketing objectives. Whether you are looking to improve SEO, refine your social media strategy, or boost conversion rates, understanding and utilizing Google Analytics is essential for your success.
1.Wireless Communication System_Wireless communication is a broad term that i...JeyaPerumal1
Wireless communication involves the transmission of information over a distance without the help of wires, cables or any other forms of electrical conductors.
Wireless communication is a broad term that incorporates all procedures and forms of connecting and communicating between two or more devices using a wireless signal through wireless communication technologies and devices.
Features of Wireless Communication
The evolution of wireless technology has brought many advancements with its effective features.
The transmitted distance can be anywhere between a few meters (for example, a television's remote control) and thousands of kilometers (for example, radio communication).
Wireless communication can be used for cellular telephony, wireless access to the internet, wireless home networking, and so on.
2.Cellular Networks_The final stage of connectivity is achieved by segmenting...JeyaPerumal1
A cellular network, frequently referred to as a mobile network, is a type of communication system that enables wireless communication between mobile devices. The final stage of connectivity is achieved by segmenting the comprehensive service area into several compact zones, each called a cell.
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024APNIC
Ellisha Heppner, Grant Management Lead, presented an update on APNIC Foundation to the PNG DNS Forum held from 6 to 10 May, 2024 in Port Moresby, Papua New Guinea.
Italy Agriculture Equipment Market Outlook to 2027harveenkaur52
Agriculture and Animal Care
Ken Research has an expertise in Agriculture and Animal Care sector and offer vast collection of information related to all major aspects such as Agriculture equipment, Crop Protection, Seed, Agriculture Chemical, Fertilizers, Protected Cultivators, Palm Oil, Hybrid Seed, Animal Feed additives and many more.
Our continuous study and findings in agriculture sector provide better insights to companies dealing with related product and services, government and agriculture associations, researchers and students to well understand the present and expected scenario.
Our Animal care category provides solutions on Animal Healthcare and related products and services, including, animal feed additives, vaccination
4. Safe
Harbor
Statement
"THE FOLLOWING IS INTENDED TO OUTLINE OUR
GENERAL PRODUCT DIRECTION. IT IS INTENDED FOR
INFORMATION PURPOSES ONLY, AND MAY NOT BE
INCORPORATED INTO ANY CONTRACT. IT IS NOT A
COMMITMENT TO DELIVER ANY MATERIAL, CODE, OR
FUNCTIONALITY, AND SHOULD NOT BE RELIED UPON IN
MAKING PURCHASING DECISION. THE DEVELOPMENT,
RELEASE, AND TIMING OF ANY FEATURES OR
FUNCTIONALITY DESCRIBED FOR ORACLE'S PRODUCTS
REMAINS AT THE SOLE DISCRETION OF ORACLE."
5. Safe
Harbor
Statement
"THE FOLLOWING IS INTENDED TO OUTLINE OUR
GENERAL PRODUCT DIRECTION. IT IS INTENDED FOR
INFORMATION PURPOSES ONLY, AND MAY NOT BE
INCORPORATED INTO ANY CONTRACT. IT IS NOT A
COMMITMENT TO DELIVER ANY MATERIAL, CODE, OR
FUNCTIONALITY, AND SHOULD NOT BE RELIED UPON IN
MAKING PURCHASING DECISION. THE DEVELOPMENT,
RELEASE, AND TIMING OF ANY FEATURES OR
FUNCTIONALITY DESCRIBED FOR ORACLE'S PRODUCTS
REMAINS AT THE SOLE DISCRETION OF ORACLE."
@lagergren
6. Agenda
• Dynamic
languages
on
the
JVM
–
Why?
• Nashorn
• Performance
• Op>mis>c
Types,
Steady
State
Performance
• Startup
and
Warmup
Performance
• Nashorn
Java
9
execu>on
architecture
• Future
Work
13. • Automa>c
memory
management
• State
of
the
art
JIT
op>miza>ons
• Na>ve
threading
capability
• Hybridiza>on
– (javax.scripting,
JSR-‐223)
• Man
decades
of
high
tech
– Already
in
the
JVM
Why
“Alien”
Languages
on
the
JVM?
14. Why
“Alien”
Languages
on
the
JVM?
0
100000
200000
300000
400000
500000
Code
bases
Lines
16. • Invokedynamic
POC
• Compliant
JavaScript
run>me
• Open
• Fast*
• Hybrid
– JSR-‐223,
javax.scrip>ng
• Extensible
Nashorn
Goals,
2010-‐
*
At
first
comparable
in
performance
to
na>ve
implementa>ons,
in
domains
where
it
makers.
17. • Toolbox
for
other
dynamic
languages
on
top
of
the
JVM
– Dynalink
– TypeScript
thesis
– JRuby
9000
synergy
– “the
invokedynamic
way
of
language
implementa>on”
Long
Term
Nashorn
Goals
20. What
Does
“Performance”
Mean?
Total
Performance
=
Execu>on
Time
+
Run>me
Overhead
[JavaScript
&
na>ve
>me
–
brought
down
by:
invokedynamic
op>miza>ons,
incremental
inlining,
field
access
>me
minimiza>on,
efficient
na>ve
code
implementa>on,
type
specializa>on,
op>mis>c
type
guesses,
JIT
op>miza>ons
of
bytecode]
21. What
Does
“Performance”
Mean?
Total
Performance
=
Execu>on
Time
+
Run>me
Overhead
The
goal
of
8u60
(main
func>onality,
like
–optimistic-
types s>ll
disabled
by
default)
22. What
Does
“Performance”
Mean?
Total
Performance
=
Execu>on
Time
+
Run>me
Overhead
The
stretch
goal
for
9
23. What
Does
“Performance”
Mean?
Total
Performance
=
Execu>on
Time
+
Run>me
Overhead
[increase
BC/Nashorn
jit
speed,
minimize
relinking
of
callsite/bytecode
regenera>on,
>red
JIT
recompila>on,
class
installa>on
speed,
>me
spent
in
GC
etc
–
MAKE
STARTUP
FASTER]
24. What
Does
“Performance”
Mean?
Total
Performance
=
Execu>on
Time
+
Warmup/Steady
State
Overhead
+
Run>me
Overhead
Especially
important:
Time
to
reach
steady
state!
Use
cases:
frequent
restarts,
REPL,
redeployments,
evals
25. What
Does
“Performance”
Mean?
Especially
important:
Time
to
reach
steady
state!
8u60
has
lazy
compilaBon
&
code
caching
that
helps
some
for
runs
n…,
n
>
1
Total
Performance
=
Execu>on
Time
+
Warmup/Steady
State
Overhead
+
Run>me
Overhead
26. Genera>ng
Code
That
Runs
Faster:
Op>mis>c
Types
[for
even
more
in
depth
info,
see
my
JVMLS
presenta>ons
from
2013
and
2014]
28. Akack
Execu>on
Time
• invokedynamic
implementa>on
– JVM
– java.lang.invoke
implementa>on
• Boxing,
boxing
everywhere
– In
the
libraries
– Representa>on
of
generated
code
– Insufficient
escape
analysis,
or
even
opportuni>es
for
it
32. Op>mis>c
Types
function() {
return a + b;
}
try {
operation; // get a, get b or iadd
} catch (final UnwarrantedOptimismException e) {
throw new RewriteException(e.getLocalVariables(), e.getProgramPoint());
}
33. Op>mis>c
Types
• Use
whatever
sta>c
types
there
are
• Guess
the
rest
• Take
a
con>nua>on
and
recompile
if
wrong
long
double
Object
(pessimis>c)
int
34. Op>mis>c
Types
• Retain
primi>ve
storage
is
possible
– Dual
fields,
later
VarHandles/TaggedArrays
– Method
specializa>on
• Add
specialized
version
of
na>ve
methods
35. Op>mis>c
Types
@Function(arity = 2,
attributes = Attribute.NOT_ENUMERABLE,
where = Where.CONSTRUCTOR)
public static double max(final Object self, final Object... args) {
switch (args.length) {
case 0:
return Double.NEGATIVE_INFINITY;
case 1:
return JSType.toNumber(args[0]);
default:
double res = JSType.toNumber(args[0]);
for (int i = 1; i < args.length; i++) {
res = Math.max(res, JSType.toNumber(args[i]));
}
return res;
}
}
37. Op>mis>c
Types
@SpecializedFunction
public static int max(final Object self, final int x, final int y) {
return Math.max(x, y);
}
@SpecializedFunction
public static long max(final Object self, final long x, final long y) {
return Math.max(x, y);
}
38. Op>mis>c
Types
@SpecializedFunction
public static int max(final Object self, final int x, final int y) {
return Math.max(x, y);
}
@SpecializedFunction
public static long max(final Object self, final long x, final long y) {
return Math.max(x, y);
}
@SpecializedFunction
public static double max(final Object self, final double x, final double y) {
return Math.max(x, y);
}
39. Op>mis>c
Types
@SpecializedFunction
public static int max(final Object self, final int x, final int y) {
return Math.max(x, y);
}
@SpecializedFunction
public static long max(final Object self, final long x, final long y) {
return Math.max(x, y);
}
@SpecializedFunction
public static double max(final Object self, final double x, final double y) {
return Math.max(x, y);
}
@SpecializedFunction
public static double max(final Object self, final Object, final Object y) {
return Math.max(JSType.toNumber(x), JSType.toNumber(y));
}
42. The
Cost
of
Steady
State
Performance
Startup
and
warmup
>me
un>l
steady
state.
Bytecode
genera>on
>me.
Memory
usage
/
GC
overhead.
43. Startup
Time
With
and
Without
Op>mis>c
Types
0
0.5
1
1.5
2
2.5
3
3.5
4
8u60,
jit
9,
jit
44. Bytecodes
generated
during
Startup
With
and
Without
Op>mis>c
Types
0
2
4
6
8
10
12
14
16
18
20
8u60,
jit
9,
jit
45. #
classes
generated
during
Startup
With
and
Without
Op>mis>c
Types
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
8u60,
jit
9,
jit
46. Nightmare
Use
Cases
• Dynamically
evaluated
throwaway
code
• Lots
of
relinking
– Lots
of
type
invalida>on
(special
case
of
the
above)
function mtd() {
// x is an Object, but starts out assumed int
// 9 times, 9 indy call sites,
// 9 continuations, 9 recompilations
//
// Or x is just a getter with side effects or
// whatever – JavaScript: anything goes
return x * x * x * x * x * x * x * x * x;
}
51. Stable
Run>me
Performance
• Op>mis>c
types
definitely
gets
us
run>me
performance
in
steady
state
• But
they
also
make
HotSpot
unfeasibly
slow
to
warm
up
– (and
also:
The
bigger
the
method,
the
worse
the
op>miza>ons)
52.
53. Startup
&
Warmup
Overhead
• Observa>on:
most
type
guesses
are
invalidated
once,
and
are
then
correct
forever
– ~95-‐99%
of
the
>me
in
Octane
• Do
we
really
need
to
generate
so
much
new
code?
54. Startup
&
Warmup
Overhead
• Observa>on:
even
callsites
aren’t
monomorphic,
for
small
polymorphism
a
guard
tree
s>ll
works
fine
• Gets
rid
of
most
relinks
if (propertyMap == propertyMap1) { … }
} else if { (propertyMap == propertyMap2) { … }
…
} else { … megamorphic slow dispatch }
55. Startup
&
Warmup
Overhead
• Let’s
assume
that
steady
state
performance
is
indeed
good
enough
(for
now)
– So
for
steady
state,
op>mis>c
types
are
definitely
a
performance
success.
• Akacking
startup
and
warmup
>me
56. Previous
Work
• Lazy
CompilaBon
(jdk
8u40)
alleviates
some
of
this
• Code
Caching
(jdk
8u40)
alleviates
some
of
this
too,
for
runs
2..n
– OpBmisBc
Type
Caching
(jdk
8u60)
57. Akacking
Startup
&
Warmup
Overhead?
• Akacking
startup
and
warmup
>me
• First
try:
Tier
the
JIT?
• Profiling
JIT
level
with
pessimis>c,
non
faul>ng
code?
58. Tier
the
JIT?
• Pro:
very
likle
new
code
needs
to
be
wriken.
59. Tier
the
JIT?
• Pro:
very
likle
new
code
needs
to
be
wriken.
• Pro:
we
already
generate
arbitrary
level
of
pessimism
on
demand
for
RewriteExceptions
60. Tier
the
JIT?
• Pro:
very
likle
new
code
needs
to
be
wriken.
• Pro:
we
already
generate
arbitrary
level
of
pessimism
on
demand
for
RewriteExceptions
• Pro:
no
significant
test
matrix
growth
61. Tier
the
JIT?
• Con:
Type
pollu>on
– Too
wide
values
wriken
to
scopes
• Con:
(dealbreaker)
code
genera>on
overhead
– We
don’t
get
away
from
the
root
cause
of
overhead
– Smallest
compile
unit
is
a
class
with
a
method
– System
dic>onary
locks
– Byte
code
verifica>on
– Various
other
class
registra>on
horrors
• (also
a
problem
in
lambda
forms
or
any
woven
bytecode)
62. Tier
the
JIT?
• Con:
Type
pollu>on
– Too
wide
values
wriken
to
scopes
• Con:
Code
genera>on
overhead
– We
don’t
get
away
from
the
root
cause
of
overhead
– Smallest
compile
unit
is
a
class
with
a
method
– System
dic>onary
locks
– Byte
code
verifica>on
– Various
other
class
registra>on
horrors
• (also
a
problem
in
lambda
forms
or
any
woven
bytecode)
63. Tier
the
JIT?
• Con:
Type
pollu>on
– Too
wide
values
wriken
to
scopes
• Con:
Code
genera>on
overhead
– We
don’t
get
away
from
the
root
cause
of
overhead
– Smallest
compile
unit
is
a
class
with
a
method
– System
dic>onary
locks
– Byte
code
verifica>on
– Various
other
class
registra>on
horrors
• (also
a
problem
in
lambda
forms
or
any
woven
bytecode)
DEAL
BREAKER
64. • It
looks
like
JIT
overhead
is
expensive
• We
don’t
get
close
to
Rhino
interpreter
startup
with
the
>ered
JIT
approach
• We
also
miss
op>mis>c
types
in
scope,
by
never
using
their
narrowest
form
– Has
to
be
corrected
azerwards
– Too
slow
&
complex
Akacking
Startup
&
Warmup
Overhead?
67. AST
profiling?
• Don’t
add
more
bytecode
genera>on
• Execute
AST
once?
– Collect
types
and
use
them
for
first
JIT
if
called
again
• Or
keep
execu>ng
AST
un>l
something
is
hot
–
only
then
send
it
to
the
JIT.
73. Example:
WhileNode
package jdk.nashorn.internal.ir;
public class WhileNode extends LoopNode {
@Override
public Object interpret(final Frame frame) throws Throwable {
final Label label = frame.getCurrentLabel();
Object result = ScriptRuntime.UNDEFINED;
while (test == null || JSType.toBoolean(test.interpret(frame))) {
try {
checkOSR(frame); // Might need to transition to JIT on backedge
result = body.interpret(frame);
} catch (final BreakException e) {
if (e.matchesLabel(label)) {
break;
}
throw e;
} catch (final ContinueException e) {
if (e.matchesLabel(label)) {
continue;
}
throw e; //not my continue
}
}
return result;
}
}
74. CompiledFunction
• Represents
one
version
of
a
JavaScript
or
Na>ve
func>on
– Contains
invoker
method
handle
– Poten>ally
also
constructor
method
handle
– Is
of
a
certain
type
(e.g.
specialized
on
params
or
generic)
• A
ScriptFunctionData
has
>=
0
CompiledFunctions.
75. • Basically
add
a
CompiledFunction
subclass
– InterpretedFunction
Trampolines
76. • Basically
add
a
CompiledFunction
subclass
– InterpretedFunction
– CallNode.interpret
returns
a
ScriptFunc>on
that
is
really
a
trampoline
Trampolines
77. Trampolines
• Basically
add
a
CompiledFunction
subclass
– InterpretedFunction
– CallNode.interpret
returns
a
ScriptFunc>on
that
is
really
a
trampoline
– Trampoline:
“interpret
yourself”
when
invoked
78. Trampolines
• Basically
add
a
CompiledFunction
subclass
– InterpretedFunction
– CallNode.interpret
returns
a
ScriptFunc>on
that
is
really
a
trampoline
– Trampoline:
“interpret
yourself”
when
invoked
• Add
a
Node.interpret(Frame frame)
method
to
the
IR
Node
– Frame
is
an
interpreter
state
(locals/scope)
79. Duplicated
Func>onality?
• But
then
we
need
to
implement
a
lot
of
code
that
already
exists
in
the
JIT
• Just
think
of
reimplemenBng
link
logic
for
all
indy
calls!!!
80. Duplicated
Func>onality?
• But
then
we
need
to
implement
a
lot
of
code
that
already
exists
in
the
JIT
• Just
think
of
reimplemenBng
link
logic
for
all
indy
calls!!!
• And
that’s
just
one
thing!
81. Duplicated
Func>onality?
• But
then
we
need
to
implement
a
lot
of
code
that
already
exists
in
the
JIT
• Just
think
of
reimplemenBng
link
logic
for
all
indy
calls!!!
– Na>ve
calls,
JavaScript
calls,
different
guards,
nested
receiver
checks,
call
site
reuse
– Even
through
Dynalink
– Infeasible
to
duplicate
codegen
logic
for
this
– And
the
tes>ng!
My
god!
82. Reuse
Link
Logic
protected GuardedInvocation findSetMethod(final CallSiteDescriptor desc, final LinkRequest request) {
final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND);
if (request.isCallSiteUnstable() || hasWithScope()) {
return findMegaMorphicSetMethod(desc, name);
}
final boolean explicitInstanceOfCheck = explicitInstanceOfCheck(desc, request);
/*
* If doing property set on a scope object, we should stop proto search on the first
* non-scope object. Without this, for example, when assigning "toString" on global scope,
* we'll end up assigning it on it's proto - which is Object.prototype.toString !!
*
* toString = function() { print("global toString"); } // don't affect Object.prototype.toString
*/
FindProperty find = findProperty(name, true, this);
// If it's not a scope search, then we don't want any inherited properties except those with user defined accessors.
if (find != null && find.isInherited() && !(find.getProperty() instanceof UserAccessorProperty)) {
// We should still check if inherited data property is not writable
if (isExtensible() && !find.getProperty().isWritable()) {
return createEmptySetMethod(desc, explicitInstanceOfCheck, "property.not.writable", true);
}
// Otherwise, forget the found property unless this is a scope callsite and the owner is a scope object as well.
if (!NashornCallSiteDescriptor.isScope(desc) || !find.getOwner().isScope()) {
find = null;
}
}
if (find != null) {
if (!find.getProperty().isWritable() && !NashornCallSiteDescriptor.isDeclaration(desc)) {
if (NashornCallSiteDescriptor.isScope(desc) && find.getProperty().isLexicalBinding()) {
throw typeError("assign.constant", name); // Overwriting ES6 const should throw also in non-strict mode.
}
// Existing, non-writable property
return createEmptySetMethod(desc, explicitInstanceOfCheck, "property.not.writable", true);
}
} else {
if (!isExtensible()) {
return createEmptySetMethod(desc, explicitInstanceOfCheck, "object.non.extensible", false);
}
}
final GuardedInvocation inv = new SetMethodCreator(this, find, desc, equest).createGuardedInvocation(findBuiltinSwitchPoint(name));
final GlobalConstants globalConstants = getGlobalConstants();
if (globalConstants != null) {
final GuardedInvocation cinv = globalConstants.findSetMethod(find, this, inv, desc, request);
if (cinv != null) {
return cinv;
}
}
return inv;
}
Example:
linking
a
set
method
for
a
ScriptObject
83. Reuse
Link
Logic
• Reuse
link
logic?
protected GuardedInvocation findSetMethod(final CallSiteDescriptor desc, final LinkRequest request) {
final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND);
if (request.isCallSiteUnstable() || hasWithScope()) {
return findMegaMorphicSetMethod(desc, name);
}
final boolean explicitInstanceOfCheck = explicitInstanceOfCheck(desc, request);
/*
* If doing property set on a scope object, we should stop proto search on the first
* non-scope object. Without this, for example, when assigning "toString" on global scope,
* we'll end up assigning it on it's proto - which is Object.prototype.toString !!
*
* toString = function() { print("global toString"); } // don't affect Object.prototype.toString
*/
FindProperty find = findProperty(name, true, this);
// If it's not a scope search, then we don't want any inherited properties except those with user defined accessors.
if (find != null && find.isInherited() && !(find.getProperty() instanceof UserAccessorProperty)) {
// We should still check if inherited data property is not writable
if (isExtensible() && !find.getProperty().isWritable()) {
return createEmptySetMethod(desc, explicitInstanceOfCheck, "property.not.writable", true);
}
// Otherwise, forget the found property unless this is a scope callsite and the owner is a scope object as well.
if (!NashornCallSiteDescriptor.isScope(desc) || !find.getOwner().isScope()) {
find = null;
}
}
if (find != null) {
if (!find.getProperty().isWritable() && !NashornCallSiteDescriptor.isDeclaration(desc)) {
if (NashornCallSiteDescriptor.isScope(desc) && find.getProperty().isLexicalBinding()) {
throw typeError("assign.constant", name); // Overwriting ES6 const should throw also in non-strict mode.
}
// Existing, non-writable property
return createEmptySetMethod(desc, explicitInstanceOfCheck, "property.not.writable", true);
}
} else {
if (!isExtensible()) {
return createEmptySetMethod(desc, explicitInstanceOfCheck, "object.non.extensible", false);
}
}
final GuardedInvocation inv = new SetMethodCreator(this, find, desc, equest).createGuardedInvocation(findBuiltinSwitchPoint(name));
final GlobalConstants globalConstants = getGlobalConstants();
if (globalConstants != null) {
final GuardedInvocation cinv = globalConstants.findSetMethod(find, this, inv, desc, request);
if (cinv != null) {
return cinv;
}
}
return inv;
}
Example:
linking
a
set
method
for
a
ScriptObject
84. Reuse
Link
Logic
• Reuse
link
logic?
protected GuardedInvocation findSetMethod(final CallSiteDescriptor desc, final LinkRequest request) {
final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND);
if (request.isCallSiteUnstable() || hasWithScope()) {
return findMegaMorphicSetMethod(desc, name);
}
final boolean explicitInstanceOfCheck = explicitInstanceOfCheck(desc, request);
/*
* If doing property set on a scope object, we should stop proto search on the first
* non-scope object. Without this, for example, when assigning "toString" on global scope,
* we'll end up assigning it on it's proto - which is Object.prototype.toString !!
*
* toString = function() { print("global toString"); } // don't affect Object.prototype.toString
*/
FindProperty find = findProperty(name, true, this);
// If it's not a scope search, then we don't want any inherited properties except those with user defined accessors.
if (find != null && find.isInherited() && !(find.getProperty() instanceof UserAccessorProperty)) {
// We should still check if inherited data property is not writable
if (isExtensible() && !find.getProperty().isWritable()) {
return createEmptySetMethod(desc, explicitInstanceOfCheck, "property.not.writable", true);
}
// Otherwise, forget the found property unless this is a scope callsite and the owner is a scope object as well.
if (!NashornCallSiteDescriptor.isScope(desc) || !find.getOwner().isScope()) {
find = null;
}
}
if (find != null) {
if (!find.getProperty().isWritable() && !NashornCallSiteDescriptor.isDeclaration(desc)) {
if (NashornCallSiteDescriptor.isScope(desc) && find.getProperty().isLexicalBinding()) {
throw typeError("assign.constant", name); // Overwriting ES6 const should throw also in non-strict mode.
}
// Existing, non-writable property
return createEmptySetMethod(desc, explicitInstanceOfCheck, "property.not.writable", true);
}
} else {
if (!isExtensible()) {
return createEmptySetMethod(desc, explicitInstanceOfCheck, "object.non.extensible", false);
}
}
final GuardedInvocation inv = new SetMethodCreator(this, find, desc, equest).createGuardedInvocation(findBuiltinSwitchPoint(name));
final GlobalConstants globalConstants = getGlobalConstants();
if (globalConstants != null) {
final GuardedInvocation cinv = globalConstants.findSetMethod(find, this, inv, desc, request);
if (cinv != null) {
return cinv;
}
}
return inv;
}
Example:
linking
a
set
method
for
a
ScriptObject
85. Link
Logic
• InterpreterAccessor
– IndexNode, AccessNode, IdentNode
– get, set methods
(take
a
Frame)
– interpret
calls
get
– Lookup
delegates
to
findGetMethod,findSetMethod
• InterpreterCall
– Lookup
delegates
to
findCallMethod,findNewMethod
• InterpreterCallable
– interpret,
creates/gets
a
ScriptFunction
• Trampolined
to
call
invoke,
possibly
wormhole
– call method
(actual
invoca>on)
86. Reusing
Link
Logic
package jdk.nashorn.internal.ir;
public class AccessNode extends BaseNode {
@Override
public Object interpret(final Frame frame) throws Throwable {
interpreterEnter(frame);
try {
return get(frame);
} finally {
interpreterLeave(frame);
}
}
@Override
public Object get(final Frame frame, final Object interpretedBase) throws Throwable {
try {
// lookupGetter uses existing ScriptObject/Dynalink link logic (set is analogue)
final CallSite cs = lookupGetter(frame, getterType(), interpretedBase, 0);
final Object value = cs.getTarget().invokeExact(interpretedBase);
return interpreterReturn(frame, value);
} catch (final ECMAException e) {
if (e.hasScriptStackTrace()) { //has stack trace been rewritten
throw e;
}
throw e.rewriteStackTrace(frame);
}
}
}
87. Interpreter?
• The
link
logic
reuse
actually
makes
us
end
up
with
rela>vely
likle
new
code!
• For
most
logic,
we
can
just
use
ScriptObject
and
ScriptRuntime
func>ons
that
already
exist
for
slow
cases
• And
add
type
narrowing
88. Interpreter
Speed;
Observa>ons
• Startup
is
significantly
faster
(even
early
in
the
project)
• But
execu>on
is
5-‐100
>mes
slower
than
execu>ng
op>mized
warmed
up
wriken
code
• We
get
automa>c
type
profiles
before
JIT>ng
• We
need
to
transi>on
from
interpreted
to
JITted
code
fairly
quickly
– Time-‐to-‐steady-‐state
must
not
suffer
from
fast
startup
89. Transi>oning
to
JIT;
Determinism
• Right
now
we
are
using
“number
of
invoca>ons”
as
the
only
JIT
metric
– No
explicit
bytecode
–
MH
return
value
filter
counter
• Tests
are
then
determinis>c
• We
are
rather
aggressive
in
transferring
to
JIT
code
as
– It
doesn’t
take
long
to
do
a
stable
type
profile
(1-‐2
execu>ons)
90. Transi>oning
to
JIT;
Loops
• At
n
backedge
execu>ons,
have
the
interpreter
throw
a
RewriteException
– Contains
in
type
map
(no
new
code)
– Works
just
like
in
the
JIT
for
a
too
wide
type
• Very
likle
code
– Logic
for
all
this
already
exists
in
op>mis>c
JIT
91. Transi>oning
to
JIT;
Loops
• Need
OSR
support
• Reuse
Program
Point
concept
from
op>mis>c
types
• Add
an
“invisible”
op>mis>c
program
point
– LoopNode implements Optimistic
– LoopNode.getProgramPoint()
93. The
Stack
Trace
Problem
• A
stack
trace
is
not
a
special
case
in
the
JIT
– All
bytecode
has
line
number
and
file
name
informa>on
• An
interpreter
would
contain
Node.interpret
methods
instead
of
the
correct
JavaScript
line
numbers
– Need
a
special
case
to
rewrite
stack
traces
from
Interpreter
mode
to
script
code
– Doable
94. The
Stack
Trace
Problem
function f() {
print(a);
}
function g() {
f();
}
g();
95. The
Stack
Trace
Problem
stacktrace.js:2 ReferenceError: "a" is not defined
at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:66)
at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:331)
at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:304)
at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:291)
at jdk.nashorn.internal.runtime.ScriptObject.noSuchProperty(ScriptObject.java:2400)
at jdk.nashorn.internal.runtime.ScriptObject.findGetMethod(ScriptObject.java:2005)
at jdk.nashorn.internal.objects.Global.findGetMethod(Global.java:2428)
at jdk.nashorn.internal.runtime.ScriptObject.lookup(ScriptObject.java:1866)
at jdk.nashorn.internal.runtime.linker.NashornLinker.getGuardedInvocation(NashornLinker.java:104)
at jdk.nashorn.internal.runtime.linker.NashornLinker.getGuardedInvocation(NashornLinker.java:98)
at jdk.internal.dynalink.support.CompositeTypeBasedGuardingDynamicLinker.
getGuardedInvocation(CompositeTypeBasedGuardingDynamicLinker.java:176)
at jdk.internal.dynalink.support.CompositeGuardingDynamicLinker.
getGuardedInvocation(CompositeGuardingDynamicLinker.java:124)
at jdk.internal.dynalink.support.LinkerServicesImpl.getGuardedInvocation(LinkerServicesImpl.java:154)
at jdk.internal.dynalink.DynamicLinker.relink(DynamicLinker.java:253)
at jdk.nashorn.internal.scripts.Script$Recompilation$3$stacktrace.f(stacktrace.js:2)
at jdk.nashorn.internal.scripts.Script$Recompilation$2$31$stacktrace.g(stacktrace.js:5)
at jdk.nashorn.internal.scripts.Script$Recompilation$1$stacktrace.:program(stacktrace.js:7)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:772)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:267)
at jdk.nashorn.internal.runtime.ScriptRuntime.applyThrow(ScriptRuntime.java:434)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:411)
at jdk.nashorn.tools.Shell.apply(Shell.java:410)
at jdk.nashorn.tools.Shell.runScripts(Shell.java:339)
at jdk.nashorn.tools.Shell.run(Shell.java:172)
at jdk.nashorn.tools.Shell.main(Shell.java:136)
at jdk.nashorn.tools.Shell.main(Shell.java:112)
96. The
Stack
Trace
Problem
stacktrace.js:4 ReferenceError: "a" is not defined
at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:66)
at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:331)
at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:304)
at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:291)
at jdk.nashorn.internal.runtime.ScriptObject.noSuchProperty(ScriptObject.java:2400)
at jdk.nashorn.internal.runtime.ScriptObject.findGetMethod(ScriptObject.java:2005)
at jdk.nashorn.internal.objects.Global.findGetMethod(Global.java:2428)
at jdk.nashorn.internal.runtime.ScriptObject.lookup(ScriptObject.java:1866)
at jdk.nashorn.internal.runtime.linker.NashornLinker.getGuardedInvocation(NashornLinker.java:104)
at jdk.nashorn.internal.runtime.linker.NashornLinker.getGuardedInvocation(NashornLinker.java:98)
at jdk.internal.dynalink.support.CompositeTypeBasedGuardingDynamicLinker.getGuardedInvocation(CompositeTypeBasedGuardingDynamicLinker.java:176)
at jdk.internal.dynalink.support.CompositeGuardingDynamicLinker.getGuardedInvocation(CompositeGuardingDynamicLinker.java:124)
at jdk.internal.dynalink.support.LinkerServicesImpl.getGuardedInvocation(LinkerServicesImpl.java:154)
at jdk.internal.dynalink.DynamicLinker.relink(DynamicLinker.java:253)
at jdk.nashorn.internal.ir.IdentNode.get(IdentNode.java:422)
at jdk.nashorn.internal.ir.IdentNode.interpret(IdentNode.java:400)
at jdk.nashorn.internal.runtime.interpreter.Interpreter.interpret(Interpreter.java:395)
at jdk.nashorn.internal.ir.CallNode$1.interpretArguments(CallNode.java:473)
at jdk.nashorn.internal.ir.CallNode$1.execute(CallNode.java:449)
at jdk.nashorn.internal.runtime.interpreter.ExceptionInterpreterOperation.run(ExceptionInterpreterOperation.java:32)
at jdk.nashorn.internal.ir.CallNode.interpret(CallNode.java:640)
at jdk.nashorn.internal.ir.ExpressionStatement.interpret(ExpressionStatement.java:102)
at jdk.nashorn.internal.ir.Block.interpret(Block.java:653)
at jdk.nashorn.internal.ir.FunctionNode.invoke(FunctionNode.java:1486)
at jdk.nashorn.internal.ir.FunctionNode.call(FunctionNode.java:1519)
at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:625)
at jdk.nashorn.internal.ir.CallNode$1.invokeCallSite(CallNode.java:511)
at jdk.nashorn.internal.ir.CallNode$1.execute(CallNode.java:449)
at jdk.nashorn.internal.runtime.interpreter.ExceptionInterpreterOperation.run(ExceptionInterpreterOperation.java:32)
at jdk.nashorn.internal.ir.CallNode.interpret(CallNode.java:640)
at jdk.nashorn.internal.ir.ExpressionStatement.interpret(ExpressionStatement.java:102)
at jdk.nashorn.internal.ir.Block.interpret(Block.java:653)
at jdk.nashorn.internal.ir.FunctionNode.invoke(FunctionNode.java:1486)
at jdk.nashorn.internal.ir.FunctionNode.call(FunctionNode.java:1519)
at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:625)
at jdk.nashorn.internal.ir.CallNode$1.invokeCallSite(CallNode.java:511)
at jdk.nashorn.internal.ir.CallNode$1.execute(CallNode.java:449)
at jdk.nashorn.internal.runtime.interpreter.ExceptionInterpreterOperation.run(ExceptionInterpreterOperation.java:32)
at jdk.nashorn.internal.ir.CallNode.interpret(CallNode.java:640)
at jdk.nashorn.internal.ir.BinaryNode.interpret(BinaryNode.java:633)
at jdk.nashorn.internal.ir.ExpressionStatement.interpret(ExpressionStatement.java:102)
at jdk.nashorn.internal.ir.Block.interpret(Block.java:653)
at jdk.nashorn.internal.ir.FunctionNode.invoke(FunctionNode.java:1486)
at jdk.nashorn.internal.ir.FunctionNode.call(FunctionNode.java:1519)
at jdk.nashorn.internal.runtime.interpreter.InterpreterCallable.wormholeInterpreterCall(InterpreterCallable.java:101)
at jdk.nashorn.internal.scripts.Wormhole$=stacktrace,js.wormholeInterpreterCall(stacktrace.js:4)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:763)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:267)
at jdk.nashorn.internal.runtime.ScriptRuntime.applyThrow(ScriptRuntime.java:434)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:411)
at jdk.nashorn.tools.Shell.apply(Shell.java:410)
at jdk.nashorn.tools.Shell.runScripts(Shell.java:339)
at jdk.nashorn.tools.Shell.run(Shell.java:172)
at jdk.nashorn.tools.Shell.main(Shell.java:136)
at jdk.nashorn.tools.Shell.main(Shell.java:112)
97. The
Stack
Trace
Problem
stacktrace.js:2 ReferenceError: "a" is not defined
at jdk.nashorn.internal.objects.Global.findGetMethod(Global.java:2428)
at jdk.internal.dynalink.support.CompositeTypeBasedGuardingDynamicLinker.
getGuardedInvocation(CompositeTypeBasedGuardingDynamicLinker.java:176)
at jdk.internal.dynalink.support.CompositeGuardingDynamicLinker.
getGuardedInvocation(CompositeGuardingDynamicLinker.java:124)
at jdk.internal.dynalink.support.LinkerServicesImpl.getGuardedInvocation(LinkerServicesImpl.java:154)
at jdk.internal.dynalink.DynamicLinker.relink(DynamicLinker.java:253)
at jdk.nashorn.internal.scripts.Script$Interpreted$.f(stacktrace.js:2)
at jdk.nashorn.internal.scripts.Script$Interpreted$.g(stacktrace.js:5)
at jdk.nashorn.internal.scripts.Script$Interpreted$.:program(stacktrace.js:7)
at jdk.nashorn.tools.Shell.apply(Shell.java:410)
at jdk.nashorn.tools.Shell.runScripts(Shell.java:339)
at jdk.nashorn.tools.Shell.run(Shell.java:172)
at jdk.nashorn.tools.Shell.main(Shell.java:136)
at jdk.nashorn.tools.Shell.main(Shell.java:112)
98. The
Stack
Trace
Problem
• Any
NativeError
trace
passed
out
of
the
interpreter
needs
to
be
trapped
in
e.g.
FunctionNode.interpret
and
poten>ally
rewriken
99. The
Stack
Trace
Problem
• Any
NativeError
trace
passed
out
of
the
interpreter
needs
to
be
trapped
in
e.g.
FunctionNode.interpret
and
poten>ally
rewriken
• nasgen
tool
needs
to
support
Interpreter
state
in
some
cases,
NativeError
– Added
@needsInterpreterFrame=[true|false] annota>on
100. Security
Problems
• The
JIT
code
uses
a
MethodHandles.lookup()
reachable
only
from
jdk.nashorn.internal.scripts package.
101. Security
Problems
• The
JIT
code
uses
a
MethodHandles.lookup()
reachable
only
from
jdk.nashorn.internal.scripts package.
• If
we
use
a
lookup
from
the
IR
package,
it
is
too
privileged
– The
Interpreter
needs
a
Source.getLookup()
method
that
returns
the
restricted
lookup.
– Lookup
is
wriken
to
Source,
whenever
we
enter
a
source
we
haven’t
found
before,
through
a
“wormhole”
in
the
script
package.
102. Security
Problems
• The
JIT
code
uses
a
MethodHandles.lookup()
reachable
only
from
jdk.nashorn.internal.scripts package.
• If
we
use
a
lookup
from
the
IR
package,
it
is
too
privileged
– The
Interpreter
needs
a
Source.getLookup()
method
that
returns
the
restricted
lookup.
– Lookup
is
wriken
to
Source,
whenever
we
enter
a
source
we
haven’t
found
before,
through
a
“wormhole”
in
the
script
package.
• One
wormhole
method
per
Source
is
all
that’s
required
103. Security
Problems
public static wormholeInterpreterCall(InterpreterCallable;Frame;ScriptFunction;Object;[Object;)Object;
0 aload 0
1 invokeinterface InterpreterCallable.getSource()Source;
6 dup
// CHECK IF SOURCE ALREADY HAS LOOKUP
7 invokevirtual Source.hasLookup()Z
10 ifne 22
// NO – GET ONE WITH SCRIPT PACKAGE PRIVILEGE
13 invokestatic MethodHandles.lookup()MethodHandles$Lookup;
16 invokevirtual Source.setLookup(MethodHandles$Lookup;)V
19 goto 23
22 pop
// MARSHALL PARAMETERS TO READ INVOCATION
23 aload 0
24 aload 1
25 aload 2
26 aload 3
27 aload 4
29 invokestatic InterpreterCallable.wormholeInterpreterCall
(InterpreterCallable;Frame;ScriptFunction;Object;[Object;)Object;
32 areturn
105. Avoiding
too
much
link
>me
• CallSite
caching
• Can
actually
be
used
to
solve
problems
that
we
don’t
detect
in
the
JIT
function f() {
g(); //new bootstrap/lookup, store in cache
g(); //no need to link separately, reuse g()
g(); // -”-
g(); // -”-
g(); // -”-
g = function() { return 17; } //invalidate
g(); //new bootstrap/lookup
}
106. Run>me
overhead
• Add
known
set
of
specialized,
non
invalidated
CallSites
already
linked
in
current
scope
• InterpreterAccessor
– isCachedCallSite(…)
• InterpreterCall
– isCachedCallSite(…)
107. “Code
Shape
Overhead”
–
Program
Points
• Nashorn
concept:
program
point
• Used
to
iden>fy
a
program
point
in
a
method
when
re-‐JITTING?
• A
lot
of
JIT
only
transforms
change
code
shape
– Spli€ng,
Inlining
Finallies,
Folding
(interpreter
doesn’t
need
that)
– Program
points
are
assigned
very
late
108. “Code
Shape
Overhead”
–
Program
Points
• Should
avoid
JIT
only
transforms
in
interpreted
mode
for
speed
– Spli€ng,
Lowering
etc
• S>ll
need
to
preserve
code
shape
to
correctly
map
program
point
informa>on
• Alterna>ve
“fuzzier”
program
point
representa>on
– Tuple
(#
in
expression,
source
posi>on)?
109. Background
Processing
• This
a
main
strength
with
two
code
execu>on
environments
• We
can
do
(even
specula>ve)
JIT>ng
in
the
background
early
• Even
(non
explicit)
mul>threaded
if
we
want
– Balancing
heuris>cs
• java.util.concurrent.Future<CompiledFunction>
111. Current
Results
• Tests
are
clean
• We
are
JavaScript
compliant
in
“interpreter
only”
and
“mixed”
modes.
• Startup
performance
is
significantly
beker
than
before
• Ini>al
footprint
/
code
genera>on
>me
is
much
lower
– It
is
important
to
go
to
JIT
quickly
– Type
info
is
usually
already
correct
112. JEP
• A
JEP
is
coming,
and
is
moving
through
the
process
• Will
be
made
public
shortly
119. Call
and
Alloca>on
Site
Profiling
• Execu>on
Overhead
– Alloca>on
site
profiling
– Call
site
profiling
120. Alloca>on
Profiling
• Simple
to
do
• Eliminate
op>mis>c
data
structure
invalida>ons
function vector() {
return new Array(); //defaults to optimistic int
}
var vectors = [];
for (var i = 0; i < 1e6; i++) {
vectors.push(new vector().push(“string”));
}
121. Par>al
Compila>on
• Par>al
compila>on
• Reuse
compiled
Nodes*
– Hang
on
to
MethodHandles
by
“Signature”
• Parameter
types
• Parameter
values
– A
loss
let
code
*
PotenBal
path
profile
polluBon
issues
that
need
to
be
worked
around,
similar
to
as
in
LambdaForm
caching
122. package jdk.nashorn.internal.ir;
public abstract class Node {
protected WeakHashMap<Signature, MethodHandle> code;
// …
public abstract Object interpret(Frame frame);
// …
}
Par>al
Compila>on
123. package jdk.nashorn.internal.ir;
public abstract class Node {
protected WeakHashMap<Signature, MethodHandle> code;
// …
public abstract Object interpret(Frame frame);
// …
}
Par>al
Compila>on
124. Par>al
Compila>on
• Enables
par>al
evalua>on
– with
MethodHandles.constant
and
MethodHandle
combinators
– Truffle
style
behavior
without
requiring
a
modified
VM
125. The
Peeks
and
The
Pokes
(but
safely)
• Not
interpreter
specific
• VarHandles
– Fast
gekers
and
sekers
– No
extra
storage
for
primi>ve/object
versions
– No
bounds
checks
(e.g.
spill
pool,
ArrayData,
TypedArrays
–
who
needs
Unsafe?)
– (sun.misc.TaggedArray)
126. JFR
Integra>on;
Events
• Dynalink
– Relinking
callsites
– Megamorhic
callsites
• Language
agnos>c
– Mul>
language
data
generated
– Type
changes
• Language
specific
– Array
like
object
layout,
packed
/
sparse
– ScriptObject
layouts
127. Parallelism
• The
more
cores,
the
more
we
can
specula>vely
work
(e.g.
JIT)
in
the
background
• Specula>ve
parallel
background
processing
• java.util.concurrent.Future<CompiledFunction>
128. Leveraging
JDK
Changes
• Improvements
and
speedups
of
java.lang.invoke
• Improvements
(or
removal)
of
LambdaForms
• We
Project
Valhalla,
we
think
– VarHandles
complete
– The
minimum
compile
unit
-‐
can
it
shrink?
• Could
spring
from
ClassDynamic?
129. Research
• Mul>
language
framework
– Mul>
Pla‚orm
Typeless
IR
(JRuby
9000
style)
– TypeScript
• “On
implemen>ng
mul>ple
pluggable
dynamic
language
frontends
on
the
JVM,
using
the
Nashorn
run>me”
[Gabrielsson,
Lagergren,
Szegedi]
• Pluggable
VM
frontends