https://codereview.chromium.org/1288773007/diff/40001/src/ast-expression-visitor.h
File src/ast-expression-visitor.h (right):

https://codereview.chromium.org/1288773007/diff/40001/src/ast-expression-visitor.h#newcode26
src/ast-expression-visitor.h:26: void* operator new(size_t size, Zone*
zone) { return zone->New(size); }
On 2015/08/20 04:01:40, bradn wrote:
On 2015/08/19 12:06:37, titzer wrote:
> I don't think you want to define your own new here. I think you want
to extend
> ZoneObject and use "new (zone)". It's not safer, but it's the V8
way.

Not groking. But maybe I'm missing something basic :-)

I can't inherit from ZoneObject without doing multiple inheritance
here, as I
need to inherit from AstVisitor. Also, AstVisitor inherits from
Embedded, which
in debug mode has a clashing operator new.

Currently this inlines ZoneObject in this class, so for instance in
TypingReseter::Run() I can do new (zone).
Or are you suggesting I do placement new there, ie:
new (zone->New(sizeof(TypingReseter))) TypingReseter ?

FWIW, this is the pattern used in typing.h and a few other places.

Honestly, I don't know why typing.h does that. Why would one want to
store a visitor on the heap? You can just have it on the stack, as in

TypingReseter visitor(info);
visitor.VisitAll();

or even

TypingReseter(info).VisitAll();

https://codereview.chromium.org/1288773007/diff/140001/src/typing-reset.cc
File src/typing-reset.cc (right):

https://codereview.chromium.org/1288773007/diff/140001/src/typing-reset.cc#newcode22
src/typing-reset.cc:22: TypingReseter* visitor = new (info->zone())
TypingReseter(info);
No need to heap-allocate the visitor, AFAICT.

https://codereview.chromium.org/1288773007/diff/140001/test/cctest/expression-type-collector.cc
File test/cctest/expression-type-collector.cc (right):

https://codereview.chromium.org/1288773007/diff/140001/test/cctest/expression-type-collector.cc#newcode32
test/cctest/expression-type-collector.cc:32: ExpressionTypeCollector*
visitor =
Same here, no reason for heap allocation.

https://codereview.chromium.org/1288773007/diff/140001/test/cctest/expression-type-collector.h
File test/cctest/expression-type-collector.h (right):

https://codereview.chromium.org/1288773007/diff/140001/test/cctest/expression-type-collector.h#newcode13
test/cctest/expression-type-collector.h:13: // Macros to define checking
of a tree walk.
That's some fancy macro fu there! :)

https://codereview.chromium.org/1288773007/

--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to