Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Issue 11444008: Save a handle allocation in two accessor functions of class Type. (Closed)

Created:
8 years ago by Florian Schneider
Modified:
8 years ago
Reviewers:
srdjan, Ivan Posva
CC:
reviews_dartlang.org, vm-dev_dartlang.org
Visibility:
Public.

Description

Save a handle allocation in two accessor functions of class Type. The ASSERT already makes sure, that we have the correct type at hand. Committed: https://code.google.com/p/dart/source/detail?r=15775

Patch Set 1 #

Patch Set 2 : #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats (+4 lines, -8 lines) Patch
M runtime/vm/object.cc View 1 1 chunk +4 lines, -8 lines 6 comments Download

Messages

Total messages: 5 (0 generated)
Florian Schneider
Type::type_class shows up on the profile when running dart2js in checked mode.
8 years ago (2012-12-05 15:07:12 UTC) #1
srdjan
lgtm
8 years ago (2012-12-05 20:02:44 UTC) #2
Ivan Posva
Please come up with an alternative and safe proposal. -Ivan https://codereview.chromium.org/11444008/diff/3001/runtime/vm/object.cc File runtime/vm/object.cc (right): https://codereview.chromium.org/11444008/diff/3001/runtime/vm/object.cc#newcode8715 ...
8 years ago (2012-12-07 17:17:30 UTC) #3
Florian Schneider
https://codereview.chromium.org/11444008/diff/3001/runtime/vm/object.cc File runtime/vm/object.cc (right): https://codereview.chromium.org/11444008/diff/3001/runtime/vm/object.cc#newcode8715 runtime/vm/object.cc:8715: return reinterpret_cast<RawClass*>(raw_ptr()->type_class_); On 2012/12/07 17:17:31, Ivan Posva wrote: > ...
8 years ago (2012-12-10 16:11:27 UTC) #4
Ivan Posva
8 years ago (2012-12-10 17:13:42 UTC) #5
Message was sent while issue was closed.
I will help you come up with an acceptable pattern for these kinds of
optimizations.

-Ivan

https://codereview.chromium.org/11444008/diff/3001/runtime/vm/object.cc
File runtime/vm/object.cc (right):

https://codereview.chromium.org/11444008/diff/3001/runtime/vm/object.cc#newco...
runtime/vm/object.cc:8715: return
reinterpret_cast<RawClass*>(raw_ptr()->type_class_);
On 2012/12/10 16:11:27, Florian Schneider wrote:
> On 2012/12/07 17:17:31, Ivan Posva wrote:
> > I do not like the approach taken here. It should be safe in at least debug
> mode,
> > giving us the same protection which using the handle does. This pattern here
> > does not qualify.
> 
> What protection do you want here? The caller has to wrap the raw pointer in a
> handle anyway, so all asserts in handle-initialization will be done there.

Please note that since you are returning a RawClass* here, that there is no
further protection (or checking) if the caller associates this with a Class
handle. This has been a deliberate decision, as we need to be able to trust the
return types of calls.

> I don't see much benefit of creating a handle here, just for asserting.

I did not say that you needed to create a handle here in the non-debug case.

https://codereview.chromium.org/11444008/diff/3001/runtime/vm/object.cc#newco...
runtime/vm/object.cc:8722: return
reinterpret_cast<RawUnresolvedClass*>(raw_ptr()->type_class_);
On 2012/12/10 16:11:27, Florian Schneider wrote:
> On 2012/12/07 17:17:31, Ivan Posva wrote:
> > ditto + the check for HasResolvedTypeClass() has disappeared.
> 
> Sure, I can re-insert the assert, but it is redundant wrt the asserts I added.

Type::HasResolvedType() conveys a completely different meaning from the
type_class_ field containing an object of type UnresolvedClass. It might be that
this is currently the case, but relying on that fact here makes me nervous.

Powered by Google App Engine
This is Rietveld 408576698