OLD | NEW |
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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 Handle<Object> handle = GlobalHandles::Create(*result); | 422 Handle<Object> handle = GlobalHandles::Create(*result); |
423 GlobalHandles::MakeWeak(handle.location(), NULL, &ClearWrapperCache); | 423 GlobalHandles::MakeWeak(handle.location(), NULL, &ClearWrapperCache); |
424 script->wrapper()->set_proxy(reinterpret_cast<Address>(handle.location())); | 424 script->wrapper()->set_proxy(reinterpret_cast<Address>(handle.location())); |
425 return result; | 425 return result; |
426 } | 426 } |
427 | 427 |
428 | 428 |
429 // Init line_ends array with code positions of line ends inside script | 429 // Init line_ends array with code positions of line ends inside script |
430 // source. | 430 // source. |
431 void InitScriptLineEnds(Handle<Script> script) { | 431 void InitScriptLineEnds(Handle<Script> script) { |
432 if (!script->line_ends_fixed_array()->IsUndefined()) return; | 432 if (!script->line_ends()->IsUndefined()) return; |
433 | 433 |
434 if (!script->source()->IsString()) { | 434 if (!script->source()->IsString()) { |
435 ASSERT(script->source()->IsUndefined()); | 435 ASSERT(script->source()->IsUndefined()); |
436 script->set_line_ends_fixed_array(*(Factory::NewFixedArray(0))); | 436 script->set_line_ends(*(Factory::NewFixedArray(0))); |
437 ASSERT(script->line_ends_fixed_array()->IsFixedArray()); | 437 ASSERT(script->line_ends()->IsFixedArray()); |
438 return; | 438 return; |
439 } | 439 } |
440 | 440 |
441 Handle<String> src(String::cast(script->source())); | 441 Handle<String> src(String::cast(script->source())); |
442 const int src_len = src->length(); | 442 const int src_len = src->length(); |
443 Handle<String> new_line = Factory::NewStringFromAscii(CStrVector("\n")); | 443 Handle<String> new_line = Factory::NewStringFromAscii(CStrVector("\n")); |
444 | 444 |
445 // Pass 1: Identify line count. | 445 // Pass 1: Identify line count. |
446 int line_count = 0; | 446 int line_count = 0; |
447 int position = 0; | 447 int position = 0; |
(...skipping 12 matching lines...) Expand all Loading... |
460 position = 0; | 460 position = 0; |
461 while (position != -1 && position < src_len) { | 461 while (position != -1 && position < src_len) { |
462 position = Runtime::StringMatch(src, new_line, position); | 462 position = Runtime::StringMatch(src, new_line, position); |
463 // If the script does not end with a line ending add the final end | 463 // If the script does not end with a line ending add the final end |
464 // position as just past the last line ending. | 464 // position as just past the last line ending. |
465 array->set(array_index++, | 465 array->set(array_index++, |
466 Smi::FromInt(position != -1 ? position++ : src_len)); | 466 Smi::FromInt(position != -1 ? position++ : src_len)); |
467 } | 467 } |
468 ASSERT(array_index == line_count); | 468 ASSERT(array_index == line_count); |
469 | 469 |
470 script->set_line_ends_fixed_array(*array); | 470 script->set_line_ends(*array); |
471 ASSERT(script->line_ends_fixed_array()->IsFixedArray()); | 471 ASSERT(script->line_ends()->IsFixedArray()); |
472 } | 472 } |
473 | 473 |
474 | 474 |
475 // Convert code position into line number. | 475 // Convert code position into line number. |
476 int GetScriptLineNumber(Handle<Script> script, int code_pos) { | 476 int GetScriptLineNumber(Handle<Script> script, int code_pos) { |
477 InitScriptLineEnds(script); | 477 InitScriptLineEnds(script); |
478 AssertNoAllocation no_allocation; | 478 AssertNoAllocation no_allocation; |
479 FixedArray* line_ends_array = | 479 FixedArray* line_ends_array = |
480 FixedArray::cast(script->line_ends_fixed_array()); | 480 FixedArray::cast(script->line_ends()); |
481 const int line_ends_len = line_ends_array->length(); | 481 const int line_ends_len = line_ends_array->length(); |
482 | 482 |
483 int line = -1; | 483 int line = -1; |
484 if (line_ends_len > 0 && | 484 if (line_ends_len > 0 && |
485 code_pos <= (Smi::cast(line_ends_array->get(0)))->value()) { | 485 code_pos <= (Smi::cast(line_ends_array->get(0)))->value()) { |
486 line = 0; | 486 line = 0; |
487 } else { | 487 } else { |
488 for (int i = 1; i < line_ends_len; ++i) { | 488 for (int i = 1; i < line_ends_len; ++i) { |
489 if ((Smi::cast(line_ends_array->get(i - 1)))->value() < code_pos && | 489 if ((Smi::cast(line_ends_array->get(i - 1)))->value() < code_pos && |
490 code_pos <= (Smi::cast(line_ends_array->get(i)))->value()) { | 490 code_pos <= (Smi::cast(line_ends_array->get(i)))->value()) { |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 Handle<Map> new_map = Factory::CopyMapDropTransitions(old_map); | 780 Handle<Map> new_map = Factory::CopyMapDropTransitions(old_map); |
781 obj->set_map(*new_map); | 781 obj->set_map(*new_map); |
782 new_map->set_needs_loading(true); | 782 new_map->set_needs_loading(true); |
783 // Store the lazy loading info in the constructor field. We'll | 783 // Store the lazy loading info in the constructor field. We'll |
784 // reestablish the constructor from the fixed array after loading. | 784 // reestablish the constructor from the fixed array after loading. |
785 new_map->set_constructor(*arr); | 785 new_map->set_constructor(*arr); |
786 ASSERT(!obj->IsLoaded()); | 786 ASSERT(!obj->IsLoaded()); |
787 } | 787 } |
788 | 788 |
789 } } // namespace v8::internal | 789 } } // namespace v8::internal |
OLD | NEW |