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

Side by Side Diff: src/handles.cc

Issue 593108: GetScriptLineNumber was changed. ... (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: '' Created 10 years, 10 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 | « no previous file | test/cctest/test-compiler.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 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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 470
471 script->set_line_ends(*array); 471 script->set_line_ends(*array);
472 ASSERT(script->line_ends()->IsFixedArray()); 472 ASSERT(script->line_ends()->IsFixedArray());
473 } 473 }
474 474
475 475
476 // Convert code position into line number. 476 // Convert code position into line number.
477 int GetScriptLineNumber(Handle<Script> script, int code_pos) { 477 int GetScriptLineNumber(Handle<Script> script, int code_pos) {
478 InitScriptLineEnds(script); 478 InitScriptLineEnds(script);
479 AssertNoAllocation no_allocation; 479 AssertNoAllocation no_allocation;
480 FixedArray* line_ends_array = 480 FixedArray* line_ends_array = FixedArray::cast(script->line_ends());
481 FixedArray::cast(script->line_ends());
482 const int line_ends_len = line_ends_array->length(); 481 const int line_ends_len = line_ends_array->length();
483 482
484 int line = -1; 483 if (!line_ends_len)
485 if (line_ends_len > 0 && 484 return -1;
486 code_pos <= (Smi::cast(line_ends_array->get(0)))->value()) { 485
487 line = 0; 486 if ((Smi::cast(line_ends_array->get(0)))->value() >= code_pos)
488 } else { 487 return script->line_offset()->value();
489 for (int i = 1; i < line_ends_len; ++i) { 488
490 if ((Smi::cast(line_ends_array->get(i - 1)))->value() < code_pos && 489 int left = 0;
491 code_pos <= (Smi::cast(line_ends_array->get(i)))->value()) { 490 int right = line_ends_len;
492 line = i; 491 while (int half = (right - left) / 2) {
493 break; 492 if ((Smi::cast(line_ends_array->get(left + half)))->value() > code_pos) {
494 } 493 right -= half;
494 } else {
495 left += half;
495 } 496 }
496 } 497 }
497 498 return right + script->line_offset()->value();
498 return line != -1 ? line + script->line_offset()->value() : line;
499 } 499 }
500 500
501 501
502 void CustomArguments::IterateInstance(ObjectVisitor* v) { 502 void CustomArguments::IterateInstance(ObjectVisitor* v) {
503 v->VisitPointers(values_, values_ + 4); 503 v->VisitPointers(values_, values_ + 4);
504 } 504 }
505 505
506 506
507 // Compute the property keys from the interceptor. 507 // Compute the property keys from the interceptor.
508 v8::Handle<v8::Array> GetKeysForNamedInterceptor(Handle<JSObject> receiver, 508 v8::Handle<v8::Array> GetKeysForNamedInterceptor(Handle<JSObject> receiver,
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 Handle<Map> new_map = Factory::CopyMapDropTransitions(old_map); 824 Handle<Map> new_map = Factory::CopyMapDropTransitions(old_map);
825 obj->set_map(*new_map); 825 obj->set_map(*new_map);
826 new_map->set_needs_loading(true); 826 new_map->set_needs_loading(true);
827 // Store the lazy loading info in the constructor field. We'll 827 // Store the lazy loading info in the constructor field. We'll
828 // reestablish the constructor from the fixed array after loading. 828 // reestablish the constructor from the fixed array after loading.
829 new_map->set_constructor(*arr); 829 new_map->set_constructor(*arr);
830 ASSERT(!obj->IsLoaded()); 830 ASSERT(!obj->IsLoaded());
831 } 831 }
832 832
833 } } // namespace v8::internal 833 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698