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

Side by Side Diff: src/handles.cc

Issue 385035: Restore info needed to register profile ticks in functions from... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 1 month 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/factory.cc ('k') | src/objects.h » ('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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 Handle<Object> handle = GlobalHandles::Create(*result); 420 Handle<Object> handle = GlobalHandles::Create(*result);
421 GlobalHandles::MakeWeak(handle.location(), NULL, &ClearWrapperCache); 421 GlobalHandles::MakeWeak(handle.location(), NULL, &ClearWrapperCache);
422 script->wrapper()->set_proxy(reinterpret_cast<Address>(handle.location())); 422 script->wrapper()->set_proxy(reinterpret_cast<Address>(handle.location()));
423 return result; 423 return result;
424 } 424 }
425 425
426 426
427 // Init line_ends array with code positions of line ends inside script 427 // Init line_ends array with code positions of line ends inside script
428 // source. 428 // source.
429 void InitScriptLineEnds(Handle<Script> script) { 429 void InitScriptLineEnds(Handle<Script> script) {
430 if (!script->line_ends()->IsUndefined()) return; 430 if (!script->line_ends_fixed_array()->IsUndefined()) return;
431 431
432 if (!script->source()->IsString()) { 432 if (!script->source()->IsString()) {
433 ASSERT(script->source()->IsUndefined()); 433 ASSERT(script->source()->IsUndefined());
434 script->set_line_ends(*(Factory::NewJSArray(0))); 434 script->set_line_ends_fixed_array(*(Factory::NewFixedArray(0)));
435 ASSERT(script->line_ends()->IsJSArray()); 435 ASSERT(script->line_ends_fixed_array()->IsFixedArray());
436 return; 436 return;
437 } 437 }
438 438
439 Handle<String> src(String::cast(script->source())); 439 Handle<String> src(String::cast(script->source()));
440 const int src_len = src->length(); 440 const int src_len = src->length();
441 Handle<String> new_line = Factory::NewStringFromAscii(CStrVector("\n")); 441 Handle<String> new_line = Factory::NewStringFromAscii(CStrVector("\n"));
442 442
443 // Pass 1: Identify line count. 443 // Pass 1: Identify line count.
444 int line_count = 0; 444 int line_count = 0;
445 int position = 0; 445 int position = 0;
(...skipping 12 matching lines...) Expand all
458 position = 0; 458 position = 0;
459 while (position != -1 && position < src_len) { 459 while (position != -1 && position < src_len) {
460 position = Runtime::StringMatch(src, new_line, position); 460 position = Runtime::StringMatch(src, new_line, position);
461 // If the script does not end with a line ending add the final end 461 // If the script does not end with a line ending add the final end
462 // position as just past the last line ending. 462 // position as just past the last line ending.
463 array->set(array_index++, 463 array->set(array_index++,
464 Smi::FromInt(position != -1 ? position++ : src_len)); 464 Smi::FromInt(position != -1 ? position++ : src_len));
465 } 465 }
466 ASSERT(array_index == line_count); 466 ASSERT(array_index == line_count);
467 467
468 Handle<JSArray> object = Factory::NewJSArrayWithElements(array); 468 script->set_line_ends_fixed_array(*array);
469 script->set_line_ends(*object); 469 ASSERT(script->line_ends_fixed_array()->IsFixedArray());
470 ASSERT(script->line_ends()->IsJSArray());
471 } 470 }
472 471
473 472
474 // Convert code position into line number. 473 // Convert code position into line number.
475 int GetScriptLineNumber(Handle<Script> script, int code_pos) { 474 int GetScriptLineNumber(Handle<Script> script, int code_pos) {
476 InitScriptLineEnds(script); 475 InitScriptLineEnds(script);
477 AssertNoAllocation no_allocation; 476 AssertNoAllocation no_allocation;
478 JSArray* line_ends_array = JSArray::cast(script->line_ends()); 477 FixedArray* line_ends_array =
479 const int line_ends_len = (Smi::cast(line_ends_array->length()))->value(); 478 FixedArray::cast(script->line_ends_fixed_array());
479 const int line_ends_len = line_ends_array->length();
480 480
481 int line = -1; 481 int line = -1;
482 if (line_ends_len > 0 && 482 if (line_ends_len > 0 &&
483 code_pos <= (Smi::cast(line_ends_array->GetElement(0)))->value()) { 483 code_pos <= (Smi::cast(line_ends_array->get(0)))->value()) {
484 line = 0; 484 line = 0;
485 } else { 485 } else {
486 for (int i = 1; i < line_ends_len; ++i) { 486 for (int i = 1; i < line_ends_len; ++i) {
487 if ((Smi::cast(line_ends_array->GetElement(i - 1)))->value() < code_pos && 487 if ((Smi::cast(line_ends_array->get(i - 1)))->value() < code_pos &&
488 code_pos <= (Smi::cast(line_ends_array->GetElement(i)))->value()) { 488 code_pos <= (Smi::cast(line_ends_array->get(i)))->value()) {
489 line = i; 489 line = i;
490 break; 490 break;
491 } 491 }
492 } 492 }
493 } 493 }
494 494
495 return line != -1 ? line + script->line_offset()->value() : line; 495 return line != -1 ? line + script->line_offset()->value() : line;
496 } 496 }
497 497
498 498
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 Handle<Map> new_map = Factory::CopyMapDropTransitions(old_map); 778 Handle<Map> new_map = Factory::CopyMapDropTransitions(old_map);
779 obj->set_map(*new_map); 779 obj->set_map(*new_map);
780 new_map->set_needs_loading(true); 780 new_map->set_needs_loading(true);
781 // Store the lazy loading info in the constructor field. We'll 781 // Store the lazy loading info in the constructor field. We'll
782 // reestablish the constructor from the fixed array after loading. 782 // reestablish the constructor from the fixed array after loading.
783 new_map->set_constructor(*arr); 783 new_map->set_constructor(*arr);
784 ASSERT(!obj->IsLoaded()); 784 ASSERT(!obj->IsLoaded());
785 } 785 }
786 786
787 } } // namespace v8::internal 787 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/factory.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698