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

Issue 6991007: Don't flatten every time we call CharCodeAt

Created:
9 years, 7 months ago by Lasse Reichstein
Modified:
9 years, 7 months ago
CC:
v8-dev
Visibility:
Public.

Description

Don't flatten every time we call CharCodeAt Add String->GetMayFlatten(int) that tries to get a character and may flatten. This uses an isolate global counter to flatten at regular intervals, instead of doing it every time.

Patch Set 1 #

Total comments: 2

Patch Set 2 : Added depth-of-cons heuristic #

Patch Set 3 : Handle flat cons string. Flatten entire string. #

Total comments: 5
Unified diffs Side-by-side diffs Delta from patch set Stats (+137 lines, -27 lines) Patch
M src/handles.h View 2 chunks +4 lines, -1 line 0 comments Download
M src/handles.cc View 2 chunks +9 lines, -1 line 0 comments Download
M src/isolate.h View 1 2 chunks +11 lines, -0 lines 0 comments Download
M src/isolate.cc View 1 chunk +2 lines, -1 line 0 comments Download
M src/objects.h View 1 2 6 chunks +28 lines, -9 lines 0 comments Download
M src/objects.cc View 1 2 3 chunks +40 lines, -2 lines 2 comments Download
M src/objects-inl.h View 1 2 4 chunks +41 lines, -1 line 3 comments Download
M src/runtime.cc View 2 chunks +2 lines, -12 lines 0 comments Download

Messages

Total messages: 5 (0 generated)
Lasse Reichstein
9 years, 7 months ago (2011-05-10 11:50:32 UTC) #1
Vitaly Repeshko
http://codereview.chromium.org/6991007/diff/1/src/objects.cc File src/objects.cc (right): http://codereview.chromium.org/6991007/diff/1/src/objects.cc#newcode5214 src/objects.cc:5214: if (this->GetIsolate()->ShouldFlattenString()) { Here "this" can already be a ...
9 years, 7 months ago (2011-05-10 13:07:02 UTC) #2
Lasse Reichstein
http://codereview.chromium.org/6991007/diff/1/src/objects.cc File src/objects.cc (right): http://codereview.chromium.org/6991007/diff/1/src/objects.cc#newcode5214 src/objects.cc:5214: if (this->GetIsolate()->ShouldFlattenString()) { Good point. We should probably not ...
9 years, 7 months ago (2011-05-10 16:27:46 UTC) #3
Erik Corry
LGTM with the 'flat' naming fixed. http://codereview.chromium.org/6991007/diff/6001/src/objects-inl.h File src/objects-inl.h (right): http://codereview.chromium.org/6991007/diff/6001/src/objects-inl.h#newcode183 src/objects-inl.h:183: uint32_t type = ...
9 years, 7 months ago (2011-05-11 19:31:59 UTC) #4
Vitaly Repeshko
9 years, 7 months ago (2011-05-12 15:54:53 UTC) #5
LGTM too modulo the same issue.

http://codereview.chromium.org/6991007/diff/6001/src/objects-inl.h
File src/objects-inl.h (right):

http://codereview.chromium.org/6991007/diff/6001/src/objects-inl.h#newcode2029
src/objects-inl.h:2029: if (this->IsFlat()) {
I agree that this is confusing. IsFlat is usually called to avoid flattening or
before getting a vector of chars. I think ConsString should have a new
IsFlattenedCons predicate and other usages of IsFlat should be replaced with
more specific predicates.

http://codereview.chromium.org/6991007/diff/6001/src/objects.cc
File src/objects.cc (right):

http://codereview.chromium.org/6991007/diff/6001/src/objects.cc#newcode5220
src/objects.cc:5220: int recurse_limit = 7;
Make this a (documented) constant in ConsString.

http://codereview.chromium.org/6991007/diff/6001/src/objects.cc#newcode5236
src/objects.cc:5236: cursor = String::cast(flatten_result->ToObjectUnchecked());
It's more straightforward to simply return 
Smi::FromInt(String::cast(flatten_result->ToObjectUnchecked())->Get(index))
here.

Powered by Google App Engine
This is Rietveld 408576698