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

Side by Side Diff: src/api.cc

Issue 142813003: A64: Synchronize with r15358. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 11 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 | « src/api.h ('k') | src/arguments.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 943 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 954
955 955
956 void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) { 956 void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) {
957 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 957 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
958 if (IsDeadCheck(isolate, "v8::FunctionTemplate::Inherit()")) return; 958 if (IsDeadCheck(isolate, "v8::FunctionTemplate::Inherit()")) return;
959 ENTER_V8(isolate); 959 ENTER_V8(isolate);
960 Utils::OpenHandle(this)->set_parent_template(*Utils::OpenHandle(*value)); 960 Utils::OpenHandle(this)->set_parent_template(*Utils::OpenHandle(*value));
961 } 961 }
962 962
963 963
964 // TODO(dcarney): Remove this abstraction when old callbacks are removed.
965 class CallHandlerHelper {
966 public:
967 static inline void Set(Local<FunctionTemplate> function_template,
968 InvocationCallback callback,
969 v8::Handle<Value> data) {
970 function_template->SetCallHandlerInternal(callback, data);
971 }
972 static inline void Set(Local<FunctionTemplate> function_template,
973 FunctionCallback callback,
974 v8::Handle<Value> data) {
975 function_template->SetCallHandler(callback, data);
976 }
977 };
978
979
964 template<typename Callback> 980 template<typename Callback>
965 static Local<FunctionTemplate> FunctionTemplateNew( 981 static Local<FunctionTemplate> FunctionTemplateNew(
966 Callback callback, 982 Callback callback,
967 v8::Handle<Value> data, 983 v8::Handle<Value> data,
968 v8::Handle<Signature> signature, 984 v8::Handle<Signature> signature,
969 int length) { 985 int length) {
970 i::Isolate* isolate = i::Isolate::Current(); 986 i::Isolate* isolate = i::Isolate::Current();
971 EnsureInitializedForIsolate(isolate, "v8::FunctionTemplate::New()"); 987 EnsureInitializedForIsolate(isolate, "v8::FunctionTemplate::New()");
972 LOG_API(isolate, "FunctionTemplate::New"); 988 LOG_API(isolate, "FunctionTemplate::New");
973 ENTER_V8(isolate); 989 ENTER_V8(isolate);
974 i::Handle<i::Struct> struct_obj = 990 i::Handle<i::Struct> struct_obj =
975 isolate->factory()->NewStruct(i::FUNCTION_TEMPLATE_INFO_TYPE); 991 isolate->factory()->NewStruct(i::FUNCTION_TEMPLATE_INFO_TYPE);
976 i::Handle<i::FunctionTemplateInfo> obj = 992 i::Handle<i::FunctionTemplateInfo> obj =
977 i::Handle<i::FunctionTemplateInfo>::cast(struct_obj); 993 i::Handle<i::FunctionTemplateInfo>::cast(struct_obj);
978 InitializeFunctionTemplate(obj); 994 InitializeFunctionTemplate(obj);
979 int next_serial_number = isolate->next_serial_number(); 995 int next_serial_number = isolate->next_serial_number();
980 isolate->set_next_serial_number(next_serial_number + 1); 996 isolate->set_next_serial_number(next_serial_number + 1);
981 obj->set_serial_number(i::Smi::FromInt(next_serial_number)); 997 obj->set_serial_number(i::Smi::FromInt(next_serial_number));
982 if (callback != 0) { 998 if (callback != 0) {
983 if (data.IsEmpty()) data = v8::Undefined(); 999 if (data.IsEmpty()) data = v8::Undefined();
984 Utils::ToLocal(obj)->SetCallHandler(callback, data); 1000 CallHandlerHelper::Set(Utils::ToLocal(obj), callback, data);
985 } 1001 }
986 obj->set_length(length); 1002 obj->set_length(length);
987 obj->set_undetectable(false); 1003 obj->set_undetectable(false);
988 obj->set_needs_access_check(false); 1004 obj->set_needs_access_check(false);
989 1005
990 if (!signature.IsEmpty()) 1006 if (!signature.IsEmpty())
991 obj->set_signature(*Utils::OpenHandle(*signature)); 1007 obj->set_signature(*Utils::OpenHandle(*signature));
992 return Utils::ToLocal(obj); 1008 return Utils::ToLocal(obj);
993 } 1009 }
994 1010
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 if (data.IsEmpty()) data = v8::Undefined(); 1234 if (data.IsEmpty()) data = v8::Undefined();
1219 obj->set_data(*Utils::OpenHandle(*data)); 1235 obj->set_data(*Utils::OpenHandle(*data));
1220 Utils::OpenHandle(function_template)->set_call_code(*obj); 1236 Utils::OpenHandle(function_template)->set_call_code(*obj);
1221 } 1237 }
1222 1238
1223 void FunctionTemplate::SetCallHandler(InvocationCallback callback, 1239 void FunctionTemplate::SetCallHandler(InvocationCallback callback,
1224 v8::Handle<Value> data) { 1240 v8::Handle<Value> data) {
1225 FunctionTemplateSetCallHandler(this, callback, data); 1241 FunctionTemplateSetCallHandler(this, callback, data);
1226 } 1242 }
1227 1243
1244 void FunctionTemplate::SetCallHandlerInternal(InvocationCallback callback,
1245 v8::Handle<Value> data) {
1246 FunctionTemplateSetCallHandler(this, callback, data);
1247 }
1248
1228 void FunctionTemplate::SetCallHandler(FunctionCallback callback, 1249 void FunctionTemplate::SetCallHandler(FunctionCallback callback,
1229 v8::Handle<Value> data) { 1250 v8::Handle<Value> data) {
1230 FunctionTemplateSetCallHandler(this, callback, data); 1251 FunctionTemplateSetCallHandler(this, callback, data);
1231 } 1252 }
1232 1253
1233 static i::Handle<i::AccessorInfo> SetAccessorInfoProperties( 1254 static i::Handle<i::AccessorInfo> SetAccessorInfoProperties(
1234 i::Handle<i::AccessorInfo> obj, 1255 i::Handle<i::AccessorInfo> obj,
1235 v8::Handle<String> name, 1256 v8::Handle<String> name,
1236 v8::AccessControl settings, 1257 v8::AccessControl settings,
1237 v8::PropertyAttribute attributes, 1258 v8::PropertyAttribute attributes,
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
1998 i::Handle<i::SharedFunctionInfo> function_info = OpenScript(this); 2019 i::Handle<i::SharedFunctionInfo> function_info = OpenScript(this);
1999 i::Handle<i::Script> script(i::Script::cast(function_info->script())); 2020 i::Handle<i::Script> script(i::Script::cast(function_info->script()));
2000 i::Handle<i::Object> id(script->id(), isolate); 2021 i::Handle<i::Object> id(script->id(), isolate);
2001 raw_id = *id; 2022 raw_id = *id;
2002 } 2023 }
2003 i::Handle<i::Object> id(raw_id, isolate); 2024 i::Handle<i::Object> id(raw_id, isolate);
2004 return Utils::ToLocal(id); 2025 return Utils::ToLocal(id);
2005 } 2026 }
2006 2027
2007 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
2008 int Script::GetLineNumber(int code_pos) { 2042 int Script::GetLineNumber(int code_pos) {
2009 i::Isolate* isolate = i::Isolate::Current(); 2043 i::Isolate* isolate = i::Isolate::Current();
2010 ON_BAILOUT(isolate, "v8::Script::GetLineNumber()", return -1); 2044 ON_BAILOUT(isolate, "v8::Script::GetLineNumber()", return -1);
2011 LOG_API(isolate, "Script::GetLineNumber"); 2045 LOG_API(isolate, "Script::GetLineNumber");
2012 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2046 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2013 if (obj->IsScript()) { 2047 if (obj->IsScript()) {
2014 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));
2015 return i::GetScriptLineNumber(script, code_pos); 2049 return i::GetScriptLineNumber(script, code_pos);
2016 } else { 2050 } else {
2017 return -1; 2051 return -1;
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
2566 } 2600 }
2567 2601
2568 2602
2569 bool Value::IsArrayBuffer() const { 2603 bool Value::IsArrayBuffer() const {
2570 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsArrayBuffer()")) 2604 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsArrayBuffer()"))
2571 return false; 2605 return false;
2572 return Utils::OpenHandle(this)->IsJSArrayBuffer(); 2606 return Utils::OpenHandle(this)->IsJSArrayBuffer();
2573 } 2607 }
2574 2608
2575 2609
2610 bool Value::IsArrayBufferView() const {
2611 return Utils::OpenHandle(this)->IsJSArrayBufferView();
2612 }
2613
2614
2576 bool Value::IsTypedArray() const { 2615 bool Value::IsTypedArray() const {
2577 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsArrayBuffer()")) 2616 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsArrayBuffer()"))
2578 return false; 2617 return false;
2579 return Utils::OpenHandle(this)->IsJSTypedArray(); 2618 return Utils::OpenHandle(this)->IsJSTypedArray();
2580 } 2619 }
2581 2620
2582 2621
2583 #define TYPED_ARRAY_LIST(F) \ 2622 #define TYPED_ARRAY_LIST(F) \
2584 F(Uint8Array, kExternalUnsignedByteArray) \ 2623 F(Uint8Array, kExternalUnsignedByteArray) \
2585 F(Int8Array, kExternalByteArray) \ 2624 F(Int8Array, kExternalByteArray) \
(...skipping 13 matching lines...) Expand all
2599 i::Handle<i::Object> obj = Utils::OpenHandle(this); \ 2638 i::Handle<i::Object> obj = Utils::OpenHandle(this); \
2600 if (!obj->IsJSTypedArray()) return false; \ 2639 if (!obj->IsJSTypedArray()) return false; \
2601 return i::JSTypedArray::cast(*obj)->type() == type_const; \ 2640 return i::JSTypedArray::cast(*obj)->type() == type_const; \
2602 } 2641 }
2603 2642
2604 TYPED_ARRAY_LIST(VALUE_IS_TYPED_ARRAY) 2643 TYPED_ARRAY_LIST(VALUE_IS_TYPED_ARRAY)
2605 2644
2606 #undef VALUE_IS_TYPED_ARRAY 2645 #undef VALUE_IS_TYPED_ARRAY
2607 2646
2608 2647
2648 bool Value::IsDataView() const {
2649 return Utils::OpenHandle(this)->IsJSDataView();
2650 }
2651
2652
2609 bool Value::IsObject() const { 2653 bool Value::IsObject() const {
2610 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsObject()")) return false; 2654 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsObject()")) return false;
2611 return Utils::OpenHandle(this)->IsJSObject(); 2655 return Utils::OpenHandle(this)->IsJSObject();
2612 } 2656 }
2613 2657
2614 2658
2615 bool Value::IsNumber() const { 2659 bool Value::IsNumber() const {
2616 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsNumber()")) return false; 2660 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsNumber()")) return false;
2617 return Utils::OpenHandle(this)->IsNumber(); 2661 return Utils::OpenHandle(this)->IsNumber();
2618 } 2662 }
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
2865 LOG_API(isolate, "ToInteger"); 2909 LOG_API(isolate, "ToInteger");
2866 ENTER_V8(isolate); 2910 ENTER_V8(isolate);
2867 EXCEPTION_PREAMBLE(isolate); 2911 EXCEPTION_PREAMBLE(isolate);
2868 num = i::Execution::ToInteger(obj, &has_pending_exception); 2912 num = i::Execution::ToInteger(obj, &has_pending_exception);
2869 EXCEPTION_BAILOUT_CHECK(isolate, Local<Integer>()); 2913 EXCEPTION_BAILOUT_CHECK(isolate, Local<Integer>());
2870 } 2914 }
2871 return ToApiHandle<Integer>(num); 2915 return ToApiHandle<Integer>(num);
2872 } 2916 }
2873 2917
2874 2918
2919 #ifdef V8_ENABLE_CHECKS
2920 void i::Internals::CheckInitialized(v8::Isolate* external_isolate) {
2921 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate);
2922 ApiCheck(isolate != NULL && isolate->IsInitialized() && !i::V8::IsDead(),
2923 "v8::internal::Internals::CheckInitialized()",
2924 "Isolate is not initialized or V8 has died");
2925 }
2926 #endif
2927
2928
2875 void External::CheckCast(v8::Value* that) { 2929 void External::CheckCast(v8::Value* that) {
2876 if (IsDeadCheck(i::Isolate::Current(), "v8::External::Cast()")) return; 2930 if (IsDeadCheck(i::Isolate::Current(), "v8::External::Cast()")) return;
2877 ApiCheck(Utils::OpenHandle(that)->IsExternal(), 2931 ApiCheck(Utils::OpenHandle(that)->IsExternal(),
2878 "v8::External::Cast()", 2932 "v8::External::Cast()",
2879 "Could not convert to external"); 2933 "Could not convert to external");
2880 } 2934 }
2881 2935
2882 2936
2883 void v8::Object::CheckCast(Value* that) { 2937 void v8::Object::CheckCast(Value* that) {
2884 if (IsDeadCheck(i::Isolate::Current(), "v8::Object::Cast()")) return; 2938 if (IsDeadCheck(i::Isolate::Current(), "v8::Object::Cast()")) return;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2945 2999
2946 void v8::ArrayBuffer::CheckCast(Value* that) { 3000 void v8::ArrayBuffer::CheckCast(Value* that) {
2947 if (IsDeadCheck(i::Isolate::Current(), "v8::ArrayBuffer::Cast()")) return; 3001 if (IsDeadCheck(i::Isolate::Current(), "v8::ArrayBuffer::Cast()")) return;
2948 i::Handle<i::Object> obj = Utils::OpenHandle(that); 3002 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2949 ApiCheck(obj->IsJSArrayBuffer(), 3003 ApiCheck(obj->IsJSArrayBuffer(),
2950 "v8::ArrayBuffer::Cast()", 3004 "v8::ArrayBuffer::Cast()",
2951 "Could not convert to ArrayBuffer"); 3005 "Could not convert to ArrayBuffer");
2952 } 3006 }
2953 3007
2954 3008
3009 void v8::ArrayBufferView::CheckCast(Value* that) {
3010 i::Handle<i::Object> obj = Utils::OpenHandle(that);
3011 ApiCheck(obj->IsJSArrayBufferView(),
3012 "v8::ArrayBufferView::Cast()",
3013 "Could not convert to ArrayBufferView");
3014 }
3015
3016
2955 void v8::TypedArray::CheckCast(Value* that) { 3017 void v8::TypedArray::CheckCast(Value* that) {
2956 if (IsDeadCheck(i::Isolate::Current(), "v8::TypedArray::Cast()")) return; 3018 if (IsDeadCheck(i::Isolate::Current(), "v8::TypedArray::Cast()")) return;
2957 i::Handle<i::Object> obj = Utils::OpenHandle(that); 3019 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2958 ApiCheck(obj->IsJSTypedArray(), 3020 ApiCheck(obj->IsJSTypedArray(),
2959 "v8::TypedArray::Cast()", 3021 "v8::TypedArray::Cast()",
2960 "Could not convert to TypedArray"); 3022 "Could not convert to TypedArray");
2961 } 3023 }
2962 3024
2963 3025
2964 #define CHECK_TYPED_ARRAY_CAST(ApiClass, typeConst) \ 3026 #define CHECK_TYPED_ARRAY_CAST(ApiClass, typeConst) \
2965 void v8::ApiClass::CheckCast(Value* that) { \ 3027 void v8::ApiClass::CheckCast(Value* that) { \
2966 if (IsDeadCheck(i::Isolate::Current(), "v8::" #ApiClass "::Cast()")) \ 3028 if (IsDeadCheck(i::Isolate::Current(), "v8::" #ApiClass "::Cast()")) \
2967 return; \ 3029 return; \
2968 i::Handle<i::Object> obj = Utils::OpenHandle(that); \ 3030 i::Handle<i::Object> obj = Utils::OpenHandle(that); \
2969 ApiCheck(obj->IsJSTypedArray() && \ 3031 ApiCheck(obj->IsJSTypedArray() && \
2970 i::JSTypedArray::cast(*obj)->type() == typeConst, \ 3032 i::JSTypedArray::cast(*obj)->type() == typeConst, \
2971 "v8::" #ApiClass "::Cast()", \ 3033 "v8::" #ApiClass "::Cast()", \
2972 "Could not convert to " #ApiClass); \ 3034 "Could not convert to " #ApiClass); \
2973 } 3035 }
2974 3036
2975 3037
2976 TYPED_ARRAY_LIST(CHECK_TYPED_ARRAY_CAST) 3038 TYPED_ARRAY_LIST(CHECK_TYPED_ARRAY_CAST)
2977 3039
2978 #undef CHECK_TYPED_ARRAY_CAST 3040 #undef CHECK_TYPED_ARRAY_CAST
2979 3041
2980 3042
3043 void v8::DataView::CheckCast(Value* that) {
3044 i::Handle<i::Object> obj = Utils::OpenHandle(that);
3045 ApiCheck(obj->IsJSDataView(),
3046 "v8::DataView::Cast()",
3047 "Could not convert to DataView");
3048 }
3049
3050
2981 void v8::Date::CheckCast(v8::Value* that) { 3051 void v8::Date::CheckCast(v8::Value* that) {
2982 i::Isolate* isolate = i::Isolate::Current(); 3052 i::Isolate* isolate = i::Isolate::Current();
2983 if (IsDeadCheck(isolate, "v8::Date::Cast()")) return; 3053 if (IsDeadCheck(isolate, "v8::Date::Cast()")) return;
2984 i::Handle<i::Object> obj = Utils::OpenHandle(that); 3054 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2985 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Date_string()), 3055 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Date_string()),
2986 "v8::Date::Cast()", 3056 "v8::Date::Cast()",
2987 "Could not convert to date"); 3057 "Could not convert to date");
2988 } 3058 }
2989 3059
2990 3060
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after
3858 v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Handle<v8::String> key) { 3928 v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Handle<v8::String> key) {
3859 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3929 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3860 ON_BAILOUT(isolate, "v8::Object::GetHiddenValue()", 3930 ON_BAILOUT(isolate, "v8::Object::GetHiddenValue()",
3861 return Local<v8::Value>()); 3931 return Local<v8::Value>());
3862 ENTER_V8(isolate); 3932 ENTER_V8(isolate);
3863 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3933 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3864 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 3934 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
3865 i::Handle<i::String> key_string = 3935 i::Handle<i::String> key_string =
3866 isolate->factory()->InternalizeString(key_obj); 3936 isolate->factory()->InternalizeString(key_obj);
3867 i::Handle<i::Object> result(self->GetHiddenProperty(*key_string), isolate); 3937 i::Handle<i::Object> result(self->GetHiddenProperty(*key_string), isolate);
3868 if (result->IsUndefined()) return v8::Local<v8::Value>(); 3938 if (result->IsTheHole()) return v8::Local<v8::Value>();
3869 return Utils::ToLocal(result); 3939 return Utils::ToLocal(result);
3870 } 3940 }
3871 3941
3872 3942
3873 bool v8::Object::DeleteHiddenValue(v8::Handle<v8::String> key) { 3943 bool v8::Object::DeleteHiddenValue(v8::Handle<v8::String> key) {
3874 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3944 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3875 ON_BAILOUT(isolate, "v8::DeleteHiddenValue()", return false); 3945 ON_BAILOUT(isolate, "v8::DeleteHiddenValue()", return false);
3876 ENTER_V8(isolate); 3946 ENTER_V8(isolate);
3877 i::HandleScope scope(isolate); 3947 i::HandleScope scope(isolate);
3878 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3948 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
4272 4342
4273 int Function::GetScriptColumnNumber() const { 4343 int Function::GetScriptColumnNumber() const {
4274 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); 4344 i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
4275 if (func->shared()->script()->IsScript()) { 4345 if (func->shared()->script()->IsScript()) {
4276 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); 4346 i::Handle<i::Script> script(i::Script::cast(func->shared()->script()));
4277 return i::GetScriptColumnNumber(script, func->shared()->start_position()); 4347 return i::GetScriptColumnNumber(script, func->shared()->start_position());
4278 } 4348 }
4279 return kLineOffsetNotFound; 4349 return kLineOffsetNotFound;
4280 } 4350 }
4281 4351
4352
4282 Handle<Value> Function::GetScriptId() const { 4353 Handle<Value> Function::GetScriptId() const {
4283 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); 4354 i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
4284 if (!func->shared()->script()->IsScript()) 4355 if (!func->shared()->script()->IsScript())
4285 return v8::Undefined(); 4356 return v8::Undefined();
4286 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); 4357 i::Handle<i::Script> script(i::Script::cast(func->shared()->script()));
4287 return Utils::ToLocal(i::Handle<i::Object>(script->id(), func->GetIsolate())); 4358 return Utils::ToLocal(i::Handle<i::Object>(script->id(), func->GetIsolate()));
4288 } 4359 }
4289 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
4290 int String::Length() const { 4370 int String::Length() const {
4291 i::Handle<i::String> str = Utils::OpenHandle(this); 4371 i::Handle<i::String> str = Utils::OpenHandle(this);
4292 if (IsDeadCheck(str->GetIsolate(), "v8::String::Length()")) return 0; 4372 if (IsDeadCheck(str->GetIsolate(), "v8::String::Length()")) return 0;
4293 return str->length(); 4373 return str->length();
4294 } 4374 }
4295 4375
4296 4376
4297 bool String::IsOneByte() const { 4377 bool String::IsOneByte() const {
4298 i::Handle<i::String> str = Utils::OpenHandle(this); 4378 i::Handle<i::String> str = Utils::OpenHandle(this);
4299 if (IsDeadCheck(str->GetIsolate(), "v8::String::IsOneByte()")) { 4379 if (IsDeadCheck(str->GetIsolate(), "v8::String::IsOneByte()")) {
(...skipping 1854 matching lines...) Expand 10 before | Expand all | Expand 10 after
6154 6234
6155 void v8::ArrayBuffer::Neuter() { 6235 void v8::ArrayBuffer::Neuter() {
6156 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); 6236 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this);
6157 i::Isolate* isolate = obj->GetIsolate(); 6237 i::Isolate* isolate = obj->GetIsolate();
6158 ApiCheck(obj->is_external(), 6238 ApiCheck(obj->is_external(),
6159 "v8::ArrayBuffer::Neuter", 6239 "v8::ArrayBuffer::Neuter",
6160 "Only externalized ArrayBuffers can be neutered"); 6240 "Only externalized ArrayBuffers can be neutered");
6161 LOG_API(obj->GetIsolate(), "v8::ArrayBuffer::Neuter()"); 6241 LOG_API(obj->GetIsolate(), "v8::ArrayBuffer::Neuter()");
6162 ENTER_V8(isolate); 6242 ENTER_V8(isolate);
6163 6243
6164 for (i::Handle<i::Object> array_obj(obj->weak_first_array(), isolate); 6244 for (i::Handle<i::Object> view_obj(obj->weak_first_view(), isolate);
6165 !array_obj->IsUndefined();) { 6245 !view_obj->IsUndefined();) {
6166 i::Handle<i::JSTypedArray> typed_array(i::JSTypedArray::cast(*array_obj)); 6246 i::Handle<i::JSArrayBufferView> view(i::JSArrayBufferView::cast(*view_obj));
6167 typed_array->Neuter(); 6247 if (view->IsJSTypedArray()) {
6168 array_obj = i::handle(typed_array->weak_next(), isolate); 6248 i::JSTypedArray::cast(*view)->Neuter();
6249 } else if (view->IsJSDataView()) {
6250 i::JSDataView::cast(*view)->Neuter();
6251 } else {
6252 UNREACHABLE();
6253 }
6254 view_obj = i::handle(view->weak_next(), isolate);
6169 } 6255 }
6170 obj->Neuter(); 6256 obj->Neuter();
6171 } 6257 }
6172 6258
6173 6259
6174 size_t v8::ArrayBuffer::ByteLength() const { 6260 size_t v8::ArrayBuffer::ByteLength() const {
6175 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 6261 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
6176 if (IsDeadCheck(isolate, "v8::ArrayBuffer::ByteLength()")) return 0; 6262 if (IsDeadCheck(isolate, "v8::ArrayBuffer::ByteLength()")) return 0;
6177 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); 6263 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this);
6178 return static_cast<size_t>(obj->byte_length()->Number()); 6264 return static_cast<size_t>(obj->byte_length()->Number());
(...skipping 17 matching lines...) Expand all
6196 EnsureInitializedForIsolate(isolate, "v8::ArrayBuffer::New(void*, size_t)"); 6282 EnsureInitializedForIsolate(isolate, "v8::ArrayBuffer::New(void*, size_t)");
6197 LOG_API(isolate, "v8::ArrayBuffer::New(void*, size_t)"); 6283 LOG_API(isolate, "v8::ArrayBuffer::New(void*, size_t)");
6198 ENTER_V8(isolate); 6284 ENTER_V8(isolate);
6199 i::Handle<i::JSArrayBuffer> obj = 6285 i::Handle<i::JSArrayBuffer> obj =
6200 isolate->factory()->NewJSArrayBuffer(); 6286 isolate->factory()->NewJSArrayBuffer();
6201 i::Runtime::SetupArrayBuffer(isolate, obj, true, data, byte_length); 6287 i::Runtime::SetupArrayBuffer(isolate, obj, true, data, byte_length);
6202 return Utils::ToLocal(obj); 6288 return Utils::ToLocal(obj);
6203 } 6289 }
6204 6290
6205 6291
6206 Local<ArrayBuffer> v8::TypedArray::Buffer() { 6292 Local<ArrayBuffer> v8::ArrayBufferView::Buffer() {
6207 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 6293 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this);
6208 if (IsDeadCheck(isolate, "v8::TypedArray::Buffer()"))
6209 return Local<ArrayBuffer>();
6210 i::Handle<i::JSTypedArray> obj = Utils::OpenHandle(this);
6211 ASSERT(obj->buffer()->IsJSArrayBuffer()); 6294 ASSERT(obj->buffer()->IsJSArrayBuffer());
6212 i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(obj->buffer())); 6295 i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(obj->buffer()));
6213 return Utils::ToLocal(buffer); 6296 return Utils::ToLocal(buffer);
6214 } 6297 }
6215 6298
6216 6299
6217 size_t v8::TypedArray::ByteOffset() { 6300 size_t v8::ArrayBufferView::ByteOffset() {
6218 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 6301 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this);
6219 if (IsDeadCheck(isolate, "v8::TypedArray::ByteOffset()")) return 0;
6220 i::Handle<i::JSTypedArray> obj = Utils::OpenHandle(this);
6221 return static_cast<size_t>(obj->byte_offset()->Number()); 6302 return static_cast<size_t>(obj->byte_offset()->Number());
6222 } 6303 }
6223 6304
6224 6305
6225 size_t v8::TypedArray::ByteLength() { 6306 size_t v8::ArrayBufferView::ByteLength() {
6226 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 6307 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this);
6227 if (IsDeadCheck(isolate, "v8::TypedArray::ByteLength()")) return 0;
6228 i::Handle<i::JSTypedArray> obj = Utils::OpenHandle(this);
6229 return static_cast<size_t>(obj->byte_length()->Number()); 6308 return static_cast<size_t>(obj->byte_length()->Number());
6230 } 6309 }
6231 6310
6232 6311
6312 void* v8::ArrayBufferView::BaseAddress() {
6313 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this);
6314 i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(obj->buffer()));
6315 void* buffer_data = buffer->backing_store();
6316 size_t byte_offset = static_cast<size_t>(obj->byte_offset()->Number());
6317 return static_cast<uint8_t*>(buffer_data) + byte_offset;
6318 }
6319
6320
6233 size_t v8::TypedArray::Length() { 6321 size_t v8::TypedArray::Length() {
6234 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 6322 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
6235 if (IsDeadCheck(isolate, "v8::TypedArray::Length()")) return 0; 6323 if (IsDeadCheck(isolate, "v8::TypedArray::Length()")) return 0;
6236 i::Handle<i::JSTypedArray> obj = Utils::OpenHandle(this); 6324 i::Handle<i::JSTypedArray> obj = Utils::OpenHandle(this);
6237 return static_cast<size_t>(obj->length()->Number()); 6325 return static_cast<size_t>(obj->length()->Number());
6238 } 6326 }
6239 6327
6240 6328
6241 void* v8::TypedArray::BaseAddress() { 6329 static inline void SetupArrayBufferView(
6242 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 6330 i::Isolate* isolate,
6243 if (IsDeadCheck(isolate, "v8::TypedArray::BaseAddress()")) return NULL; 6331 i::Handle<i::JSArrayBufferView> obj,
6244 i::Handle<i::JSTypedArray> obj = Utils::OpenHandle(this); 6332 i::Handle<i::JSArrayBuffer> buffer,
6245 i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(obj->buffer())); 6333 size_t byte_offset,
6246 void* buffer_data = buffer->backing_store(); 6334 size_t byte_length) {
6247 size_t byte_offset = static_cast<size_t>(obj->byte_offset()->Number()); 6335 ASSERT(byte_offset + byte_length <=
6248 return static_cast<uint8_t*>(buffer_data) + byte_offset; 6336 static_cast<size_t>(buffer->byte_length()->Number()));
6337
6338 obj->set_buffer(*buffer);
6339
6340 obj->set_weak_next(buffer->weak_first_view());
6341 buffer->set_weak_first_view(*obj);
6342
6343 i::Handle<i::Object> byte_offset_object =
6344 isolate->factory()->NewNumberFromSize(byte_offset);
6345 obj->set_byte_offset(*byte_offset_object);
6346
6347 i::Handle<i::Object> byte_length_object =
6348 isolate->factory()->NewNumberFromSize(byte_length);
6349 obj->set_byte_length(*byte_length_object);
6249 } 6350 }
6250 6351
6251
6252 template<typename ElementType, 6352 template<typename ElementType,
6253 ExternalArrayType array_type, 6353 ExternalArrayType array_type,
6254 i::ElementsKind elements_kind> 6354 i::ElementsKind elements_kind>
6255 i::Handle<i::JSTypedArray> NewTypedArray( 6355 i::Handle<i::JSTypedArray> NewTypedArray(
6256 i::Isolate* isolate, 6356 i::Isolate* isolate,
6257 Handle<ArrayBuffer> array_buffer, size_t byte_offset, size_t length) { 6357 Handle<ArrayBuffer> array_buffer, size_t byte_offset, size_t length) {
6258 i::Handle<i::JSTypedArray> obj = 6358 i::Handle<i::JSTypedArray> obj =
6259 isolate->factory()->NewJSTypedArray(array_type); 6359 isolate->factory()->NewJSTypedArray(array_type);
6260 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer); 6360 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer);
6261 6361
6262 ASSERT(byte_offset % sizeof(ElementType) == 0); 6362 ASSERT(byte_offset % sizeof(ElementType) == 0);
6263 ASSERT(byte_offset + length * sizeof(ElementType) <=
6264 static_cast<size_t>(buffer->byte_length()->Number()));
6265 6363
6266 obj->set_buffer(*buffer); 6364 SetupArrayBufferView(
6365 isolate, obj, buffer, byte_offset, length * sizeof(ElementType));
6267 6366
6268 obj->set_weak_next(buffer->weak_first_array()); 6367 i::Handle<i::Object> length_object =
6269 buffer->set_weak_first_array(*obj); 6368 isolate->factory()->NewNumberFromSize(length);
6270
6271 i::Handle<i::Object> byte_offset_object = isolate->factory()->NewNumber(
6272 static_cast<double>(byte_offset));
6273 obj->set_byte_offset(*byte_offset_object);
6274
6275 i::Handle<i::Object> byte_length_object = isolate->factory()->NewNumber(
6276 static_cast<double>(length * sizeof(ElementType)));
6277 obj->set_byte_length(*byte_length_object);
6278
6279 i::Handle<i::Object> length_object = isolate->factory()->NewNumber(
6280 static_cast<double>(length));
6281 obj->set_length(*length_object); 6369 obj->set_length(*length_object);
6282 6370
6283 i::Handle<i::ExternalArray> elements = 6371 i::Handle<i::ExternalArray> elements =
6284 isolate->factory()->NewExternalArray( 6372 isolate->factory()->NewExternalArray(
6285 static_cast<int>(length), array_type, 6373 static_cast<int>(length), array_type,
6286 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset); 6374 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset);
6287 obj->set_elements(*elements); 6375 obj->set_elements(*elements);
6288 return obj; 6376 return obj;
6289 } 6377 }
6290 6378
(...skipping 28 matching lines...) Expand all
6319 i::EXTERNAL_UNSIGNED_INT_ELEMENTS) 6407 i::EXTERNAL_UNSIGNED_INT_ELEMENTS)
6320 TYPED_ARRAY_NEW(Int32Array, int32_t, kExternalIntArray, 6408 TYPED_ARRAY_NEW(Int32Array, int32_t, kExternalIntArray,
6321 i::EXTERNAL_INT_ELEMENTS) 6409 i::EXTERNAL_INT_ELEMENTS)
6322 TYPED_ARRAY_NEW(Float32Array, float, kExternalFloatArray, 6410 TYPED_ARRAY_NEW(Float32Array, float, kExternalFloatArray,
6323 i::EXTERNAL_FLOAT_ELEMENTS) 6411 i::EXTERNAL_FLOAT_ELEMENTS)
6324 TYPED_ARRAY_NEW(Float64Array, double, kExternalDoubleArray, 6412 TYPED_ARRAY_NEW(Float64Array, double, kExternalDoubleArray,
6325 i::EXTERNAL_DOUBLE_ELEMENTS) 6413 i::EXTERNAL_DOUBLE_ELEMENTS)
6326 6414
6327 #undef TYPED_ARRAY_NEW 6415 #undef TYPED_ARRAY_NEW
6328 6416
6417 Local<DataView> DataView::New(Handle<ArrayBuffer> array_buffer,
6418 size_t byte_offset, size_t byte_length) {
6419 i::Isolate* isolate = i::Isolate::Current();
6420 EnsureInitializedForIsolate(
6421 isolate, "v8::DataView::New(void*, size_t, size_t)");
6422 LOG_API(isolate, "v8::DataView::New(void*, size_t, size_t)");
6423 ENTER_V8(isolate);
6424 i::Handle<i::JSDataView> obj = isolate->factory()->NewJSDataView();
6425 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer);
6426 SetupArrayBufferView(
6427 isolate, obj, buffer, byte_offset, byte_length);
6428 return Utils::ToLocal(obj);
6429 }
6430
6329 6431
6330 Local<Symbol> v8::Symbol::New(Isolate* isolate) { 6432 Local<Symbol> v8::Symbol::New(Isolate* isolate) {
6331 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6433 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6332 EnsureInitializedForIsolate(i_isolate, "v8::Symbol::New()"); 6434 EnsureInitializedForIsolate(i_isolate, "v8::Symbol::New()");
6333 LOG_API(i_isolate, "Symbol::New()"); 6435 LOG_API(i_isolate, "Symbol::New()");
6334 ENTER_V8(i_isolate); 6436 ENTER_V8(i_isolate);
6335 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol(); 6437 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol();
6336 return Utils::ToLocal(result); 6438 return Utils::ToLocal(result);
6337 } 6439 }
6338 6440
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
6531 6633
6532 CpuProfiler* Isolate::GetCpuProfiler() { 6634 CpuProfiler* Isolate::GetCpuProfiler() {
6533 i::CpuProfiler* cpu_profiler = 6635 i::CpuProfiler* cpu_profiler =
6534 reinterpret_cast<i::Isolate*>(this)->cpu_profiler(); 6636 reinterpret_cast<i::Isolate*>(this)->cpu_profiler();
6535 return reinterpret_cast<CpuProfiler*>(cpu_profiler); 6637 return reinterpret_cast<CpuProfiler*>(cpu_profiler);
6536 } 6638 }
6537 6639
6538 6640
6539 v8::Local<v8::Context> Isolate::GetCurrentContext() { 6641 v8::Local<v8::Context> Isolate::GetCurrentContext() {
6540 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(this); 6642 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(this);
6541 i::Handle<i::Object> current = internal_isolate->native_context(); 6643 i::Context* context = internal_isolate->context();
6542 if (current.is_null()) return Local<Context>(); 6644 if (context == NULL) return Local<Context>();
6543 i::Handle<i::Context> context = i::Handle<i::Context>::cast(current); 6645 i::Context* native_context = context->global_object()->native_context();
6544 return Utils::ToLocal(context); 6646 if (native_context == NULL) return Local<Context>();
6647 return Utils::ToLocal(i::Handle<i::Context>(native_context));
6545 } 6648 }
6546 6649
6547 6650
6548 void Isolate::SetObjectGroupId(const Persistent<Value>& object, 6651 void Isolate::SetObjectGroupId(const Persistent<Value>& object,
6549 UniqueId id) { 6652 UniqueId id) {
6550 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(this); 6653 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(this);
6551 internal_isolate->global_handles()->SetObjectGroupId( 6654 internal_isolate->global_handles()->SetObjectGroupId(
6552 Utils::OpenPersistent(object).location(), 6655 Utils::OpenPersistent(object).location(),
6553 id); 6656 id);
6554 } 6657 }
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
7297 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); 7400 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
7298 return reinterpret_cast<const CpuProfileNode*>(profile->sample(index)); 7401 return reinterpret_cast<const CpuProfileNode*>(profile->sample(index));
7299 } 7402 }
7300 7403
7301 7404
7302 int CpuProfile::GetSamplesCount() const { 7405 int CpuProfile::GetSamplesCount() const {
7303 return reinterpret_cast<const i::CpuProfile*>(this)->samples_count(); 7406 return reinterpret_cast<const i::CpuProfile*>(this)->samples_count();
7304 } 7407 }
7305 7408
7306 7409
7307 int CpuProfiler::GetProfilesCount() {
7308 i::Isolate* isolate = i::Isolate::Current();
7309 IsDeadCheck(isolate, "v8::CpuProfiler::GetProfilesCount");
7310 i::CpuProfiler* profiler = isolate->cpu_profiler();
7311 ASSERT(profiler != NULL);
7312 return profiler->GetProfilesCount();
7313 }
7314
7315
7316 int CpuProfiler::GetProfileCount() { 7410 int CpuProfiler::GetProfileCount() {
7317 return reinterpret_cast<i::CpuProfiler*>(this)->GetProfilesCount(); 7411 return reinterpret_cast<i::CpuProfiler*>(this)->GetProfilesCount();
7318 } 7412 }
7319 7413
7320 7414
7321 const CpuProfile* CpuProfiler::GetProfile(int index,
7322 Handle<Value> security_token) {
7323 i::Isolate* isolate = i::Isolate::Current();
7324 IsDeadCheck(isolate, "v8::CpuProfiler::GetProfile");
7325 i::CpuProfiler* profiler = isolate->cpu_profiler();
7326 ASSERT(profiler != NULL);
7327 return reinterpret_cast<const CpuProfile*>(
7328 profiler->GetProfile(
7329 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
7330 index));
7331 }
7332
7333
7334 const CpuProfile* CpuProfiler::GetCpuProfile(int index, 7415 const CpuProfile* CpuProfiler::GetCpuProfile(int index,
7335 Handle<Value> security_token) { 7416 Handle<Value> security_token) {
7336 return reinterpret_cast<const CpuProfile*>( 7417 return reinterpret_cast<const CpuProfile*>(
7337 reinterpret_cast<i::CpuProfiler*>(this)->GetProfile( 7418 reinterpret_cast<i::CpuProfiler*>(this)->GetProfile(
7338 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), 7419 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
7339 index)); 7420 index));
7340 } 7421 }
7341 7422
7342 7423
7343 const CpuProfile* CpuProfiler::GetCpuProfile(int index) { 7424 const CpuProfile* CpuProfiler::GetCpuProfile(int index) {
7344 return reinterpret_cast<const CpuProfile*>( 7425 return reinterpret_cast<const CpuProfile*>(
7345 reinterpret_cast<i::CpuProfiler*>(this)->GetProfile(NULL, index)); 7426 reinterpret_cast<i::CpuProfiler*>(this)->GetProfile(NULL, index));
7346 } 7427 }
7347 7428
7348 7429
7349 const CpuProfile* CpuProfiler::FindProfile(unsigned uid,
7350 Handle<Value> security_token) {
7351 i::Isolate* isolate = i::Isolate::Current();
7352 IsDeadCheck(isolate, "v8::CpuProfiler::FindProfile");
7353 i::CpuProfiler* profiler = isolate->cpu_profiler();
7354 ASSERT(profiler != NULL);
7355 return reinterpret_cast<const CpuProfile*>(
7356 profiler->FindProfile(
7357 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
7358 uid));
7359 }
7360
7361
7362 const CpuProfile* CpuProfiler::FindCpuProfile(unsigned uid, 7430 const CpuProfile* CpuProfiler::FindCpuProfile(unsigned uid,
7363 Handle<Value> security_token) { 7431 Handle<Value> security_token) {
7364 return reinterpret_cast<const CpuProfile*>( 7432 return reinterpret_cast<const CpuProfile*>(
7365 reinterpret_cast<i::CpuProfiler*>(this)->FindProfile( 7433 reinterpret_cast<i::CpuProfiler*>(this)->FindProfile(
7366 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), 7434 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
7367 uid)); 7435 uid));
7368 } 7436 }
7369 7437
7370 7438
7371 void CpuProfiler::StartProfiling(Handle<String> title, bool record_samples) {
7372 i::Isolate* isolate = i::Isolate::Current();
7373 IsDeadCheck(isolate, "v8::CpuProfiler::StartProfiling");
7374 i::CpuProfiler* profiler = isolate->cpu_profiler();
7375 ASSERT(profiler != NULL);
7376 profiler->StartProfiling(*Utils::OpenHandle(*title), record_samples);
7377 }
7378
7379
7380 void CpuProfiler::StartCpuProfiling(Handle<String> title, bool record_samples) { 7439 void CpuProfiler::StartCpuProfiling(Handle<String> title, bool record_samples) {
7381 reinterpret_cast<i::CpuProfiler*>(this)->StartProfiling( 7440 reinterpret_cast<i::CpuProfiler*>(this)->StartProfiling(
7382 *Utils::OpenHandle(*title), record_samples); 7441 *Utils::OpenHandle(*title), record_samples);
7383 } 7442 }
7384 7443
7385 7444
7386 const CpuProfile* CpuProfiler::StopProfiling(Handle<String> title,
7387 Handle<Value> security_token) {
7388 i::Isolate* isolate = i::Isolate::Current();
7389 IsDeadCheck(isolate, "v8::CpuProfiler::StopProfiling");
7390 i::CpuProfiler* profiler = isolate->cpu_profiler();
7391 ASSERT(profiler != NULL);
7392 return reinterpret_cast<const CpuProfile*>(
7393 profiler->StopProfiling(
7394 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
7395 *Utils::OpenHandle(*title)));
7396 }
7397
7398
7399 const CpuProfile* CpuProfiler::StopCpuProfiling(Handle<String> title, 7445 const CpuProfile* CpuProfiler::StopCpuProfiling(Handle<String> title,
7400 Handle<Value> security_token) { 7446 Handle<Value> security_token) {
7401 return reinterpret_cast<const CpuProfile*>( 7447 return reinterpret_cast<const CpuProfile*>(
7402 reinterpret_cast<i::CpuProfiler*>(this)->StopProfiling( 7448 reinterpret_cast<i::CpuProfiler*>(this)->StopProfiling(
7403 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), 7449 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
7404 *Utils::OpenHandle(*title))); 7450 *Utils::OpenHandle(*title)));
7405 } 7451 }
7406 7452
7407 7453
7408 const CpuProfile* CpuProfiler::StopCpuProfiling(Handle<String> title) { 7454 const CpuProfile* CpuProfiler::StopCpuProfiling(Handle<String> title) {
7409 return reinterpret_cast<const CpuProfile*>( 7455 return reinterpret_cast<const CpuProfile*>(
7410 reinterpret_cast<i::CpuProfiler*>(this)->StopProfiling( 7456 reinterpret_cast<i::CpuProfiler*>(this)->StopProfiling(
7411 NULL, 7457 NULL,
7412 *Utils::OpenHandle(*title))); 7458 *Utils::OpenHandle(*title)));
7413 } 7459 }
7414 7460
7415 7461
7416 void CpuProfiler::DeleteAllProfiles() {
7417 i::Isolate* isolate = i::Isolate::Current();
7418 IsDeadCheck(isolate, "v8::CpuProfiler::DeleteAllProfiles");
7419 i::CpuProfiler* profiler = isolate->cpu_profiler();
7420 ASSERT(profiler != NULL);
7421 profiler->DeleteAllProfiles();
7422 }
7423
7424
7425 void CpuProfiler::DeleteAllCpuProfiles() { 7462 void CpuProfiler::DeleteAllCpuProfiles() {
7426 reinterpret_cast<i::CpuProfiler*>(this)->DeleteAllProfiles(); 7463 reinterpret_cast<i::CpuProfiler*>(this)->DeleteAllProfiles();
7427 } 7464 }
7428 7465
7429 7466
7430 static i::HeapGraphEdge* ToInternal(const HeapGraphEdge* edge) { 7467 static i::HeapGraphEdge* ToInternal(const HeapGraphEdge* edge) {
7431 return const_cast<i::HeapGraphEdge*>( 7468 return const_cast<i::HeapGraphEdge*>(
7432 reinterpret_cast<const i::HeapGraphEdge*>(edge)); 7469 reinterpret_cast<const i::HeapGraphEdge*>(edge));
7433 } 7470 }
7434 7471
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
7548 IsDeadCheck(isolate, "v8::HeapSnapshot::Delete"); 7585 IsDeadCheck(isolate, "v8::HeapSnapshot::Delete");
7549 if (isolate->heap_profiler()->GetSnapshotsCount() > 1) { 7586 if (isolate->heap_profiler()->GetSnapshotsCount() > 1) {
7550 ToInternal(this)->Delete(); 7587 ToInternal(this)->Delete();
7551 } else { 7588 } else {
7552 // If this is the last snapshot, clean up all accessory data as well. 7589 // If this is the last snapshot, clean up all accessory data as well.
7553 isolate->heap_profiler()->DeleteAllSnapshots(); 7590 isolate->heap_profiler()->DeleteAllSnapshots();
7554 } 7591 }
7555 } 7592 }
7556 7593
7557 7594
7558 HeapSnapshot::Type HeapSnapshot::GetType() const {
7559 i::Isolate* isolate = i::Isolate::Current();
7560 IsDeadCheck(isolate, "v8::HeapSnapshot::GetType");
7561 return kFull;
7562 }
7563
7564
7565 unsigned HeapSnapshot::GetUid() const { 7595 unsigned HeapSnapshot::GetUid() const {
7566 i::Isolate* isolate = i::Isolate::Current(); 7596 i::Isolate* isolate = i::Isolate::Current();
7567 IsDeadCheck(isolate, "v8::HeapSnapshot::GetUid"); 7597 IsDeadCheck(isolate, "v8::HeapSnapshot::GetUid");
7568 return ToInternal(this)->uid(); 7598 return ToInternal(this)->uid();
7569 } 7599 }
7570 7600
7571 7601
7572 Handle<String> HeapSnapshot::GetTitle() const { 7602 Handle<String> HeapSnapshot::GetTitle() const {
7573 i::Isolate* isolate = i::Isolate::Current(); 7603 i::Isolate* isolate = i::Isolate::Current();
7574 IsDeadCheck(isolate, "v8::HeapSnapshot::GetTitle"); 7604 IsDeadCheck(isolate, "v8::HeapSnapshot::GetTitle");
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
7625 "v8::HeapSnapshot::Serialize", 7655 "v8::HeapSnapshot::Serialize",
7626 "Unsupported output encoding"); 7656 "Unsupported output encoding");
7627 ApiCheck(stream->GetChunkSize() > 0, 7657 ApiCheck(stream->GetChunkSize() > 0,
7628 "v8::HeapSnapshot::Serialize", 7658 "v8::HeapSnapshot::Serialize",
7629 "Invalid stream chunk size"); 7659 "Invalid stream chunk size");
7630 i::HeapSnapshotJSONSerializer serializer(ToInternal(this)); 7660 i::HeapSnapshotJSONSerializer serializer(ToInternal(this));
7631 serializer.Serialize(stream); 7661 serializer.Serialize(stream);
7632 } 7662 }
7633 7663
7634 7664
7635 int HeapProfiler::GetSnapshotsCount() {
7636 i::Isolate* isolate = i::Isolate::Current();
7637 IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshotsCount");
7638 return isolate->heap_profiler()->GetSnapshotsCount();
7639 }
7640
7641
7642 int HeapProfiler::GetSnapshotCount() { 7665 int HeapProfiler::GetSnapshotCount() {
7643 return reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshotsCount(); 7666 return reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshotsCount();
7644 } 7667 }
7645 7668
7646 7669
7647 const HeapSnapshot* HeapProfiler::GetSnapshot(int index) {
7648 i::Isolate* isolate = i::Isolate::Current();
7649 IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshot");
7650 return reinterpret_cast<const HeapSnapshot*>(
7651 isolate->heap_profiler()->GetSnapshot(index));
7652 }
7653
7654
7655 const HeapSnapshot* HeapProfiler::GetHeapSnapshot(int index) { 7670 const HeapSnapshot* HeapProfiler::GetHeapSnapshot(int index) {
7656 return reinterpret_cast<const HeapSnapshot*>( 7671 return reinterpret_cast<const HeapSnapshot*>(
7657 reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshot(index)); 7672 reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshot(index));
7658 } 7673 }
7659 7674
7660 7675
7661 const HeapSnapshot* HeapProfiler::FindSnapshot(unsigned uid) {
7662 i::Isolate* isolate = i::Isolate::Current();
7663 IsDeadCheck(isolate, "v8::HeapProfiler::FindSnapshot");
7664 return reinterpret_cast<const HeapSnapshot*>(
7665 isolate->heap_profiler()->FindSnapshot(uid));
7666 }
7667
7668
7669 const HeapSnapshot* HeapProfiler::FindHeapSnapshot(unsigned uid) { 7676 const HeapSnapshot* HeapProfiler::FindHeapSnapshot(unsigned uid) {
7670 return reinterpret_cast<const HeapSnapshot*>( 7677 return reinterpret_cast<const HeapSnapshot*>(
7671 reinterpret_cast<i::HeapProfiler*>(this)->FindSnapshot(uid)); 7678 reinterpret_cast<i::HeapProfiler*>(this)->FindSnapshot(uid));
7672 } 7679 }
7673 7680
7674 7681
7675 SnapshotObjectId HeapProfiler::GetSnapshotObjectId(Handle<Value> value) {
7676 i::Isolate* isolate = i::Isolate::Current();
7677 IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshotObjectId");
7678 i::Handle<i::Object> obj = Utils::OpenHandle(*value);
7679 return isolate->heap_profiler()->GetSnapshotObjectId(obj);
7680 }
7681
7682
7683 SnapshotObjectId HeapProfiler::GetObjectId(Handle<Value> value) { 7682 SnapshotObjectId HeapProfiler::GetObjectId(Handle<Value> value) {
7684 i::Handle<i::Object> obj = Utils::OpenHandle(*value); 7683 i::Handle<i::Object> obj = Utils::OpenHandle(*value);
7685 return reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshotObjectId(obj); 7684 return reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshotObjectId(obj);
7686 } 7685 }
7687 7686
7688 7687
7689 const HeapSnapshot* HeapProfiler::TakeSnapshot(Handle<String> title,
7690 HeapSnapshot::Type type,
7691 ActivityControl* control,
7692 ObjectNameResolver* resolver) {
7693 i::Isolate* isolate = i::Isolate::Current();
7694 IsDeadCheck(isolate, "v8::HeapProfiler::TakeSnapshot");
7695 return reinterpret_cast<const HeapSnapshot*>(
7696 isolate->heap_profiler()->TakeSnapshot(
7697 *Utils::OpenHandle(*title), control, resolver));
7698 }
7699
7700
7701 const HeapSnapshot* HeapProfiler::TakeHeapSnapshot( 7688 const HeapSnapshot* HeapProfiler::TakeHeapSnapshot(
7702 Handle<String> title, 7689 Handle<String> title,
7703 ActivityControl* control, 7690 ActivityControl* control,
7704 ObjectNameResolver* resolver) { 7691 ObjectNameResolver* resolver) {
7705 return reinterpret_cast<const HeapSnapshot*>( 7692 return reinterpret_cast<const HeapSnapshot*>(
7706 reinterpret_cast<i::HeapProfiler*>(this)->TakeSnapshot( 7693 reinterpret_cast<i::HeapProfiler*>(this)->TakeSnapshot(
7707 *Utils::OpenHandle(*title), control, resolver)); 7694 *Utils::OpenHandle(*title), control, resolver));
7708 } 7695 }
7709 7696
7710 7697
7711 void HeapProfiler::StartHeapObjectsTracking() {
7712 i::Isolate* isolate = i::Isolate::Current();
7713 IsDeadCheck(isolate, "v8::HeapProfiler::StartHeapObjectsTracking");
7714 isolate->heap_profiler()->StartHeapObjectsTracking();
7715 }
7716
7717
7718 void HeapProfiler::StartTrackingHeapObjects() { 7698 void HeapProfiler::StartTrackingHeapObjects() {
7719 reinterpret_cast<i::HeapProfiler*>(this)->StartHeapObjectsTracking(); 7699 reinterpret_cast<i::HeapProfiler*>(this)->StartHeapObjectsTracking();
7720 } 7700 }
7721 7701
7722 7702
7723 void HeapProfiler::StopHeapObjectsTracking() {
7724 i::Isolate* isolate = i::Isolate::Current();
7725 IsDeadCheck(isolate, "v8::HeapProfiler::StopHeapObjectsTracking");
7726 isolate->heap_profiler()->StopHeapObjectsTracking();
7727 }
7728
7729
7730 void HeapProfiler::StopTrackingHeapObjects() { 7703 void HeapProfiler::StopTrackingHeapObjects() {
7731 reinterpret_cast<i::HeapProfiler*>(this)->StopHeapObjectsTracking(); 7704 reinterpret_cast<i::HeapProfiler*>(this)->StopHeapObjectsTracking();
7732 } 7705 }
7733 7706
7734 7707
7735 SnapshotObjectId HeapProfiler::PushHeapObjectsStats(OutputStream* stream) {
7736 i::Isolate* isolate = i::Isolate::Current();
7737 IsDeadCheck(isolate, "v8::HeapProfiler::PushHeapObjectsStats");
7738 return isolate->heap_profiler()->PushHeapObjectsStats(stream);
7739 }
7740
7741
7742 SnapshotObjectId HeapProfiler::GetHeapStats(OutputStream* stream) { 7708 SnapshotObjectId HeapProfiler::GetHeapStats(OutputStream* stream) {
7743 return reinterpret_cast<i::HeapProfiler*>(this)->PushHeapObjectsStats(stream); 7709 return reinterpret_cast<i::HeapProfiler*>(this)->PushHeapObjectsStats(stream);
7744 } 7710 }
7745 7711
7746 7712
7747 void HeapProfiler::DeleteAllSnapshots() {
7748 i::Isolate* isolate = i::Isolate::Current();
7749 IsDeadCheck(isolate, "v8::HeapProfiler::DeleteAllSnapshots");
7750 isolate->heap_profiler()->DeleteAllSnapshots();
7751 }
7752
7753
7754 void HeapProfiler::DeleteAllHeapSnapshots() { 7713 void HeapProfiler::DeleteAllHeapSnapshots() {
7755 reinterpret_cast<i::HeapProfiler*>(this)->DeleteAllSnapshots(); 7714 reinterpret_cast<i::HeapProfiler*>(this)->DeleteAllSnapshots();
7756 } 7715 }
7757 7716
7758 7717
7759 void HeapProfiler::DefineWrapperClass(uint16_t class_id,
7760 WrapperInfoCallback callback) {
7761 i::Isolate::Current()->heap_profiler()->DefineWrapperClass(class_id,
7762 callback);
7763 }
7764
7765
7766 void HeapProfiler::SetWrapperClassInfoProvider(uint16_t class_id, 7718 void HeapProfiler::SetWrapperClassInfoProvider(uint16_t class_id,
7767 WrapperInfoCallback callback) { 7719 WrapperInfoCallback callback) {
7768 reinterpret_cast<i::HeapProfiler*>(this)->DefineWrapperClass(class_id, 7720 reinterpret_cast<i::HeapProfiler*>(this)->DefineWrapperClass(class_id,
7769 callback); 7721 callback);
7770 } 7722 }
7771 7723
7772 7724
7773 int HeapProfiler::GetPersistentHandleCount() {
7774 i::Isolate* isolate = i::Isolate::Current();
7775 return isolate->global_handles()->NumberOfGlobalHandles();
7776 }
7777
7778
7779 size_t HeapProfiler::GetMemorySizeUsedByProfiler() {
7780 return i::Isolate::Current()->heap_profiler()->GetMemorySizeUsedByProfiler();
7781 }
7782
7783
7784 size_t HeapProfiler::GetProfilerMemorySize() { 7725 size_t HeapProfiler::GetProfilerMemorySize() {
7785 return reinterpret_cast<i::HeapProfiler*>(this)-> 7726 return reinterpret_cast<i::HeapProfiler*>(this)->
7786 GetMemorySizeUsedByProfiler(); 7727 GetMemorySizeUsedByProfiler();
7787 } 7728 }
7788 7729
7789 7730
7790 void HeapProfiler::SetRetainedObjectInfo(UniqueId id, 7731 void HeapProfiler::SetRetainedObjectInfo(UniqueId id,
7791 RetainedObjectInfo* info) { 7732 RetainedObjectInfo* info) {
7792 reinterpret_cast<i::HeapProfiler*>(this)->SetRetainedObjectInfo(id, info); 7733 reinterpret_cast<i::HeapProfiler*>(this)->SetRetainedObjectInfo(id, info);
7793 } 7734 }
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
8050 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7991 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
8051 Address callback_address = 7992 Address callback_address =
8052 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7993 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8053 VMState<EXTERNAL> state(isolate); 7994 VMState<EXTERNAL> state(isolate);
8054 ExternalCallbackScope call_scope(isolate, callback_address); 7995 ExternalCallbackScope call_scope(isolate, callback_address);
8055 return callback(info); 7996 return callback(info);
8056 } 7997 }
8057 7998
8058 7999
8059 } } // namespace v8::internal 8000 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/api.h ('k') | src/arguments.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698