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

Side by Side Diff: src/handles.cc

Issue 228093004: Implement handlified String::Flatten. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: even shorter Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/handles.h ('k') | src/hydrogen.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 Handle<JSGlobalProxy> ReinitializeJSGlobalProxy( 127 Handle<JSGlobalProxy> ReinitializeJSGlobalProxy(
128 Handle<JSFunction> constructor, 128 Handle<JSFunction> constructor,
129 Handle<JSGlobalProxy> global) { 129 Handle<JSGlobalProxy> global) {
130 CALL_HEAP_FUNCTION( 130 CALL_HEAP_FUNCTION(
131 constructor->GetIsolate(), 131 constructor->GetIsolate(),
132 constructor->GetHeap()->ReinitializeJSGlobalProxy(*constructor, *global), 132 constructor->GetHeap()->ReinitializeJSGlobalProxy(*constructor, *global),
133 JSGlobalProxy); 133 JSGlobalProxy);
134 } 134 }
135 135
136 136
137 void FlattenString(Handle<String> string) {
138 CALL_HEAP_FUNCTION_VOID(string->GetIsolate(), string->TryFlatten());
139 }
140
141
142 Handle<String> FlattenGetString(Handle<String> string) {
143 CALL_HEAP_FUNCTION(string->GetIsolate(), string->TryFlatten(), String);
144 }
145
146
147 Handle<Object> GetProperty(Handle<JSReceiver> obj, 137 Handle<Object> GetProperty(Handle<JSReceiver> obj,
148 const char* name) { 138 const char* name) {
149 Isolate* isolate = obj->GetIsolate(); 139 Isolate* isolate = obj->GetIsolate();
150 Handle<String> str = isolate->factory()->InternalizeUtf8String(name); 140 Handle<String> str = isolate->factory()->InternalizeUtf8String(name);
151 ASSERT(!str.is_null()); 141 ASSERT(!str.is_null());
152 return Object::GetPropertyOrElement(obj, str); 142 return Object::GetPropertyOrElement(obj, str);
153 } 143 }
154 144
155 145
156 // Wrappers for scripts are kept alive and cached in weak global 146 // Wrappers for scripts are kept alive and cached in weak global
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 // Even if the last line misses a line end, it is counted. 245 // Even if the last line misses a line end, it is counted.
256 line_ends->Add(src_len); 246 line_ends->Add(src_len);
257 return; 247 return;
258 } 248 }
259 } 249 }
260 } 250 }
261 251
262 252
263 Handle<FixedArray> CalculateLineEnds(Handle<String> src, 253 Handle<FixedArray> CalculateLineEnds(Handle<String> src,
264 bool with_last_line) { 254 bool with_last_line) {
265 src = FlattenGetString(src); 255 src = String::Flatten(src);
266 // Rough estimate of line count based on a roughly estimated average 256 // Rough estimate of line count based on a roughly estimated average
267 // length of (unpacked) code. 257 // length of (unpacked) code.
268 int line_count_estimate = src->length() >> 4; 258 int line_count_estimate = src->length() >> 4;
269 List<int> line_ends(line_count_estimate); 259 List<int> line_ends(line_count_estimate);
270 Isolate* isolate = src->GetIsolate(); 260 Isolate* isolate = src->GetIsolate();
271 { 261 {
272 DisallowHeapAllocation no_allocation; // ensure vectors stay valid. 262 DisallowHeapAllocation no_allocation; // ensure vectors stay valid.
273 // Dispatch on type of strings. 263 // Dispatch on type of strings.
274 String::FlatContent content = src->GetFlatContent(); 264 String::FlatContent content = src->GetFlatContent();
275 ASSERT(content.IsFlat()); 265 ASSERT(content.IsFlat());
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 Handle<Code> code) { 698 Handle<Code> code) {
709 heap->EnsureWeakObjectToCodeTable(); 699 heap->EnsureWeakObjectToCodeTable();
710 Handle<DependentCode> dep(heap->LookupWeakObjectToCodeDependency(*object)); 700 Handle<DependentCode> dep(heap->LookupWeakObjectToCodeDependency(*object));
711 dep = DependentCode::Insert(dep, DependentCode::kWeaklyEmbeddedGroup, code); 701 dep = DependentCode::Insert(dep, DependentCode::kWeaklyEmbeddedGroup, code);
712 CALL_HEAP_FUNCTION_VOID(heap->isolate(), 702 CALL_HEAP_FUNCTION_VOID(heap->isolate(),
713 heap->AddWeakObjectToCodeDependency(*object, *dep)); 703 heap->AddWeakObjectToCodeDependency(*object, *dep));
714 } 704 }
715 705
716 706
717 } } // namespace v8::internal 707 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/handles.h ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698