OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 Handle<ExecutableAccessorInfo> info = | 427 Handle<ExecutableAccessorInfo> info = |
428 Handle<ExecutableAccessorInfo>::cast( | 428 Handle<ExecutableAccessorInfo>::cast( |
429 NewStruct(EXECUTABLE_ACCESSOR_INFO_TYPE)); | 429 NewStruct(EXECUTABLE_ACCESSOR_INFO_TYPE)); |
430 info->set_flag(0); // Must clear the flag, it was initialized as undefined. | 430 info->set_flag(0); // Must clear the flag, it was initialized as undefined. |
431 return info; | 431 return info; |
432 } | 432 } |
433 | 433 |
434 | 434 |
435 Handle<Script> Factory::NewScript(Handle<String> source) { | 435 Handle<Script> Factory::NewScript(Handle<String> source) { |
436 // Generate id for this script. | 436 // Generate id for this script. |
437 int id; | |
438 Heap* heap = isolate()->heap(); | 437 Heap* heap = isolate()->heap(); |
439 if (heap->last_script_id()->IsUndefined()) { | 438 int id = heap->last_script_id()->value() + 1; |
440 // Script ids start from one. | 439 if (!Smi::IsValid(id) || id < 0) id = 1; |
441 id = 1; | 440 heap->set_last_script_id(Smi::FromInt(id)); |
442 } else { | |
443 // Increment id, wrap when positive smi is exhausted. | |
444 id = Smi::cast(heap->last_script_id())->value(); | |
445 id++; | |
446 if (!Smi::IsValid(id)) { | |
447 id = 0; | |
448 } | |
449 } | |
450 heap->SetLastScriptId(Smi::FromInt(id)); | |
451 | 441 |
452 // Create and initialize script object. | 442 // Create and initialize script object. |
453 Handle<Foreign> wrapper = NewForeign(0, TENURED); | 443 Handle<Foreign> wrapper = NewForeign(0, TENURED); |
454 Handle<Script> script = Handle<Script>::cast(NewStruct(SCRIPT_TYPE)); | 444 Handle<Script> script = Handle<Script>::cast(NewStruct(SCRIPT_TYPE)); |
455 script->set_source(*source); | 445 script->set_source(*source); |
456 script->set_name(heap->undefined_value()); | 446 script->set_name(heap->undefined_value()); |
457 script->set_id(heap->last_script_id()); | 447 script->set_id(Smi::FromInt(id)); |
458 script->set_line_offset(Smi::FromInt(0)); | 448 script->set_line_offset(Smi::FromInt(0)); |
459 script->set_column_offset(Smi::FromInt(0)); | 449 script->set_column_offset(Smi::FromInt(0)); |
460 script->set_data(heap->undefined_value()); | 450 script->set_data(heap->undefined_value()); |
461 script->set_context_data(heap->undefined_value()); | 451 script->set_context_data(heap->undefined_value()); |
462 script->set_type(Smi::FromInt(Script::TYPE_NORMAL)); | 452 script->set_type(Smi::FromInt(Script::TYPE_NORMAL)); |
463 script->set_compilation_type(Smi::FromInt(Script::COMPILATION_TYPE_HOST)); | 453 script->set_compilation_type(Smi::FromInt(Script::COMPILATION_TYPE_HOST)); |
464 script->set_compilation_state( | 454 script->set_compilation_state( |
465 Smi::FromInt(Script::COMPILATION_STATE_INITIAL)); | 455 Smi::FromInt(Script::COMPILATION_STATE_INITIAL)); |
466 script->set_wrapper(*wrapper); | 456 script->set_wrapper(*wrapper); |
467 script->set_line_ends(heap->undefined_value()); | 457 script->set_line_ends(heap->undefined_value()); |
(...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1608 return Handle<Object>::null(); | 1598 return Handle<Object>::null(); |
1609 } | 1599 } |
1610 | 1600 |
1611 | 1601 |
1612 Handle<Object> Factory::ToBoolean(bool value) { | 1602 Handle<Object> Factory::ToBoolean(bool value) { |
1613 return value ? true_value() : false_value(); | 1603 return value ? true_value() : false_value(); |
1614 } | 1604 } |
1615 | 1605 |
1616 | 1606 |
1617 } } // namespace v8::internal | 1607 } } // namespace v8::internal |
OLD | NEW |