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

Side by Side Diff: src/string-stream.cc

Issue 23549011: remove Isolate::Current from most files starting with 's' through 'v' (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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
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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 void StringStream::PrintObject(Object* o) { 187 void StringStream::PrintObject(Object* o) {
188 o->ShortPrint(this); 188 o->ShortPrint(this);
189 if (o->IsString()) { 189 if (o->IsString()) {
190 if (String::cast(o)->length() <= String::kMaxShortPrintLength) { 190 if (String::cast(o)->length() <= String::kMaxShortPrintLength) {
191 return; 191 return;
192 } 192 }
193 } else if (o->IsNumber() || o->IsOddball()) { 193 } else if (o->IsNumber() || o->IsOddball()) {
194 return; 194 return;
195 } 195 }
196 if (o->IsHeapObject()) { 196 if (o->IsHeapObject()) {
197 DebugObjectCache* debug_object_cache = Isolate::Current()-> 197 HeapObject* ho = HeapObject::cast(o);
198 DebugObjectCache* debug_object_cache = ho->GetIsolate()->
198 string_stream_debug_object_cache(); 199 string_stream_debug_object_cache();
199 for (int i = 0; i < debug_object_cache->length(); i++) { 200 for (int i = 0; i < debug_object_cache->length(); i++) {
200 if ((*debug_object_cache)[i] == o) { 201 if ((*debug_object_cache)[i] == o) {
201 Add("#%d#", i); 202 Add("#%d#", i);
202 return; 203 return;
203 } 204 }
204 } 205 }
205 if (debug_object_cache->length() < kMentionedObjectCacheMaxSize) { 206 if (debug_object_cache->length() < kMentionedObjectCacheMaxSize) {
206 Add("#%d#", debug_object_cache->length()); 207 Add("#%d#", debug_object_cache->length());
207 debug_object_cache->Add(HeapObject::cast(o)); 208 debug_object_cache->Add(HeapObject::cast(o));
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 for (unsigned next; (next = position + 2048) < length_; position = next) { 283 for (unsigned next; (next = position + 2048) < length_; position = next) {
283 char save = buffer_[next]; 284 char save = buffer_[next];
284 buffer_[next] = '\0'; 285 buffer_[next] = '\0';
285 internal::PrintF(out, "%s", &buffer_[position]); 286 internal::PrintF(out, "%s", &buffer_[position]);
286 buffer_[next] = save; 287 buffer_[next] = save;
287 } 288 }
288 internal::PrintF(out, "%s", &buffer_[position]); 289 internal::PrintF(out, "%s", &buffer_[position]);
289 } 290 }
290 291
291 292
292 Handle<String> StringStream::ToString() { 293 Handle<String> StringStream::ToString(Isolate* isolate) {
293 Factory* factory = Isolate::Current()->factory(); 294 return isolate->factory()->NewStringFromUtf8(
294 return factory->NewStringFromUtf8(Vector<const char>(buffer_, length_)); 295 Vector<const char>(buffer_, length_));
295 } 296 }
296 297
297 298
298 void StringStream::ClearMentionedObjectCache() { 299 void StringStream::ClearMentionedObjectCache(Isolate* isolate) {
299 Isolate* isolate = Isolate::Current();
300 isolate->set_string_stream_current_security_token(NULL); 300 isolate->set_string_stream_current_security_token(NULL);
301 if (isolate->string_stream_debug_object_cache() == NULL) { 301 if (isolate->string_stream_debug_object_cache() == NULL) {
302 isolate->set_string_stream_debug_object_cache( 302 isolate->set_string_stream_debug_object_cache(
303 new List<HeapObject*, PreallocatedStorageAllocationPolicy>(0)); 303 new List<HeapObject*, PreallocatedStorageAllocationPolicy>(0));
304 } 304 }
305 isolate->string_stream_debug_object_cache()->Clear(); 305 isolate->string_stream_debug_object_cache()->Clear();
306 } 306 }
307 307
308 308
309 #ifdef DEBUG 309 #ifdef DEBUG
310 bool StringStream::IsMentionedObjectCacheClear() { 310 bool StringStream::IsMentionedObjectCacheClear(Isolate* isolate) {
311 return ( 311 return isolate->string_stream_debug_object_cache()->length() == 0;
312 Isolate::Current()->string_stream_debug_object_cache()->length() == 0);
313 } 312 }
314 #endif 313 #endif
315 314
316 315
317 bool StringStream::Put(String* str) { 316 bool StringStream::Put(String* str) {
318 return Put(str, 0, str->length()); 317 return Put(str, 0, str->length());
319 } 318 }
320 319
321 320
322 bool StringStream::Put(String* str, int start, int end) { 321 bool StringStream::Put(String* str, int start, int end) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 Add(" ^%c", b + 'A' - 1); 414 Add(" ^%c", b + 'A' - 1);
416 } 415 }
417 Add("\n"); 416 Add("\n");
418 } 417 }
419 if (limit >= 10) { 418 if (limit >= 10) {
420 Add(" ...\n"); 419 Add(" ...\n");
421 } 420 }
422 } 421 }
423 422
424 423
425 void StringStream::PrintMentionedObjectCache() { 424 void StringStream::PrintMentionedObjectCache(Isolate* isolate) {
426 DebugObjectCache* debug_object_cache = 425 DebugObjectCache* debug_object_cache =
427 Isolate::Current()->string_stream_debug_object_cache(); 426 isolate->string_stream_debug_object_cache();
428 Add("==== Key ============================================\n\n"); 427 Add("==== Key ============================================\n\n");
429 for (int i = 0; i < debug_object_cache->length(); i++) { 428 for (int i = 0; i < debug_object_cache->length(); i++) {
430 HeapObject* printee = (*debug_object_cache)[i]; 429 HeapObject* printee = (*debug_object_cache)[i];
431 Add(" #%d# %p: ", i, printee); 430 Add(" #%d# %p: ", i, printee);
432 printee->ShortPrint(this); 431 printee->ShortPrint(this);
433 Add("\n"); 432 Add("\n");
434 if (printee->IsJSObject()) { 433 if (printee->IsJSObject()) {
435 if (printee->IsJSValue()) { 434 if (printee->IsJSValue()) {
436 Add(" value(): %o\n", JSValue::cast(printee)->value()); 435 Add(" value(): %o\n", JSValue::cast(printee)->value());
437 } 436 }
(...skipping 12 matching lines...) Expand all
450 PrintByteArray(ByteArray::cast(printee)); 449 PrintByteArray(ByteArray::cast(printee));
451 } else if (printee->IsFixedArray()) { 450 } else if (printee->IsFixedArray()) {
452 unsigned int limit = FixedArray::cast(printee)->length(); 451 unsigned int limit = FixedArray::cast(printee)->length();
453 PrintFixedArray(FixedArray::cast(printee), limit); 452 PrintFixedArray(FixedArray::cast(printee), limit);
454 } 453 }
455 } 454 }
456 } 455 }
457 456
458 457
459 void StringStream::PrintSecurityTokenIfChanged(Object* f) { 458 void StringStream::PrintSecurityTokenIfChanged(Object* f) {
460 Isolate* isolate = Isolate::Current(); 459 if (!f->IsHeapObject()) return;
460 HeapObject* obj = HeapObject::cast(f);
461 Isolate* isolate = obj->GetIsolate();
461 Heap* heap = isolate->heap(); 462 Heap* heap = isolate->heap();
462 if (!f->IsHeapObject() || !heap->Contains(HeapObject::cast(f))) { 463 if (!heap->Contains(obj)) return;
463 return; 464 Map* map = obj->map();
464 }
465 Map* map = HeapObject::cast(f)->map();
466 if (!map->IsHeapObject() || 465 if (!map->IsHeapObject() ||
467 !heap->Contains(map) || 466 !heap->Contains(map) ||
468 !map->IsMap() || 467 !map->IsMap() ||
469 !f->IsJSFunction()) { 468 !f->IsJSFunction()) {
470 return; 469 return;
471 } 470 }
472 471
473 JSFunction* fun = JSFunction::cast(f); 472 JSFunction* fun = JSFunction::cast(f);
474 Object* perhaps_context = fun->context(); 473 Object* perhaps_context = fun->context();
475 if (perhaps_context->IsHeapObject() && 474 if (perhaps_context->IsHeapObject() &&
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 592
594 // Only grow once to the maximum allowable size. 593 // Only grow once to the maximum allowable size.
595 char* NoAllocationStringAllocator::grow(unsigned* bytes) { 594 char* NoAllocationStringAllocator::grow(unsigned* bytes) {
596 ASSERT(size_ >= *bytes); 595 ASSERT(size_ >= *bytes);
597 *bytes = size_; 596 *bytes = size_;
598 return space_; 597 return space_;
599 } 598 }
600 599
601 600
602 } } // namespace v8::internal 601 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698