Skip to content

Instantly share code, notes, and snippets.

@Constellation
Created September 15, 2011 23:45
Show Gist options
  • Select an option

  • Save Constellation/1220820 to your computer and use it in GitHub Desktop.

Select an option

Save Constellation/1220820 to your computer and use it in GitHub Desktop.
V8の実装は,
StringがSeqString or ConsString
Consはleft / rightのStringへのptrを持っているという形, つまり,
"STRING" + "STR" + "STR2"
はparse時連結をしないとすると,
ConsString -> first ConsString -> first SeqString["STRING"]
-> second SeqString["STR"]
-> second SeqString["STR2"]
となります.
連結時は, これを再帰的にめぐることで連結できます. objects-inl.h / objects.cc
これを平たくするのを, Flatというので, Flatでgrepかけると「ああー」というのが見れます.
JSCは
JSString 3 slots
[ RopeOrFiber RopeOrFiber RopeOrFiber ]
で, RopeはRopeOrFiberの配列を持っているという形です.
Fiberは単なるStringです. 3段重ねです. 例えば,
"S1" + "S2" + "S3" + "S4" + "S5" + "S6;
の場合,
JSString
[
Rope => ["S1" "S2" "S3" "S4"]
Fiber=>"S5"
Fiber=>"S6"
]
となります.
lv5はJSCの実装を参考に実装しています.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment