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

Unified Diff: src/factory.cc

Issue 17600006: CPUProfiler: It is not clear why we are using Handle<Object> for scriptId. Lets flip it into Smi/in… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: comments addressed Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/debug.cc ('k') | src/heap.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index 2a03050b6de7af839c8ccd8719b3030ec55e3b25..673bb23031733ad2c5acde104e94a256b5a9ea70 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -434,27 +434,17 @@ Handle<ExecutableAccessorInfo> Factory::NewExecutableAccessorInfo() {
Handle<Script> Factory::NewScript(Handle<String> source) {
// Generate id for this script.
- int id;
Heap* heap = isolate()->heap();
- if (heap->last_script_id()->IsUndefined()) {
- // Script ids start from one.
- id = 1;
- } else {
- // Increment id, wrap when positive smi is exhausted.
- id = Smi::cast(heap->last_script_id())->value();
- id++;
- if (!Smi::IsValid(id)) {
- id = 0;
- }
- }
- heap->SetLastScriptId(Smi::FromInt(id));
+ int id = heap->last_script_id()->value() + 1;
+ if (!Smi::IsValid(id) || id < 0) id = 1;
+ heap->set_last_script_id(Smi::FromInt(id));
// Create and initialize script object.
Handle<Foreign> wrapper = NewForeign(0, TENURED);
Handle<Script> script = Handle<Script>::cast(NewStruct(SCRIPT_TYPE));
script->set_source(*source);
script->set_name(heap->undefined_value());
- script->set_id(heap->last_script_id());
+ script->set_id(Smi::FromInt(id));
script->set_line_offset(Smi::FromInt(0));
script->set_column_offset(Smi::FromInt(0));
script->set_data(heap->undefined_value());
« no previous file with comments | « src/debug.cc ('k') | src/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698