| 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 Object); | 302 Object); |
| 303 } | 303 } |
| 304 | 304 |
| 305 | 305 |
| 306 Handle<Object> GetPrototype(Handle<Object> obj) { | 306 Handle<Object> GetPrototype(Handle<Object> obj) { |
| 307 Handle<Object> result(obj->GetPrototype()); | 307 Handle<Object> result(obj->GetPrototype()); |
| 308 return result; | 308 return result; |
| 309 } | 309 } |
| 310 | 310 |
| 311 | 311 |
| 312 Handle<Object> SetPrototype(Handle<JSObject> obj, Handle<Object> value) { |
| 313 const bool skip_hidden_prototypes = false; |
| 314 CALL_HEAP_FUNCTION(obj->SetPrototype(*value, skip_hidden_prototypes), Object); |
| 315 } |
| 316 |
| 317 |
| 312 Handle<Object> GetHiddenProperties(Handle<JSObject> obj, | 318 Handle<Object> GetHiddenProperties(Handle<JSObject> obj, |
| 313 bool create_if_needed) { | 319 bool create_if_needed) { |
| 314 Object* holder = obj->BypassGlobalProxy(); | 320 Object* holder = obj->BypassGlobalProxy(); |
| 315 if (holder->IsUndefined()) return Factory::undefined_value(); | 321 if (holder->IsUndefined()) return Factory::undefined_value(); |
| 316 obj = Handle<JSObject>(JSObject::cast(holder)); | 322 obj = Handle<JSObject>(JSObject::cast(holder)); |
| 317 | 323 |
| 318 if (obj->HasFastProperties()) { | 324 if (obj->HasFastProperties()) { |
| 319 // If the object has fast properties, check whether the first slot | 325 // If the object has fast properties, check whether the first slot |
| 320 // in the descriptor array matches the hidden symbol. Since the | 326 // in the descriptor array matches the hidden symbol. Since the |
| 321 // hidden symbols hash code is zero (and no other string has hash | 327 // hidden symbols hash code is zero (and no other string has hash |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 | 485 |
| 480 script->set_line_ends(*array); | 486 script->set_line_ends(*array); |
| 481 ASSERT(script->line_ends()->IsFixedArray()); | 487 ASSERT(script->line_ends()->IsFixedArray()); |
| 482 } | 488 } |
| 483 | 489 |
| 484 | 490 |
| 485 // Convert code position into line number. | 491 // Convert code position into line number. |
| 486 int GetScriptLineNumber(Handle<Script> script, int code_pos) { | 492 int GetScriptLineNumber(Handle<Script> script, int code_pos) { |
| 487 InitScriptLineEnds(script); | 493 InitScriptLineEnds(script); |
| 488 AssertNoAllocation no_allocation; | 494 AssertNoAllocation no_allocation; |
| 489 FixedArray* line_ends_array = | 495 FixedArray* line_ends_array = FixedArray::cast(script->line_ends()); |
| 490 FixedArray::cast(script->line_ends()); | |
| 491 const int line_ends_len = line_ends_array->length(); | 496 const int line_ends_len = line_ends_array->length(); |
| 492 | 497 |
| 493 int line = -1; | 498 if (!line_ends_len) |
| 494 if (line_ends_len > 0 && | 499 return -1; |
| 495 code_pos <= (Smi::cast(line_ends_array->get(0)))->value()) { | 500 |
| 496 line = 0; | 501 if ((Smi::cast(line_ends_array->get(0)))->value() >= code_pos) |
| 497 } else { | 502 return script->line_offset()->value(); |
| 498 for (int i = 1; i < line_ends_len; ++i) { | 503 |
| 499 if ((Smi::cast(line_ends_array->get(i - 1)))->value() < code_pos && | 504 int left = 0; |
| 500 code_pos <= (Smi::cast(line_ends_array->get(i)))->value()) { | 505 int right = line_ends_len; |
| 501 line = i; | 506 while (int half = (right - left) / 2) { |
| 502 break; | 507 if ((Smi::cast(line_ends_array->get(left + half)))->value() > code_pos) { |
| 503 } | 508 right -= half; |
| 509 } else { |
| 510 left += half; |
| 504 } | 511 } |
| 505 } | 512 } |
| 506 | 513 return right + script->line_offset()->value(); |
| 507 return line != -1 ? line + script->line_offset()->value() : line; | |
| 508 } | 514 } |
| 509 | 515 |
| 510 | 516 |
| 511 void CustomArguments::IterateInstance(ObjectVisitor* v) { | 517 void CustomArguments::IterateInstance(ObjectVisitor* v) { |
| 512 v->VisitPointers(values_, values_ + 4); | 518 v->VisitPointers(values_, values_ + 4); |
| 513 } | 519 } |
| 514 | 520 |
| 515 | 521 |
| 516 // Compute the property keys from the interceptor. | 522 // Compute the property keys from the interceptor. |
| 517 v8::Handle<v8::Array> GetKeysForNamedInterceptor(Handle<JSObject> receiver, | 523 v8::Handle<v8::Array> GetKeysForNamedInterceptor(Handle<JSObject> receiver, |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 | 754 |
| 749 OptimizedObjectForAddingMultipleProperties:: | 755 OptimizedObjectForAddingMultipleProperties:: |
| 750 ~OptimizedObjectForAddingMultipleProperties() { | 756 ~OptimizedObjectForAddingMultipleProperties() { |
| 751 // Reoptimize the object to allow fast property access. | 757 // Reoptimize the object to allow fast property access. |
| 752 if (has_been_transformed_) { | 758 if (has_been_transformed_) { |
| 753 TransformToFastProperties(object_, unused_property_fields_); | 759 TransformToFastProperties(object_, unused_property_fields_); |
| 754 } | 760 } |
| 755 } | 761 } |
| 756 | 762 |
| 757 } } // namespace v8::internal | 763 } } // namespace v8::internal |
| OLD | NEW |