Removed a bunch of GetExistingThreadLocal calls by threading the Isolate. (issue 11412007)

13 views
Skip to first unread message

sven...@chromium.org

unread,
Nov 15, 2012, 11:09:26 AM11/15/12
to mstar...@chromium.org, v8-...@googlegroups.com
Reviewers: Michael Starzinger,

Description:
Removed a bunch of GetExistingThreadLocal calls by threading the Isolate.

For Octane, the number of calls go down from 7341629 to 1947880, i.e. they
are
reduced by more than 73%. TLS access is not especially cheap, so this
exercise
seems worthwhile.


Please review this at https://codereview.chromium.org/11412007/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
M src/api.cc
M src/arm/full-codegen-arm.cc
M src/factory.cc
M src/handles.h
M src/hydrogen.cc
M src/ia32/full-codegen-ia32.cc
M src/ic-inl.h
M src/ic.cc
M src/mips/full-codegen-mips.cc
M src/objects.h
M src/objects.cc
M src/parser.cc
M src/runtime.cc
M src/stub-cache.cc
M src/type-info.cc
M src/variables.h
M src/x64/full-codegen-x64.cc


mstar...@chromium.org

unread,
Nov 15, 2012, 4:24:25 PM11/15/12
to sven...@chromium.org, v8-...@googlegroups.com
LGTM if comments are addressed.


https://codereview.chromium.org/11412007/diff/2001/src/factory.cc
File src/factory.cc (right):

https://codereview.chromium.org/11412007/diff/2001/src/factory.cc#newcode1422
src/factory.cc:1422: Handle<Object> instance_template =
Handle<Object>(desc->instance_template(),
Use the handle constructor, that's easier to read I think.

Handle<Object> instance_template(desc->instance_template(), isolate());

https://codereview.chromium.org/11412007/diff/2001/src/hydrogen.cc
File src/hydrogen.cc (right):

https://codereview.chromium.org/11412007/diff/2001/src/hydrogen.cc#newcode3240
src/hydrogen.cc:3240: Handle<Object>
maybe_type_info(unoptimized_code->type_feedback_info(),
I know this isn't your change, it must be something pretty recent. But I
really don't like this maybe-handle pattern. The following is much
easier to read and doesn't need an explicit isolate parameter.

Handle<TypeFeedbackInfo> type_info(
TypeFeedbackInfo::cast(unoptimized_code->type_feedback_info()));

https://codereview.chromium.org/11412007/diff/2001/src/hydrogen.cc#newcode7119
src/hydrogen.cc:7119: Handle<Object>
maybe_type_info(unoptimized_code->type_feedback_info(),
Likewise.

https://codereview.chromium.org/11412007/diff/2001/src/runtime.cc
File src/runtime.cc (right):

https://codereview.chromium.org/11412007/diff/2001/src/runtime.cc#newcode3156
src/runtime.cc:3156: Handle<String>
empty_string(isolate->heap()->empty_string());
Just use "Handle<String> empty_string =
isolate->factory()->empty_string();" here, saves the handle allocation
completely.

https://codereview.chromium.org/11412007/

sven...@chromium.org

unread,
Nov 16, 2012, 3:24:36 AM11/16/12
to mstar...@chromium.org, v8-...@googlegroups.com
Landing...


https://codereview.chromium.org/11412007/diff/2001/src/factory.cc
File src/factory.cc (right):

https://codereview.chromium.org/11412007/diff/2001/src/factory.cc#newcode1422
src/factory.cc:1422: Handle<Object> instance_template =
Handle<Object>(desc->instance_template(),
On 2012/11/15 21:24:25, Michael Starzinger wrote:
> Use the handle constructor, that's easier to read I think.

> Handle<Object> instance_template(desc->instance_template(),
isolate());

Done. In general I like the proposed direct initialization much more,
too, because it is conceptually simpler: It is similar to a normal
function call with the usual overloading resolution, just for
constructors. The previous code uses copy initialization, which is much
more tricky: Conceptually it tries to create a temporary of the type of
the LHS (possibly involving conversion functions/operators) and uses a
copy constructor to move the values into the LHS. Luckily enough, GCC is
clever enough to avoid the intermediate steps, but why should we make
things more complicated than necessary? :-)

https://codereview.chromium.org/11412007/diff/2001/src/hydrogen.cc
File src/hydrogen.cc (right):

https://codereview.chromium.org/11412007/diff/2001/src/hydrogen.cc#newcode3240
src/hydrogen.cc:3240: Handle<Object>
maybe_type_info(unoptimized_code->type_feedback_info(),
On 2012/11/15 21:24:25, Michael Starzinger wrote:
> I know this isn't your change, it must be something pretty recent. But
I really
> don't like this maybe-handle pattern. The following is much easier to
read and
> doesn't need an explicit isolate parameter.

> Handle<TypeFeedbackInfo> type_info(
> TypeFeedbackInfo::cast(unoptimized_code->type_feedback_info()));

Done.

https://codereview.chromium.org/11412007/diff/2001/src/hydrogen.cc#newcode7119
src/hydrogen.cc:7119: Handle<Object>
maybe_type_info(unoptimized_code->type_feedback_info(),
On 2012/11/15 21:24:25, Michael Starzinger wrote:
> Likewise.

Done.

https://codereview.chromium.org/11412007/diff/2001/src/runtime.cc
File src/runtime.cc (right):

https://codereview.chromium.org/11412007/diff/2001/src/runtime.cc#newcode3156
src/runtime.cc:3156: Handle<String>
empty_string(isolate->heap()->empty_string());
On 2012/11/15 21:24:25, Michael Starzinger wrote:
> Just use "Handle<String> empty_string =
isolate->factory()->empty_string();"
> here, saves the handle allocation completely.

Done.

https://codereview.chromium.org/11412007/
Reply all
Reply to author
Forward
0 new messages