| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 | 287 |
| 288 | 288 |
| 289 Handle<Object> GetProperty(Isolate* isolate, | 289 Handle<Object> GetProperty(Isolate* isolate, |
| 290 Handle<Object> obj, | 290 Handle<Object> obj, |
| 291 Handle<Object> key) { | 291 Handle<Object> key) { |
| 292 CALL_HEAP_FUNCTION(isolate, | 292 CALL_HEAP_FUNCTION(isolate, |
| 293 Runtime::GetObjectProperty(isolate, obj, key), Object); | 293 Runtime::GetObjectProperty(isolate, obj, key), Object); |
| 294 } | 294 } |
| 295 | 295 |
| 296 | 296 |
| 297 Handle<Object> SetPrototype(Handle<JSObject> obj, Handle<Object> value) { | |
| 298 const bool skip_hidden_prototypes = false; | |
| 299 CALL_HEAP_FUNCTION(obj->GetIsolate(), | |
| 300 obj->SetPrototype(*value, skip_hidden_prototypes), Object); | |
| 301 } | |
| 302 | |
| 303 | |
| 304 Handle<Object> LookupSingleCharacterStringFromCode(Isolate* isolate, | 297 Handle<Object> LookupSingleCharacterStringFromCode(Isolate* isolate, |
| 305 uint32_t index) { | 298 uint32_t index) { |
| 306 CALL_HEAP_FUNCTION( | 299 CALL_HEAP_FUNCTION( |
| 307 isolate, | 300 isolate, |
| 308 isolate->heap()->LookupSingleCharacterStringFromCode(index), Object); | 301 isolate->heap()->LookupSingleCharacterStringFromCode(index), Object); |
| 309 } | 302 } |
| 310 | 303 |
| 311 | 304 |
| 312 Handle<String> SubString(Handle<String> str, | 305 Handle<String> SubString(Handle<String> str, |
| 313 int start, | 306 int start, |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 while (int half = (right - left) / 2) { | 492 while (int half = (right - left) / 2) { |
| 500 if ((Smi::cast(line_ends_array->get(left + half)))->value() > code_pos) { | 493 if ((Smi::cast(line_ends_array->get(left + half)))->value() > code_pos) { |
| 501 right -= half; | 494 right -= half; |
| 502 } else { | 495 } else { |
| 503 left += half; | 496 left += half; |
| 504 } | 497 } |
| 505 } | 498 } |
| 506 return right + script->line_offset()->value(); | 499 return right + script->line_offset()->value(); |
| 507 } | 500 } |
| 508 | 501 |
| 502 |
| 509 // Convert code position into column number. | 503 // Convert code position into column number. |
| 510 int GetScriptColumnNumber(Handle<Script> script, int code_pos) { | 504 int GetScriptColumnNumber(Handle<Script> script, int code_pos) { |
| 511 int line_number = GetScriptLineNumber(script, code_pos); | 505 int line_number = GetScriptLineNumber(script, code_pos); |
| 512 if (line_number == -1) return -1; | 506 if (line_number == -1) return -1; |
| 513 | 507 |
| 514 DisallowHeapAllocation no_allocation; | 508 DisallowHeapAllocation no_allocation; |
| 515 FixedArray* line_ends_array = FixedArray::cast(script->line_ends()); | 509 FixedArray* line_ends_array = FixedArray::cast(script->line_ends()); |
| 516 line_number = line_number - script->line_offset()->value(); | 510 line_number = line_number - script->line_offset()->value(); |
| 517 if (line_number == 0) return code_pos + script->column_offset()->value(); | 511 if (line_number == 0) return code_pos + script->column_offset()->value(); |
| 518 int prev_line_end_pos = | 512 int prev_line_end_pos = |
| 519 Smi::cast(line_ends_array->get(line_number - 1))->value(); | 513 Smi::cast(line_ends_array->get(line_number - 1))->value(); |
| 520 return code_pos - (prev_line_end_pos + 1); | 514 return code_pos - (prev_line_end_pos + 1); |
| 521 } | 515 } |
| 522 | 516 |
| 517 |
| 523 int GetScriptLineNumberSafe(Handle<Script> script, int code_pos) { | 518 int GetScriptLineNumberSafe(Handle<Script> script, int code_pos) { |
| 524 DisallowHeapAllocation no_allocation; | 519 DisallowHeapAllocation no_allocation; |
| 525 if (!script->line_ends()->IsUndefined()) { | 520 if (!script->line_ends()->IsUndefined()) { |
| 526 return GetScriptLineNumber(script, code_pos); | 521 return GetScriptLineNumber(script, code_pos); |
| 527 } | 522 } |
| 528 // Slow mode: we do not have line_ends. We have to iterate through source. | 523 // Slow mode: we do not have line_ends. We have to iterate through source. |
| 529 if (!script->source()->IsString()) { | 524 if (!script->source()->IsString()) { |
| 530 return -1; | 525 return -1; |
| 531 } | 526 } |
| 532 String* source = String::cast(script->source()); | 527 String* source = String::cast(script->source()); |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 data->next = prev_next_; | 911 data->next = prev_next_; |
| 917 data->limit = prev_limit_; | 912 data->limit = prev_limit_; |
| 918 #ifdef DEBUG | 913 #ifdef DEBUG |
| 919 handles_detached_ = true; | 914 handles_detached_ = true; |
| 920 #endif | 915 #endif |
| 921 return deferred; | 916 return deferred; |
| 922 } | 917 } |
| 923 | 918 |
| 924 | 919 |
| 925 } } // namespace v8::internal | 920 } } // namespace v8::internal |
| OLD | NEW |