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 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 if ((Smi::cast(line_ends_array->get(left + half)))->value() > code_pos) { | 507 if ((Smi::cast(line_ends_array->get(left + half)))->value() > code_pos) { |
508 right -= half; | 508 right -= half; |
509 } else { | 509 } else { |
510 left += half; | 510 left += half; |
511 } | 511 } |
512 } | 512 } |
513 return right + script->line_offset()->value(); | 513 return right + script->line_offset()->value(); |
514 } | 514 } |
515 | 515 |
516 | 516 |
| 517 int GetScriptLineNumberSafe(Handle<Script> script, int code_pos) { |
| 518 AssertNoAllocation no_allocation; |
| 519 if (!script->line_ends()->IsUndefined()) { |
| 520 return GetScriptLineNumber(script, code_pos); |
| 521 } |
| 522 // Slow mode: we do not have line_ends. We have to iterate through source. |
| 523 if (!script->source()->IsString()) { |
| 524 return -1; |
| 525 } |
| 526 String* source = String::cast(script->source()); |
| 527 int line = 0; |
| 528 int len = source->length(); |
| 529 for (int pos = 0; pos < len; pos++) { |
| 530 if (pos == code_pos) { |
| 531 break; |
| 532 } |
| 533 if (source->Get(pos) == '\n') { |
| 534 line++; |
| 535 } |
| 536 } |
| 537 return line; |
| 538 } |
| 539 |
| 540 |
517 void CustomArguments::IterateInstance(ObjectVisitor* v) { | 541 void CustomArguments::IterateInstance(ObjectVisitor* v) { |
518 v->VisitPointers(values_, values_ + 4); | 542 v->VisitPointers(values_, values_ + 4); |
519 } | 543 } |
520 | 544 |
521 | 545 |
522 // Compute the property keys from the interceptor. | 546 // Compute the property keys from the interceptor. |
523 v8::Handle<v8::Array> GetKeysForNamedInterceptor(Handle<JSObject> receiver, | 547 v8::Handle<v8::Array> GetKeysForNamedInterceptor(Handle<JSObject> receiver, |
524 Handle<JSObject> object) { | 548 Handle<JSObject> object) { |
525 Handle<InterceptorInfo> interceptor(object->GetNamedInterceptor()); | 549 Handle<InterceptorInfo> interceptor(object->GetNamedInterceptor()); |
526 CustomArguments args(interceptor->data(), *receiver, *object); | 550 CustomArguments args(interceptor->data(), *receiver, *object); |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 Handle<Map> new_map = Factory::CopyMapDropTransitions(old_map); | 862 Handle<Map> new_map = Factory::CopyMapDropTransitions(old_map); |
839 obj->set_map(*new_map); | 863 obj->set_map(*new_map); |
840 new_map->set_needs_loading(true); | 864 new_map->set_needs_loading(true); |
841 // Store the lazy loading info in the constructor field. We'll | 865 // Store the lazy loading info in the constructor field. We'll |
842 // reestablish the constructor from the fixed array after loading. | 866 // reestablish the constructor from the fixed array after loading. |
843 new_map->set_constructor(*arr); | 867 new_map->set_constructor(*arr); |
844 ASSERT(!obj->IsLoaded()); | 868 ASSERT(!obj->IsLoaded()); |
845 } | 869 } |
846 | 870 |
847 } } // namespace v8::internal | 871 } } // namespace v8::internal |
OLD | NEW |