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

Side by Side Diff: src/api.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/v8.h ('k') | src/debug.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2008 matching lines...) Expand 10 before | Expand all | Expand 10 after
2019 i::Handle<i::SharedFunctionInfo> function_info = OpenScript(this); 2019 i::Handle<i::SharedFunctionInfo> function_info = OpenScript(this);
2020 i::Handle<i::Script> script(i::Script::cast(function_info->script())); 2020 i::Handle<i::Script> script(i::Script::cast(function_info->script()));
2021 i::Handle<i::Object> id(script->id(), isolate); 2021 i::Handle<i::Object> id(script->id(), isolate);
2022 raw_id = *id; 2022 raw_id = *id;
2023 } 2023 }
2024 i::Handle<i::Object> id(raw_id, isolate); 2024 i::Handle<i::Object> id(raw_id, isolate);
2025 return Utils::ToLocal(id); 2025 return Utils::ToLocal(id);
2026 } 2026 }
2027 2027
2028 2028
2029 int Script::GetId() {
2030 i::Isolate* isolate = i::Isolate::Current();
2031 ON_BAILOUT(isolate, "v8::Script::Id()", return -1);
2032 LOG_API(isolate, "Script::Id");
2033 {
2034 i::HandleScope scope(isolate);
2035 i::Handle<i::SharedFunctionInfo> function_info = OpenScript(this);
2036 i::Handle<i::Script> script(i::Script::cast(function_info->script()));
2037 return script->id()->value();
2038 }
2039 }
2040
2041
2029 int Script::GetLineNumber(int code_pos) { 2042 int Script::GetLineNumber(int code_pos) {
2030 i::Isolate* isolate = i::Isolate::Current(); 2043 i::Isolate* isolate = i::Isolate::Current();
2031 ON_BAILOUT(isolate, "v8::Script::GetLineNumber()", return -1); 2044 ON_BAILOUT(isolate, "v8::Script::GetLineNumber()", return -1);
2032 LOG_API(isolate, "Script::GetLineNumber"); 2045 LOG_API(isolate, "Script::GetLineNumber");
2033 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2046 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2034 if (obj->IsScript()) { 2047 if (obj->IsScript()) {
2035 i::Handle<i::Script> script = i::Handle<i::Script>(i::Script::cast(*obj)); 2048 i::Handle<i::Script> script = i::Handle<i::Script>(i::Script::cast(*obj));
2036 return i::GetScriptLineNumber(script, code_pos); 2049 return i::GetScriptLineNumber(script, code_pos);
2037 } else { 2050 } else {
2038 return -1; 2051 return -1;
(...skipping 2290 matching lines...) Expand 10 before | Expand all | Expand 10 after
4329 4342
4330 int Function::GetScriptColumnNumber() const { 4343 int Function::GetScriptColumnNumber() const {
4331 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); 4344 i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
4332 if (func->shared()->script()->IsScript()) { 4345 if (func->shared()->script()->IsScript()) {
4333 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); 4346 i::Handle<i::Script> script(i::Script::cast(func->shared()->script()));
4334 return i::GetScriptColumnNumber(script, func->shared()->start_position()); 4347 return i::GetScriptColumnNumber(script, func->shared()->start_position());
4335 } 4348 }
4336 return kLineOffsetNotFound; 4349 return kLineOffsetNotFound;
4337 } 4350 }
4338 4351
4352
4339 Handle<Value> Function::GetScriptId() const { 4353 Handle<Value> Function::GetScriptId() const {
4340 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); 4354 i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
4341 if (!func->shared()->script()->IsScript()) 4355 if (!func->shared()->script()->IsScript())
4342 return v8::Undefined(); 4356 return v8::Undefined();
4343 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); 4357 i::Handle<i::Script> script(i::Script::cast(func->shared()->script()));
4344 return Utils::ToLocal(i::Handle<i::Object>(script->id(), func->GetIsolate())); 4358 return Utils::ToLocal(i::Handle<i::Object>(script->id(), func->GetIsolate()));
4345 } 4359 }
4346 4360
4361
4362 int Function::ScriptId() const {
4363 i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
4364 if (!func->shared()->script()->IsScript()) return v8::Script::kNoScriptId;
4365 i::Handle<i::Script> script(i::Script::cast(func->shared()->script()));
4366 return script->id()->value();
4367 }
4368
4369
4347 int String::Length() const { 4370 int String::Length() const {
4348 i::Handle<i::String> str = Utils::OpenHandle(this); 4371 i::Handle<i::String> str = Utils::OpenHandle(this);
4349 if (IsDeadCheck(str->GetIsolate(), "v8::String::Length()")) return 0; 4372 if (IsDeadCheck(str->GetIsolate(), "v8::String::Length()")) return 0;
4350 return str->length(); 4373 return str->length();
4351 } 4374 }
4352 4375
4353 4376
4354 bool String::IsOneByte() const { 4377 bool String::IsOneByte() const {
4355 i::Handle<i::String> str = Utils::OpenHandle(this); 4378 i::Handle<i::String> str = Utils::OpenHandle(this);
4356 if (IsDeadCheck(str->GetIsolate(), "v8::String::IsOneByte()")) { 4379 if (IsDeadCheck(str->GetIsolate(), "v8::String::IsOneByte()")) {
(...skipping 3611 matching lines...) Expand 10 before | Expand all | Expand 10 after
7968 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7991 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7969 Address callback_address = 7992 Address callback_address =
7970 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7993 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7971 VMState<EXTERNAL> state(isolate); 7994 VMState<EXTERNAL> state(isolate);
7972 ExternalCallbackScope call_scope(isolate, callback_address); 7995 ExternalCallbackScope call_scope(isolate, callback_address);
7973 return callback(info); 7996 return callback(info);
7974 } 7997 }
7975 7998
7976 7999
7977 } } // namespace v8::internal 8000 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698