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

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: Created 7 years, 5 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
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 2280 matching lines...) Expand 10 before | Expand all | Expand 10 after
4319 4332
4320 int Function::GetScriptColumnNumber() const { 4333 int Function::GetScriptColumnNumber() const {
4321 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); 4334 i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
4322 if (func->shared()->script()->IsScript()) { 4335 if (func->shared()->script()->IsScript()) {
4323 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); 4336 i::Handle<i::Script> script(i::Script::cast(func->shared()->script()));
4324 return i::GetScriptColumnNumber(script, func->shared()->start_position()); 4337 return i::GetScriptColumnNumber(script, func->shared()->start_position());
4325 } 4338 }
4326 return kLineOffsetNotFound; 4339 return kLineOffsetNotFound;
4327 } 4340 }
4328 4341
4342
4329 Handle<Value> Function::GetScriptId() const { 4343 Handle<Value> Function::GetScriptId() const {
4330 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); 4344 i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
4331 if (!func->shared()->script()->IsScript()) 4345 if (!func->shared()->script()->IsScript())
4332 return v8::Undefined(); 4346 return v8::Undefined();
4333 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); 4347 i::Handle<i::Script> script(i::Script::cast(func->shared()->script()));
4334 return Utils::ToLocal(i::Handle<i::Object>(script->id(), func->GetIsolate())); 4348 return Utils::ToLocal(i::Handle<i::Object>(script->id(), func->GetIsolate()));
4335 } 4349 }
4336 4350
4351
4352 int Function::ScriptId() const {
4353 i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
4354 if (!func->shared()->script()->IsScript())
4355 return i::Script::kNoScriptId;
yurys 2013/06/25 11:57:38 This should be a public constant.
Jakob Kummerow 2013/06/25 11:58:39 nit: {} please
loislo 2013/06/25 13:04:53 Done.
loislo 2013/06/25 13:04:53 Done.
4356 i::Handle<i::Script> script(i::Script::cast(func->shared()->script()));
4357 return script->id()->value();
4358 }
4359
4360
4337 int String::Length() const { 4361 int String::Length() const {
4338 i::Handle<i::String> str = Utils::OpenHandle(this); 4362 i::Handle<i::String> str = Utils::OpenHandle(this);
4339 if (IsDeadCheck(str->GetIsolate(), "v8::String::Length()")) return 0; 4363 if (IsDeadCheck(str->GetIsolate(), "v8::String::Length()")) return 0;
4340 return str->length(); 4364 return str->length();
4341 } 4365 }
4342 4366
4343 4367
4344 bool String::IsOneByte() const { 4368 bool String::IsOneByte() const {
4345 i::Handle<i::String> str = Utils::OpenHandle(this); 4369 i::Handle<i::String> str = Utils::OpenHandle(this);
4346 if (IsDeadCheck(str->GetIsolate(), "v8::String::IsOneByte()")) { 4370 if (IsDeadCheck(str->GetIsolate(), "v8::String::IsOneByte()")) {
(...skipping 3611 matching lines...) Expand 10 before | Expand all | Expand 10 after
7958 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7982 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7959 Address callback_address = 7983 Address callback_address =
7960 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7984 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7961 VMState<EXTERNAL> state(isolate); 7985 VMState<EXTERNAL> state(isolate);
7962 ExternalCallbackScope call_scope(isolate, callback_address); 7986 ExternalCallbackScope call_scope(isolate, callback_address);
7963 return callback(info); 7987 return callback(info);
7964 } 7988 }
7965 7989
7966 7990
7967 } } // namespace v8::internal 7991 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698