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

Issue 10450014: Request for comments on overall approach. (Closed)

Created:
8 years, 7 months ago by Vyacheslav Egorov (Google)
Modified:
8 years, 6 months ago
Reviewers:
siva, Ivan Posva
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Remove RawObject::class_ field. Request for comments on overall approach. Disregard changes in x64 related files (look at ia32 only and platform independent ones). Contains some hacks and code duplication that are known, and will be addressed. I will work on splitting this CL into pieces when I am ready to commit it. NOT FOR COMMIT BUG= TEST=

Patch Set 1 #

Patch Set 2 : fix GenerateNArgsCheckInlineCacheStub #

Patch Set 3 : fix scavenger and freelist handler #

Patch Set 4 : fix scavenger and freelist handling #

Total comments: 19
Unified diffs Side-by-side diffs Delta from patch set Stats (+307 lines, -306 lines) Patch
M runtime/vm/assembler_ia32.h View 1 chunk +13 lines, -0 lines 2 comments Download
M runtime/vm/assembler_ia32.cc View 1 chunk +30 lines, -0 lines 0 comments Download
M runtime/vm/assembler_macros_ia32.cc View 1 chunk +1 line, -3 lines 0 comments Download
M runtime/vm/assembler_macros_x64.cc View 1 chunk +0 lines, -3 lines 0 comments Download
M runtime/vm/class_table.h View 2 chunks +5 lines, -0 lines 0 comments Download
M runtime/vm/code_generator_ia32.cc View 8 chunks +24 lines, -26 lines 0 comments Download
M runtime/vm/flow_graph_compiler_x64.cc View 7 chunks +10 lines, -10 lines 0 comments Download
M runtime/vm/freelist.h View 1 2 1 chunk +12 lines, -24 lines 2 comments Download
M runtime/vm/freelist.cc View 1 2 3 chunks +6 lines, -16 lines 0 comments Download
M runtime/vm/gc_marker.cc View 1 chunk +2 lines, -1 line 3 comments Download
M runtime/vm/heap.cc View 1 chunk +2 lines, -1 line 0 comments Download
M runtime/vm/intrinsifier_ia32.cc View 6 chunks +8 lines, -26 lines 0 comments Download
M runtime/vm/isolate.h View 1 chunk +3 lines, -0 lines 0 comments Download
M runtime/vm/object.h View 1 5 chunks +10 lines, -8 lines 2 comments Download
M runtime/vm/object.cc View 1 2 7 chunks +14 lines, -15 lines 2 comments Download
M runtime/vm/opt_code_generator_ia32.cc View 11 chunks +15 lines, -21 lines 2 comments Download
M runtime/vm/raw_object.h View 1 2 4 chunks +13 lines, -2 lines 4 comments Download
M runtime/vm/raw_object.cc View 1 2 8 chunks +23 lines, -20 lines 2 comments Download
M runtime/vm/raw_object_snapshot.cc View 48 chunks +73 lines, -55 lines 0 comments Download
M runtime/vm/scavenger.cc View 1 2 1 chunk +3 lines, -3 lines 0 comments Download
M runtime/vm/snapshot.h View 1 chunk +5 lines, -3 lines 0 comments Download
M runtime/vm/snapshot.cc View 7 chunks +22 lines, -9 lines 0 comments Download
M runtime/vm/stub_code_ia32.cc View 1 13 chunks +9 lines, -34 lines 0 comments Download
M runtime/vm/stub_code_x64.cc View 10 chunks +4 lines, -26 lines 0 comments Download

Messages

Total messages: 5 (0 generated)
Vyacheslav Egorov (Google)
Ivan & Siva, Here is promised CL with what I have now with regards to ...
8 years, 7 months ago (2012-05-24 12:29:34 UTC) #1
Vyacheslav Egorov (Google)
minor update: fixed register usage GenerateNArgsCheckInlineCacheStub [ideally I would like to store class id instead ...
8 years, 7 months ago (2012-05-24 13:36:19 UTC) #2
Vyacheslav Egorov (Google)
another minor update: we are down to one failure (that looks like a bug in ...
8 years, 7 months ago (2012-05-24 15:57:00 UTC) #3
Ivan Posva
First round of comments. I am sure Siva has some on the snapshotting code. -Ivan ...
8 years, 7 months ago (2012-05-26 04:34:46 UTC) #4
Vyacheslav Egorov (Google)
8 years, 7 months ago (2012-05-26 16:48:22 UTC) #5
Thanks for the initial comments!

I will start splitting CLs: first CL would be changes in IA32 code generation
(macros, etc). I will revert changes in codegen in places where class_ was
initialized.

https://chromiumcodereview.appspot.com/10450014/diff/7001/runtime/vm/assemble...
File runtime/vm/assembler_ia32.h (right):

https://chromiumcodereview.appspot.com/10450014/diff/7001/runtime/vm/assemble...
runtime/vm/assembler_ia32.h:538: void CompareClassOf(Register object, const
Class& clazz, Register scratch);
On 2012/05/26 04:34:46, Ivan Posva wrote:
> When do you ever have to compare classes? Or asked differently: In which
> situation are classids not good enough?

This macros was introduced initially to cover a very common code pattern that
loads class and then compares to some constant. 

This does compare class ids internally. 

I can expand it in places where it is used but it seems cleaner when it's
collapsed.

https://chromiumcodereview.appspot.com/10450014/diff/7001/runtime/vm/freelist.h
File runtime/vm/freelist.h (right):

https://chromiumcodereview.appspot.com/10450014/diff/7001/runtime/vm/freelist...
runtime/vm/freelist.h:56: uword next_;
On 2012/05/26 04:34:46, Ivan Posva wrote:
> I don't think this works. How do you plan to iterate over the heap? The first
> word needs exactly the same header layout as RawObject for that to work. The
> nice part is that for most free objects the header word already contains the
> size so you can use the second word for next and a third word for size iff the
> size in the header cannot fit the size of the free object.

Yes it does have exactly the same layout as RawObject: I removed class_ from
RawObject so class_ has to be removed from here (interesting thing was that
there were absolutely no assertions verifying layout match. I added one now).

Iteration works as follows: first word in all objects now is tags_. When
calculating class based on tags_ we check for free bit and if it is present we
return FreeListElement class. 

When calculating size we just always look at the size_ (second word) because now
we have enough space in the header to put it there.

> nice part is that for most free objects the header word already contains the
> size

Sorry, I am not following here. next_ field was always destroying tags_ entirely
--- so there was not size encoded in tags for objects bigger than 2 words ->
iteration always had to take it from the size_ field. Current implementation of
RawObject::Size() checks for FreeBit and falls through to SizeFromClass in this
case; I did not even need to change it.

https://chromiumcodereview.appspot.com/10450014/diff/7001/runtime/vm/gc_marke...
File runtime/vm/gc_marker.cc (right):

https://chromiumcodereview.appspot.com/10450014/diff/7001/runtime/vm/gc_marke...
runtime/vm/gc_marker.cc:152: MarkObject(raw_class);
On 2012/05/26 04:34:46, Ivan Posva wrote:
> How about
> MarkClass(raw_obj->ClassId());
> or something similar? Within the MarkingVisitor we already have the isolate
> handy by way of heap so it should be much cheaper than looking it up during
> raw_obj->GetClass().

Nice idea. Will do.

https://chromiumcodereview.appspot.com/10450014/diff/7001/runtime/vm/object.cc
File runtime/vm/object.cc (right):

https://chromiumcodereview.appspot.com/10450014/diff/7001/runtime/vm/object.c...
runtime/vm/object.cc:6298: void Code::FindAndPrint(uword pc) {
On 2012/05/26 04:34:46, Ivan Posva wrote:
> ?

This is a very useful helper method for debugging. If you have a crash in native
code it is easy to do: 

p dart::Code::FindAndPrint($pc)

to get the whole function (with comments). saves a lot of typing. 

I will obviously submit it as an entirely separate CL.

or I can try to write GDB macros, but having it right in the C++ has the
benefit: if we change something in Code/Instructions we will most definitely
forget to update GDB macros, but this guy will always stay updated.

https://chromiumcodereview.appspot.com/10450014/diff/7001/runtime/vm/object.h
File runtime/vm/object.h (right):

https://chromiumcodereview.appspot.com/10450014/diff/7001/runtime/vm/object.h...
runtime/vm/object.h:4887: return raw_->GetClass();
On 2012/05/26 04:34:46, Ivan Posva wrote:
> Please no functionality on RawObjects.

ok. There is RawObject::Size so I assumed that RawObject::GetClass would be also
fine. 

will fix.

https://chromiumcodereview.appspot.com/10450014/diff/7001/runtime/vm/opt_code...
File runtime/vm/opt_code_generator_ia32.cc (right):

https://chromiumcodereview.appspot.com/10450014/diff/7001/runtime/vm/opt_code...
runtime/vm/opt_code_generator_ia32.cc:1425: __ CompareClassId(EAX, cls);
On 2012/05/26 04:34:46, Ivan Posva wrote:
> Not sure about others, but I find this more readable:
> __ cmpl(EAX, Immediate(cls.index()));

ok. I will inline them. I agree that macros does not buy as anything in this
case. I introduced it only because I wanted to be able to quickly find places
where I compare loaded class ids.

https://chromiumcodereview.appspot.com/10450014/diff/7001/runtime/vm/raw_obje...
File runtime/vm/raw_object.h (right):

https://chromiumcodereview.appspot.com/10450014/diff/7001/runtime/vm/raw_obje...
runtime/vm/raw_object.h:320: return GetClass(ptr()->tags_);
On 2012/05/26 04:34:46, Ivan Posva wrote:
> If anything then all we should have here is GetClassId().

Will do.

https://chromiumcodereview.appspot.com/10450014/diff/7001/runtime/vm/raw_obje...
runtime/vm/raw_object.h:323: static RawClass* GetClass(uword tags);
On 2012/05/26 04:34:46, Ivan Posva wrote:
> Does not belong here. Please move to Object, or ClassTable.

Will do.

Powered by Google App Engine
This is Rietveld 408576698