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

Side by Side Diff: src/api.cc

Issue 7535004: Merge bleeding edge up to 8774 into the GC branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 years, 4 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/SConscript ('k') | src/apinatives.js » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "snapshot.h" 47 #include "snapshot.h"
48 #include "v8threads.h" 48 #include "v8threads.h"
49 #include "version.h" 49 #include "version.h"
50 #include "vm-state-inl.h" 50 #include "vm-state-inl.h"
51 51
52 #include "../include/v8-profiler.h" 52 #include "../include/v8-profiler.h"
53 #include "../include/v8-testing.h" 53 #include "../include/v8-testing.h"
54 54
55 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr)) 55 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr))
56 56
57 #ifdef ENABLE_VMSTATE_TRACKING
58 #define ENTER_V8(isolate) \ 57 #define ENTER_V8(isolate) \
59 ASSERT((isolate)->IsInitialized()); \ 58 ASSERT((isolate)->IsInitialized()); \
60 i::VMState __state__((isolate), i::OTHER) 59 i::VMState __state__((isolate), i::OTHER)
61 #define LEAVE_V8(isolate) \ 60 #define LEAVE_V8(isolate) \
62 i::VMState __state__((isolate), i::EXTERNAL) 61 i::VMState __state__((isolate), i::EXTERNAL)
63 #else
64 #define ENTER_V8(isolate) ((void) 0)
65 #define LEAVE_V8(isolate) ((void) 0)
66 #endif
67 62
68 namespace v8 { 63 namespace v8 {
69 64
70 #define ON_BAILOUT(isolate, location, code) \ 65 #define ON_BAILOUT(isolate, location, code) \
71 if (IsDeadCheck(isolate, location) || \ 66 if (IsDeadCheck(isolate, location) || \
72 IsExecutionTerminatingCheck(isolate)) { \ 67 IsExecutionTerminatingCheck(isolate)) { \
73 code; \ 68 code; \
74 UNREACHABLE(); \ 69 UNREACHABLE(); \
75 } 70 }
76 71
(...skipping 30 matching lines...) Expand all
107 "Entering the V8 API without proper locking in place"); \ 102 "Entering the V8 API without proper locking in place"); \
108 } \ 103 } \
109 } while (false) 104 } while (false)
110 105
111 106
112 // --- E x c e p t i o n B e h a v i o r --- 107 // --- E x c e p t i o n B e h a v i o r ---
113 108
114 109
115 static void DefaultFatalErrorHandler(const char* location, 110 static void DefaultFatalErrorHandler(const char* location,
116 const char* message) { 111 const char* message) {
117 #ifdef ENABLE_VMSTATE_TRACKING
118 i::VMState __state__(i::Isolate::Current(), i::OTHER); 112 i::VMState __state__(i::Isolate::Current(), i::OTHER);
119 #endif
120 API_Fatal(location, message); 113 API_Fatal(location, message);
121 } 114 }
122 115
123 116
124 static FatalErrorCallback GetFatalErrorHandler() { 117 static FatalErrorCallback GetFatalErrorHandler() {
125 i::Isolate* isolate = i::Isolate::Current(); 118 i::Isolate* isolate = i::Isolate::Current();
126 if (isolate->exception_behavior() == NULL) { 119 if (isolate->exception_behavior() == NULL) {
127 isolate->set_exception_behavior(DefaultFatalErrorHandler); 120 isolate->set_exception_behavior(DefaultFatalErrorHandler);
128 } 121 }
129 return isolate->exception_behavior(); 122 return isolate->exception_behavior();
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 array.add(Utils::OpenHandle(*value)); 870 array.add(Utils::OpenHandle(*value));
878 array.add(Utils::OpenHandle(*v8::Integer::New(attribute))); 871 array.add(Utils::OpenHandle(*v8::Integer::New(attribute)));
879 } 872 }
880 873
881 874
882 // --- F u n c t i o n T e m p l a t e --- 875 // --- F u n c t i o n T e m p l a t e ---
883 static void InitializeFunctionTemplate( 876 static void InitializeFunctionTemplate(
884 i::Handle<i::FunctionTemplateInfo> info) { 877 i::Handle<i::FunctionTemplateInfo> info) {
885 info->set_tag(i::Smi::FromInt(Consts::FUNCTION_TEMPLATE)); 878 info->set_tag(i::Smi::FromInt(Consts::FUNCTION_TEMPLATE));
886 info->set_flag(0); 879 info->set_flag(0);
887 info->set_prototype_attributes(i::Smi::FromInt(v8::None));
888 } 880 }
889 881
890 882
891 Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() { 883 Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() {
892 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 884 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
893 if (IsDeadCheck(isolate, "v8::FunctionTemplate::PrototypeTemplate()")) { 885 if (IsDeadCheck(isolate, "v8::FunctionTemplate::PrototypeTemplate()")) {
894 return Local<ObjectTemplate>(); 886 return Local<ObjectTemplate>();
895 } 887 }
896 ENTER_V8(isolate); 888 ENTER_V8(isolate);
897 i::Handle<i::Object> result(Utils::OpenHandle(this)->prototype_template()); 889 i::Handle<i::Object> result(Utils::OpenHandle(this)->prototype_template());
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 void FunctionTemplate::SetHiddenPrototype(bool value) { 1092 void FunctionTemplate::SetHiddenPrototype(bool value) {
1101 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1093 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1102 if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetHiddenPrototype()")) { 1094 if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetHiddenPrototype()")) {
1103 return; 1095 return;
1104 } 1096 }
1105 ENTER_V8(isolate); 1097 ENTER_V8(isolate);
1106 Utils::OpenHandle(this)->set_hidden_prototype(value); 1098 Utils::OpenHandle(this)->set_hidden_prototype(value);
1107 } 1099 }
1108 1100
1109 1101
1110 void FunctionTemplate::SetPrototypeAttributes(int attributes) { 1102 void FunctionTemplate::ReadOnlyPrototype() {
1111 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1103 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1112 if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetPrototypeAttributes()")) { 1104 if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetPrototypeAttributes()")) {
1113 return; 1105 return;
1114 } 1106 }
1115 ENTER_V8(isolate); 1107 ENTER_V8(isolate);
1116 Utils::OpenHandle(this)->set_prototype_attributes( 1108 Utils::OpenHandle(this)->set_read_only_prototype(true);
1117 i::Smi::FromInt(attributes));
1118 } 1109 }
1119 1110
1120 1111
1121 void FunctionTemplate::SetNamedInstancePropertyHandler( 1112 void FunctionTemplate::SetNamedInstancePropertyHandler(
1122 NamedPropertyGetter getter, 1113 NamedPropertyGetter getter,
1123 NamedPropertySetter setter, 1114 NamedPropertySetter setter,
1124 NamedPropertyQuery query, 1115 NamedPropertyQuery query,
1125 NamedPropertyDeleter remover, 1116 NamedPropertyDeleter remover,
1126 NamedPropertyEnumerator enumerator, 1117 NamedPropertyEnumerator enumerator,
1127 Handle<Value> data) { 1118 Handle<Value> data) {
(...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after
2167 2158
2168 2159
2169 bool Value::IsDate() const { 2160 bool Value::IsDate() const {
2170 i::Isolate* isolate = i::Isolate::Current(); 2161 i::Isolate* isolate = i::Isolate::Current();
2171 if (IsDeadCheck(isolate, "v8::Value::IsDate()")) return false; 2162 if (IsDeadCheck(isolate, "v8::Value::IsDate()")) return false;
2172 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2163 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2173 return obj->HasSpecificClassOf(isolate->heap()->Date_symbol()); 2164 return obj->HasSpecificClassOf(isolate->heap()->Date_symbol());
2174 } 2165 }
2175 2166
2176 2167
2168 bool Value::IsStringObject() const {
2169 i::Isolate* isolate = i::Isolate::Current();
2170 if (IsDeadCheck(isolate, "v8::Value::IsStringObject()")) return false;
2171 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2172 return obj->HasSpecificClassOf(isolate->heap()->String_symbol());
2173 }
2174
2175
2176 bool Value::IsNumberObject() const {
2177 i::Isolate* isolate = i::Isolate::Current();
2178 if (IsDeadCheck(isolate, "v8::Value::IsNumberObject()")) return false;
2179 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2180 return obj->HasSpecificClassOf(isolate->heap()->Number_symbol());
2181 }
2182
2183
2184 static i::Object* LookupBuiltin(i::Isolate* isolate,
2185 const char* builtin_name) {
2186 i::Handle<i::String> symbol =
2187 isolate->factory()->LookupAsciiSymbol(builtin_name);
2188 i::Handle<i::JSBuiltinsObject> builtins = isolate->js_builtins_object();
2189 return builtins->GetPropertyNoExceptionThrown(*symbol);
2190 }
2191
2192
2193 static bool CheckConstructor(i::Isolate* isolate,
2194 i::Handle<i::JSObject> obj,
2195 const char* class_name) {
2196 return obj->map()->constructor() == LookupBuiltin(isolate, class_name);
2197 }
2198
2199
2200 bool Value::IsNativeError() const {
2201 i::Isolate* isolate = i::Isolate::Current();
2202 if (IsDeadCheck(isolate, "v8::Value::IsNativeError()")) return false;
2203 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2204 if (obj->IsJSObject()) {
2205 i::Handle<i::JSObject> js_obj(i::JSObject::cast(*obj));
2206 return CheckConstructor(isolate, js_obj, "$Error") ||
2207 CheckConstructor(isolate, js_obj, "$EvalError") ||
2208 CheckConstructor(isolate, js_obj, "$RangeError") ||
2209 CheckConstructor(isolate, js_obj, "$ReferenceError") ||
2210 CheckConstructor(isolate, js_obj, "$SyntaxError") ||
2211 CheckConstructor(isolate, js_obj, "$TypeError") ||
2212 CheckConstructor(isolate, js_obj, "$URIError");
2213 } else {
2214 return false;
2215 }
2216 }
2217
2218
2219 bool Value::IsBooleanObject() const {
2220 i::Isolate* isolate = i::Isolate::Current();
2221 if (IsDeadCheck(isolate, "v8::Value::IsBooleanObject()")) return false;
2222 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2223 return obj->HasSpecificClassOf(isolate->heap()->Boolean_symbol());
2224 }
2225
2226
2177 bool Value::IsRegExp() const { 2227 bool Value::IsRegExp() const {
2178 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsRegExp()")) return false; 2228 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsRegExp()")) return false;
2179 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2229 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2180 return obj->IsJSRegExp(); 2230 return obj->IsJSRegExp();
2181 } 2231 }
2182 2232
2183 2233
2184 Local<String> Value::ToString() const { 2234 Local<String> Value::ToString() const {
2185 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2235 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2186 i::Handle<i::Object> str; 2236 i::Handle<i::Object> str;
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
2362 void v8::Date::CheckCast(v8::Value* that) { 2412 void v8::Date::CheckCast(v8::Value* that) {
2363 i::Isolate* isolate = i::Isolate::Current(); 2413 i::Isolate* isolate = i::Isolate::Current();
2364 if (IsDeadCheck(isolate, "v8::Date::Cast()")) return; 2414 if (IsDeadCheck(isolate, "v8::Date::Cast()")) return;
2365 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2415 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2366 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Date_symbol()), 2416 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Date_symbol()),
2367 "v8::Date::Cast()", 2417 "v8::Date::Cast()",
2368 "Could not convert to date"); 2418 "Could not convert to date");
2369 } 2419 }
2370 2420
2371 2421
2422 void v8::StringObject::CheckCast(v8::Value* that) {
2423 i::Isolate* isolate = i::Isolate::Current();
2424 if (IsDeadCheck(isolate, "v8::StringObject::Cast()")) return;
2425 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2426 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->String_symbol()),
2427 "v8::StringObject::Cast()",
2428 "Could not convert to StringObject");
2429 }
2430
2431
2432 void v8::NumberObject::CheckCast(v8::Value* that) {
2433 i::Isolate* isolate = i::Isolate::Current();
2434 if (IsDeadCheck(isolate, "v8::NumberObject::Cast()")) return;
2435 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2436 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Number_symbol()),
2437 "v8::NumberObject::Cast()",
2438 "Could not convert to NumberObject");
2439 }
2440
2441
2442 void v8::BooleanObject::CheckCast(v8::Value* that) {
2443 i::Isolate* isolate = i::Isolate::Current();
2444 if (IsDeadCheck(isolate, "v8::BooleanObject::Cast()")) return;
2445 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2446 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Boolean_symbol()),
2447 "v8::BooleanObject::Cast()",
2448 "Could not convert to BooleanObject");
2449 }
2450
2451
2372 void v8::RegExp::CheckCast(v8::Value* that) { 2452 void v8::RegExp::CheckCast(v8::Value* that) {
2373 if (IsDeadCheck(i::Isolate::Current(), "v8::RegExp::Cast()")) return; 2453 if (IsDeadCheck(i::Isolate::Current(), "v8::RegExp::Cast()")) return;
2374 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2454 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2375 ApiCheck(obj->IsJSRegExp(), 2455 ApiCheck(obj->IsJSRegExp(),
2376 "v8::RegExp::Cast()", 2456 "v8::RegExp::Cast()",
2377 "Could not convert to regular expression"); 2457 "Could not convert to regular expression");
2378 } 2458 }
2379 2459
2380 2460
2381 bool Value::BooleanValue() const { 2461 bool Value::BooleanValue() const {
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
2705 ENTER_V8(isolate); 2785 ENTER_V8(isolate);
2706 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2786 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2707 EXCEPTION_PREAMBLE(isolate); 2787 EXCEPTION_PREAMBLE(isolate);
2708 i::Handle<i::Object> result = i::GetElement(self, index); 2788 i::Handle<i::Object> result = i::GetElement(self, index);
2709 has_pending_exception = result.is_null(); 2789 has_pending_exception = result.is_null();
2710 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); 2790 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
2711 return Utils::ToLocal(result); 2791 return Utils::ToLocal(result);
2712 } 2792 }
2713 2793
2714 2794
2795 PropertyAttribute v8::Object::GetPropertyAttributes(v8::Handle<Value> key) {
2796 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2797 ON_BAILOUT(isolate, "v8::Object::GetPropertyAttribute()",
2798 return static_cast<PropertyAttribute>(NONE));
2799 ENTER_V8(isolate);
2800 i::HandleScope scope(isolate);
2801 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2802 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
2803 if (!key_obj->IsString()) {
2804 EXCEPTION_PREAMBLE(isolate);
2805 key_obj = i::Execution::ToString(key_obj, &has_pending_exception);
2806 EXCEPTION_BAILOUT_CHECK(isolate, static_cast<PropertyAttribute>(NONE));
2807 }
2808 i::Handle<i::String> key_string = i::Handle<i::String>::cast(key_obj);
2809 PropertyAttributes result = self->GetPropertyAttribute(*key_string);
2810 if (result == ABSENT) return static_cast<PropertyAttribute>(NONE);
2811 return static_cast<PropertyAttribute>(result);
2812 }
2813
2814
2715 Local<Value> v8::Object::GetPrototype() { 2815 Local<Value> v8::Object::GetPrototype() {
2716 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2816 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2717 ON_BAILOUT(isolate, "v8::Object::GetPrototype()", 2817 ON_BAILOUT(isolate, "v8::Object::GetPrototype()",
2718 return Local<v8::Value>()); 2818 return Local<v8::Value>());
2719 ENTER_V8(isolate); 2819 ENTER_V8(isolate);
2720 i::Handle<i::Object> self = Utils::OpenHandle(this); 2820 i::Handle<i::Object> self = Utils::OpenHandle(this);
2721 i::Handle<i::Object> result = i::GetPrototype(self); 2821 i::Handle<i::Object> result = i::GetPrototype(self);
2722 return Utils::ToLocal(result); 2822 return Utils::ToLocal(result);
2723 } 2823 }
2724 2824
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
3085 return Utils::ToLocal(i::Handle<i::Context>(context)); 3185 return Utils::ToLocal(i::Handle<i::Context>(context));
3086 } 3186 }
3087 3187
3088 3188
3089 int v8::Object::GetIdentityHash() { 3189 int v8::Object::GetIdentityHash() {
3090 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3190 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3091 ON_BAILOUT(isolate, "v8::Object::GetIdentityHash()", return 0); 3191 ON_BAILOUT(isolate, "v8::Object::GetIdentityHash()", return 0);
3092 ENTER_V8(isolate); 3192 ENTER_V8(isolate);
3093 i::HandleScope scope(isolate); 3193 i::HandleScope scope(isolate);
3094 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3194 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3095 i::Handle<i::Object> hidden_props_obj(i::GetHiddenProperties(self, true)); 3195 return i::GetIdentityHash(self);
3096 if (!hidden_props_obj->IsJSObject()) {
3097 // We failed to create hidden properties. That's a detached
3098 // global proxy.
3099 ASSERT(hidden_props_obj->IsUndefined());
3100 return 0;
3101 }
3102 i::Handle<i::JSObject> hidden_props =
3103 i::Handle<i::JSObject>::cast(hidden_props_obj);
3104 i::Handle<i::String> hash_symbol = isolate->factory()->identity_hash_symbol();
3105 if (hidden_props->HasLocalProperty(*hash_symbol)) {
3106 i::Handle<i::Object> hash = i::GetProperty(hidden_props, hash_symbol);
3107 CHECK(!hash.is_null());
3108 CHECK(hash->IsSmi());
3109 return i::Smi::cast(*hash)->value();
3110 }
3111
3112 int hash_value;
3113 int attempts = 0;
3114 do {
3115 // Generate a random 32-bit hash value but limit range to fit
3116 // within a smi.
3117 hash_value = i::V8::Random(self->GetIsolate()) & i::Smi::kMaxValue;
3118 attempts++;
3119 } while (hash_value == 0 && attempts < 30);
3120 hash_value = hash_value != 0 ? hash_value : 1; // never return 0
3121 CHECK(!i::SetLocalPropertyIgnoreAttributes(
3122 hidden_props,
3123 hash_symbol,
3124 i::Handle<i::Object>(i::Smi::FromInt(hash_value)),
3125 static_cast<PropertyAttributes>(None)).is_null());
3126
3127 return hash_value;
3128 } 3196 }
3129 3197
3130 3198
3131 bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key, 3199 bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key,
3132 v8::Handle<v8::Value> value) { 3200 v8::Handle<v8::Value> value) {
3133 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3201 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3134 ON_BAILOUT(isolate, "v8::Object::SetHiddenValue()", return false); 3202 ON_BAILOUT(isolate, "v8::Object::SetHiddenValue()", return false);
3135 ENTER_V8(isolate); 3203 ENTER_V8(isolate);
3136 i::HandleScope scope(isolate); 3204 i::HandleScope scope(isolate);
3137 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3205 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3138 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, true)); 3206 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(
3207 self,
3208 i::JSObject::ALLOW_CREATION));
3139 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 3209 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3140 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); 3210 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
3141 EXCEPTION_PREAMBLE(isolate); 3211 EXCEPTION_PREAMBLE(isolate);
3142 i::Handle<i::Object> obj = i::SetProperty( 3212 i::Handle<i::Object> obj = i::SetProperty(
3143 hidden_props, 3213 hidden_props,
3144 key_obj, 3214 key_obj,
3145 value_obj, 3215 value_obj,
3146 static_cast<PropertyAttributes>(None), 3216 static_cast<PropertyAttributes>(None),
3147 i::kNonStrictMode); 3217 i::kNonStrictMode);
3148 has_pending_exception = obj.is_null(); 3218 has_pending_exception = obj.is_null();
3149 EXCEPTION_BAILOUT_CHECK(isolate, false); 3219 EXCEPTION_BAILOUT_CHECK(isolate, false);
3150 return true; 3220 return true;
3151 } 3221 }
3152 3222
3153 3223
3154 v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Handle<v8::String> key) { 3224 v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Handle<v8::String> key) {
3155 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3225 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3156 ON_BAILOUT(isolate, "v8::Object::GetHiddenValue()", 3226 ON_BAILOUT(isolate, "v8::Object::GetHiddenValue()",
3157 return Local<v8::Value>()); 3227 return Local<v8::Value>());
3158 ENTER_V8(isolate); 3228 ENTER_V8(isolate);
3159 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3229 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3160 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, false)); 3230 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(
3231 self,
3232 i::JSObject::OMIT_CREATION));
3161 if (hidden_props->IsUndefined()) { 3233 if (hidden_props->IsUndefined()) {
3162 return v8::Local<v8::Value>(); 3234 return v8::Local<v8::Value>();
3163 } 3235 }
3164 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 3236 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
3165 EXCEPTION_PREAMBLE(isolate); 3237 EXCEPTION_PREAMBLE(isolate);
3166 i::Handle<i::Object> result = i::GetProperty(hidden_props, key_obj); 3238 i::Handle<i::Object> result = i::GetProperty(hidden_props, key_obj);
3167 has_pending_exception = result.is_null(); 3239 has_pending_exception = result.is_null();
3168 EXCEPTION_BAILOUT_CHECK(isolate, v8::Local<v8::Value>()); 3240 EXCEPTION_BAILOUT_CHECK(isolate, v8::Local<v8::Value>());
3169 if (result->IsUndefined()) { 3241 if (result->IsUndefined()) {
3170 return v8::Local<v8::Value>(); 3242 return v8::Local<v8::Value>();
3171 } 3243 }
3172 return Utils::ToLocal(result); 3244 return Utils::ToLocal(result);
3173 } 3245 }
3174 3246
3175 3247
3176 bool v8::Object::DeleteHiddenValue(v8::Handle<v8::String> key) { 3248 bool v8::Object::DeleteHiddenValue(v8::Handle<v8::String> key) {
3177 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3249 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3178 ON_BAILOUT(isolate, "v8::DeleteHiddenValue()", return false); 3250 ON_BAILOUT(isolate, "v8::DeleteHiddenValue()", return false);
3179 ENTER_V8(isolate); 3251 ENTER_V8(isolate);
3180 i::HandleScope scope(isolate); 3252 i::HandleScope scope(isolate);
3181 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3253 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3182 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, false)); 3254 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(
3255 self,
3256 i::JSObject::OMIT_CREATION));
3183 if (hidden_props->IsUndefined()) { 3257 if (hidden_props->IsUndefined()) {
3184 return true; 3258 return true;
3185 } 3259 }
3186 i::Handle<i::JSObject> js_obj(i::JSObject::cast(*hidden_props)); 3260 i::Handle<i::JSObject> js_obj(i::JSObject::cast(*hidden_props));
3187 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 3261 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
3188 return i::DeleteProperty(js_obj, key_obj)->IsTrue(); 3262 return i::DeleteProperty(js_obj, key_obj)->IsTrue();
3189 } 3263 }
3190 3264
3191 3265
3192 namespace { 3266 namespace {
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
3844 3918
3845 bool v8::V8::Initialize() { 3919 bool v8::V8::Initialize() {
3846 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); 3920 i::Isolate* isolate = i::Isolate::UncheckedCurrent();
3847 if (isolate != NULL && isolate->IsInitialized()) { 3921 if (isolate != NULL && isolate->IsInitialized()) {
3848 return true; 3922 return true;
3849 } 3923 }
3850 return InitializeHelper(); 3924 return InitializeHelper();
3851 } 3925 }
3852 3926
3853 3927
3928 void v8::V8::SetEntropySource(EntropySource source) {
3929 i::V8::SetEntropySource(source);
3930 }
3931
3932
3854 bool v8::V8::Dispose() { 3933 bool v8::V8::Dispose() {
3855 i::Isolate* isolate = i::Isolate::Current(); 3934 i::Isolate* isolate = i::Isolate::Current();
3856 if (!ApiCheck(isolate != NULL && isolate->IsDefaultIsolate(), 3935 if (!ApiCheck(isolate != NULL && isolate->IsDefaultIsolate(),
3857 "v8::V8::Dispose()", 3936 "v8::V8::Dispose()",
3858 "Use v8::Isolate::Dispose() for a non-default isolate.")) { 3937 "Use v8::Isolate::Dispose() for a non-default isolate.")) {
3859 return false; 3938 return false;
3860 } 3939 }
3861 i::V8::TearDown(); 3940 i::V8::TearDown();
3862 return true; 3941 return true;
3863 } 3942 }
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
4427 i::Isolate* isolate = i::Isolate::Current(); 4506 i::Isolate* isolate = i::Isolate::Current();
4428 EnsureInitializedForIsolate(isolate, "v8::Object::New()"); 4507 EnsureInitializedForIsolate(isolate, "v8::Object::New()");
4429 LOG_API(isolate, "Object::New"); 4508 LOG_API(isolate, "Object::New");
4430 ENTER_V8(isolate); 4509 ENTER_V8(isolate);
4431 i::Handle<i::JSObject> obj = 4510 i::Handle<i::JSObject> obj =
4432 isolate->factory()->NewJSObject(isolate->object_function()); 4511 isolate->factory()->NewJSObject(isolate->object_function());
4433 return Utils::ToLocal(obj); 4512 return Utils::ToLocal(obj);
4434 } 4513 }
4435 4514
4436 4515
4516 Local<v8::Value> v8::NumberObject::New(double value) {
4517 i::Isolate* isolate = i::Isolate::Current();
4518 EnsureInitializedForIsolate(isolate, "v8::NumberObject::New()");
4519 LOG_API(isolate, "NumberObject::New");
4520 ENTER_V8(isolate);
4521 i::Handle<i::Object> number = isolate->factory()->NewNumber(value);
4522 i::Handle<i::Object> obj = isolate->factory()->ToObject(number);
4523 return Utils::ToLocal(obj);
4524 }
4525
4526
4527 double v8::NumberObject::NumberValue() const {
4528 i::Isolate* isolate = i::Isolate::Current();
4529 if (IsDeadCheck(isolate, "v8::NumberObject::NumberValue()")) return 0;
4530 LOG_API(isolate, "NumberObject::NumberValue");
4531 i::Handle<i::Object> obj = Utils::OpenHandle(this);
4532 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj);
4533 return jsvalue->value()->Number();
4534 }
4535
4536
4537 Local<v8::Value> v8::BooleanObject::New(bool value) {
4538 i::Isolate* isolate = i::Isolate::Current();
4539 EnsureInitializedForIsolate(isolate, "v8::BooleanObject::New()");
4540 LOG_API(isolate, "BooleanObject::New");
4541 ENTER_V8(isolate);
4542 i::Handle<i::Object> boolean(value ? isolate->heap()->true_value()
4543 : isolate->heap()->false_value());
4544 i::Handle<i::Object> obj = isolate->factory()->ToObject(boolean);
4545 return Utils::ToLocal(obj);
4546 }
4547
4548
4549 bool v8::BooleanObject::BooleanValue() const {
4550 i::Isolate* isolate = i::Isolate::Current();
4551 if (IsDeadCheck(isolate, "v8::BooleanObject::BooleanValue()")) return 0;
4552 LOG_API(isolate, "BooleanObject::BooleanValue");
4553 i::Handle<i::Object> obj = Utils::OpenHandle(this);
4554 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj);
4555 return jsvalue->value()->IsTrue();
4556 }
4557
4558
4559 Local<v8::Value> v8::StringObject::New(Handle<String> value) {
4560 i::Isolate* isolate = i::Isolate::Current();
4561 EnsureInitializedForIsolate(isolate, "v8::StringObject::New()");
4562 LOG_API(isolate, "StringObject::New");
4563 ENTER_V8(isolate);
4564 i::Handle<i::Object> obj =
4565 isolate->factory()->ToObject(Utils::OpenHandle(*value));
4566 return Utils::ToLocal(obj);
4567 }
4568
4569
4570 Local<v8::String> v8::StringObject::StringValue() const {
4571 i::Isolate* isolate = i::Isolate::Current();
4572 if (IsDeadCheck(isolate, "v8::StringObject::StringValue()")) {
4573 return Local<v8::String>();
4574 }
4575 LOG_API(isolate, "StringObject::StringValue");
4576 i::Handle<i::Object> obj = Utils::OpenHandle(this);
4577 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj);
4578 return Utils::ToLocal(
4579 i::Handle<i::String>(i::String::cast(jsvalue->value())));
4580 }
4581
4582
4437 Local<v8::Value> v8::Date::New(double time) { 4583 Local<v8::Value> v8::Date::New(double time) {
4438 i::Isolate* isolate = i::Isolate::Current(); 4584 i::Isolate* isolate = i::Isolate::Current();
4439 EnsureInitializedForIsolate(isolate, "v8::Date::New()"); 4585 EnsureInitializedForIsolate(isolate, "v8::Date::New()");
4440 LOG_API(isolate, "Date::New"); 4586 LOG_API(isolate, "Date::New");
4441 if (isnan(time)) { 4587 if (isnan(time)) {
4442 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. 4588 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs.
4443 time = i::OS::nan_value(); 4589 time = i::OS::nan_value();
4444 } 4590 }
4445 ENTER_V8(isolate); 4591 ENTER_V8(isolate);
4446 EXCEPTION_PREAMBLE(isolate); 4592 EXCEPTION_PREAMBLE(isolate);
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
4825 4971
4826 void V8::RemoveMemoryAllocationCallback(MemoryAllocationCallback callback) { 4972 void V8::RemoveMemoryAllocationCallback(MemoryAllocationCallback callback) {
4827 i::Isolate* isolate = i::Isolate::Current(); 4973 i::Isolate* isolate = i::Isolate::Current();
4828 if (IsDeadCheck(isolate, "v8::V8::RemoveMemoryAllocationCallback()")) return; 4974 if (IsDeadCheck(isolate, "v8::V8::RemoveMemoryAllocationCallback()")) return;
4829 isolate->memory_allocator()->RemoveMemoryAllocationCallback( 4975 isolate->memory_allocator()->RemoveMemoryAllocationCallback(
4830 callback); 4976 callback);
4831 } 4977 }
4832 4978
4833 4979
4834 void V8::PauseProfiler() { 4980 void V8::PauseProfiler() {
4835 #ifdef ENABLE_LOGGING_AND_PROFILING
4836 i::Isolate* isolate = i::Isolate::Current(); 4981 i::Isolate* isolate = i::Isolate::Current();
4837 isolate->logger()->PauseProfiler(); 4982 isolate->logger()->PauseProfiler();
4838 #endif
4839 } 4983 }
4840 4984
4841 4985
4842 void V8::ResumeProfiler() { 4986 void V8::ResumeProfiler() {
4843 #ifdef ENABLE_LOGGING_AND_PROFILING
4844 i::Isolate* isolate = i::Isolate::Current(); 4987 i::Isolate* isolate = i::Isolate::Current();
4845 isolate->logger()->ResumeProfiler(); 4988 isolate->logger()->ResumeProfiler();
4846 #endif
4847 } 4989 }
4848 4990
4849 4991
4850 bool V8::IsProfilerPaused() { 4992 bool V8::IsProfilerPaused() {
4851 #ifdef ENABLE_LOGGING_AND_PROFILING
4852 i::Isolate* isolate = i::Isolate::Current(); 4993 i::Isolate* isolate = i::Isolate::Current();
4853 return isolate->logger()->IsProfilerPaused(); 4994 return isolate->logger()->IsProfilerPaused();
4854 #else
4855 return true;
4856 #endif
4857 }
4858
4859
4860 int V8::GetLogLines(int from_pos, char* dest_buf, int max_size) {
4861 #ifdef ENABLE_LOGGING_AND_PROFILING
4862 ASSERT(max_size >= kMinimumSizeForLogLinesBuffer);
4863 return LOGGER->GetLogLines(from_pos, dest_buf, max_size);
4864 #endif
4865 return 0;
4866 } 4995 }
4867 4996
4868 4997
4869 int V8::GetCurrentThreadId() { 4998 int V8::GetCurrentThreadId() {
4870 i::Isolate* isolate = i::Isolate::Current(); 4999 i::Isolate* isolate = i::Isolate::Current();
4871 EnsureInitializedForIsolate(isolate, "V8::GetCurrentThreadId()"); 5000 EnsureInitializedForIsolate(isolate, "V8::GetCurrentThreadId()");
4872 return isolate->thread_id().ToInteger(); 5001 return isolate->thread_id().ToInteger();
4873 } 5002 }
4874 5003
4875 5004
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
5320 i::Isolate* isolate = i::Isolate::Current(); 5449 i::Isolate* isolate = i::Isolate::Current();
5321 EnsureInitializedForIsolate(isolate, "v8::Debug::GetDebugContext()"); 5450 EnsureInitializedForIsolate(isolate, "v8::Debug::GetDebugContext()");
5322 ENTER_V8(isolate); 5451 ENTER_V8(isolate);
5323 return Utils::ToLocal(i::Isolate::Current()->debugger()->GetDebugContext()); 5452 return Utils::ToLocal(i::Isolate::Current()->debugger()->GetDebugContext());
5324 } 5453 }
5325 5454
5326 #endif // ENABLE_DEBUGGER_SUPPORT 5455 #endif // ENABLE_DEBUGGER_SUPPORT
5327 5456
5328 5457
5329 Handle<String> CpuProfileNode::GetFunctionName() const { 5458 Handle<String> CpuProfileNode::GetFunctionName() const {
5330 #ifdef ENABLE_LOGGING_AND_PROFILING
5331 i::Isolate* isolate = i::Isolate::Current(); 5459 i::Isolate* isolate = i::Isolate::Current();
5332 IsDeadCheck(isolate, "v8::CpuProfileNode::GetFunctionName"); 5460 IsDeadCheck(isolate, "v8::CpuProfileNode::GetFunctionName");
5333 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); 5461 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
5334 const i::CodeEntry* entry = node->entry(); 5462 const i::CodeEntry* entry = node->entry();
5335 if (!entry->has_name_prefix()) { 5463 if (!entry->has_name_prefix()) {
5336 return Handle<String>(ToApi<String>( 5464 return Handle<String>(ToApi<String>(
5337 isolate->factory()->LookupAsciiSymbol(entry->name()))); 5465 isolate->factory()->LookupAsciiSymbol(entry->name())));
5338 } else { 5466 } else {
5339 return Handle<String>(ToApi<String>(isolate->factory()->NewConsString( 5467 return Handle<String>(ToApi<String>(isolate->factory()->NewConsString(
5340 isolate->factory()->LookupAsciiSymbol(entry->name_prefix()), 5468 isolate->factory()->LookupAsciiSymbol(entry->name_prefix()),
5341 isolate->factory()->LookupAsciiSymbol(entry->name())))); 5469 isolate->factory()->LookupAsciiSymbol(entry->name()))));
5342 } 5470 }
5343 #else
5344 return v8::String::Empty();
5345 #endif
5346 } 5471 }
5347 5472
5348 5473
5349 Handle<String> CpuProfileNode::GetScriptResourceName() const { 5474 Handle<String> CpuProfileNode::GetScriptResourceName() const {
5350 #ifdef ENABLE_LOGGING_AND_PROFILING
5351 i::Isolate* isolate = i::Isolate::Current(); 5475 i::Isolate* isolate = i::Isolate::Current();
5352 IsDeadCheck(isolate, "v8::CpuProfileNode::GetScriptResourceName"); 5476 IsDeadCheck(isolate, "v8::CpuProfileNode::GetScriptResourceName");
5353 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); 5477 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
5354 return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol( 5478 return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol(
5355 node->entry()->resource_name()))); 5479 node->entry()->resource_name())));
5356 #else
5357 return v8::String::Empty();
5358 #endif
5359 } 5480 }
5360 5481
5361 5482
5362 int CpuProfileNode::GetLineNumber() const { 5483 int CpuProfileNode::GetLineNumber() const {
5363 #ifdef ENABLE_LOGGING_AND_PROFILING
5364 i::Isolate* isolate = i::Isolate::Current(); 5484 i::Isolate* isolate = i::Isolate::Current();
5365 IsDeadCheck(isolate, "v8::CpuProfileNode::GetLineNumber"); 5485 IsDeadCheck(isolate, "v8::CpuProfileNode::GetLineNumber");
5366 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->line_number(); 5486 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->line_number();
5367 #else
5368 return 0;
5369 #endif
5370 } 5487 }
5371 5488
5372 5489
5373 double CpuProfileNode::GetTotalTime() const { 5490 double CpuProfileNode::GetTotalTime() const {
5374 #ifdef ENABLE_LOGGING_AND_PROFILING
5375 i::Isolate* isolate = i::Isolate::Current(); 5491 i::Isolate* isolate = i::Isolate::Current();
5376 IsDeadCheck(isolate, "v8::CpuProfileNode::GetTotalTime"); 5492 IsDeadCheck(isolate, "v8::CpuProfileNode::GetTotalTime");
5377 return reinterpret_cast<const i::ProfileNode*>(this)->GetTotalMillis(); 5493 return reinterpret_cast<const i::ProfileNode*>(this)->GetTotalMillis();
5378 #else
5379 return 0.0;
5380 #endif
5381 } 5494 }
5382 5495
5383 5496
5384 double CpuProfileNode::GetSelfTime() const { 5497 double CpuProfileNode::GetSelfTime() const {
5385 #ifdef ENABLE_LOGGING_AND_PROFILING
5386 i::Isolate* isolate = i::Isolate::Current(); 5498 i::Isolate* isolate = i::Isolate::Current();
5387 IsDeadCheck(isolate, "v8::CpuProfileNode::GetSelfTime"); 5499 IsDeadCheck(isolate, "v8::CpuProfileNode::GetSelfTime");
5388 return reinterpret_cast<const i::ProfileNode*>(this)->GetSelfMillis(); 5500 return reinterpret_cast<const i::ProfileNode*>(this)->GetSelfMillis();
5389 #else
5390 return 0.0;
5391 #endif
5392 } 5501 }
5393 5502
5394 5503
5395 double CpuProfileNode::GetTotalSamplesCount() const { 5504 double CpuProfileNode::GetTotalSamplesCount() const {
5396 #ifdef ENABLE_LOGGING_AND_PROFILING
5397 i::Isolate* isolate = i::Isolate::Current(); 5505 i::Isolate* isolate = i::Isolate::Current();
5398 IsDeadCheck(isolate, "v8::CpuProfileNode::GetTotalSamplesCount"); 5506 IsDeadCheck(isolate, "v8::CpuProfileNode::GetTotalSamplesCount");
5399 return reinterpret_cast<const i::ProfileNode*>(this)->total_ticks(); 5507 return reinterpret_cast<const i::ProfileNode*>(this)->total_ticks();
5400 #else
5401 return 0.0;
5402 #endif
5403 } 5508 }
5404 5509
5405 5510
5406 double CpuProfileNode::GetSelfSamplesCount() const { 5511 double CpuProfileNode::GetSelfSamplesCount() const {
5407 #ifdef ENABLE_LOGGING_AND_PROFILING
5408 i::Isolate* isolate = i::Isolate::Current(); 5512 i::Isolate* isolate = i::Isolate::Current();
5409 IsDeadCheck(isolate, "v8::CpuProfileNode::GetSelfSamplesCount"); 5513 IsDeadCheck(isolate, "v8::CpuProfileNode::GetSelfSamplesCount");
5410 return reinterpret_cast<const i::ProfileNode*>(this)->self_ticks(); 5514 return reinterpret_cast<const i::ProfileNode*>(this)->self_ticks();
5411 #else
5412 return 0.0;
5413 #endif
5414 } 5515 }
5415 5516
5416 5517
5417 unsigned CpuProfileNode::GetCallUid() const { 5518 unsigned CpuProfileNode::GetCallUid() const {
5418 #ifdef ENABLE_LOGGING_AND_PROFILING
5419 i::Isolate* isolate = i::Isolate::Current(); 5519 i::Isolate* isolate = i::Isolate::Current();
5420 IsDeadCheck(isolate, "v8::CpuProfileNode::GetCallUid"); 5520 IsDeadCheck(isolate, "v8::CpuProfileNode::GetCallUid");
5421 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->GetCallUid(); 5521 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->GetCallUid();
5422 #else
5423 return 0;
5424 #endif
5425 } 5522 }
5426 5523
5427 5524
5428 int CpuProfileNode::GetChildrenCount() const { 5525 int CpuProfileNode::GetChildrenCount() const {
5429 #ifdef ENABLE_LOGGING_AND_PROFILING
5430 i::Isolate* isolate = i::Isolate::Current(); 5526 i::Isolate* isolate = i::Isolate::Current();
5431 IsDeadCheck(isolate, "v8::CpuProfileNode::GetChildrenCount"); 5527 IsDeadCheck(isolate, "v8::CpuProfileNode::GetChildrenCount");
5432 return reinterpret_cast<const i::ProfileNode*>(this)->children()->length(); 5528 return reinterpret_cast<const i::ProfileNode*>(this)->children()->length();
5433 #else
5434 return 0;
5435 #endif
5436 } 5529 }
5437 5530
5438 5531
5439 const CpuProfileNode* CpuProfileNode::GetChild(int index) const { 5532 const CpuProfileNode* CpuProfileNode::GetChild(int index) const {
5440 #ifdef ENABLE_LOGGING_AND_PROFILING
5441 i::Isolate* isolate = i::Isolate::Current(); 5533 i::Isolate* isolate = i::Isolate::Current();
5442 IsDeadCheck(isolate, "v8::CpuProfileNode::GetChild"); 5534 IsDeadCheck(isolate, "v8::CpuProfileNode::GetChild");
5443 const i::ProfileNode* child = 5535 const i::ProfileNode* child =
5444 reinterpret_cast<const i::ProfileNode*>(this)->children()->at(index); 5536 reinterpret_cast<const i::ProfileNode*>(this)->children()->at(index);
5445 return reinterpret_cast<const CpuProfileNode*>(child); 5537 return reinterpret_cast<const CpuProfileNode*>(child);
5446 #else
5447 return NULL;
5448 #endif
5449 } 5538 }
5450 5539
5451 5540
5452 void CpuProfile::Delete() { 5541 void CpuProfile::Delete() {
5453 #ifdef ENABLE_LOGGING_AND_PROFILING
5454 i::Isolate* isolate = i::Isolate::Current(); 5542 i::Isolate* isolate = i::Isolate::Current();
5455 IsDeadCheck(isolate, "v8::CpuProfile::Delete"); 5543 IsDeadCheck(isolate, "v8::CpuProfile::Delete");
5456 i::CpuProfiler::DeleteProfile(reinterpret_cast<i::CpuProfile*>(this)); 5544 i::CpuProfiler::DeleteProfile(reinterpret_cast<i::CpuProfile*>(this));
5457 if (i::CpuProfiler::GetProfilesCount() == 0 && 5545 if (i::CpuProfiler::GetProfilesCount() == 0 &&
5458 !i::CpuProfiler::HasDetachedProfiles()) { 5546 !i::CpuProfiler::HasDetachedProfiles()) {
5459 // If this was the last profile, clean up all accessory data as well. 5547 // If this was the last profile, clean up all accessory data as well.
5460 i::CpuProfiler::DeleteAllProfiles(); 5548 i::CpuProfiler::DeleteAllProfiles();
5461 } 5549 }
5462 #endif
5463 } 5550 }
5464 5551
5465 5552
5466 unsigned CpuProfile::GetUid() const { 5553 unsigned CpuProfile::GetUid() const {
5467 #ifdef ENABLE_LOGGING_AND_PROFILING
5468 i::Isolate* isolate = i::Isolate::Current(); 5554 i::Isolate* isolate = i::Isolate::Current();
5469 IsDeadCheck(isolate, "v8::CpuProfile::GetUid"); 5555 IsDeadCheck(isolate, "v8::CpuProfile::GetUid");
5470 return reinterpret_cast<const i::CpuProfile*>(this)->uid(); 5556 return reinterpret_cast<const i::CpuProfile*>(this)->uid();
5471 #else
5472 return 0;
5473 #endif
5474 } 5557 }
5475 5558
5476 5559
5477 Handle<String> CpuProfile::GetTitle() const { 5560 Handle<String> CpuProfile::GetTitle() const {
5478 #ifdef ENABLE_LOGGING_AND_PROFILING
5479 i::Isolate* isolate = i::Isolate::Current(); 5561 i::Isolate* isolate = i::Isolate::Current();
5480 IsDeadCheck(isolate, "v8::CpuProfile::GetTitle"); 5562 IsDeadCheck(isolate, "v8::CpuProfile::GetTitle");
5481 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); 5563 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
5482 return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol( 5564 return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol(
5483 profile->title()))); 5565 profile->title())));
5484 #else
5485 return v8::String::Empty();
5486 #endif
5487 } 5566 }
5488 5567
5489 5568
5490 const CpuProfileNode* CpuProfile::GetBottomUpRoot() const { 5569 const CpuProfileNode* CpuProfile::GetBottomUpRoot() const {
5491 #ifdef ENABLE_LOGGING_AND_PROFILING
5492 i::Isolate* isolate = i::Isolate::Current(); 5570 i::Isolate* isolate = i::Isolate::Current();
5493 IsDeadCheck(isolate, "v8::CpuProfile::GetBottomUpRoot"); 5571 IsDeadCheck(isolate, "v8::CpuProfile::GetBottomUpRoot");
5494 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); 5572 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
5495 return reinterpret_cast<const CpuProfileNode*>(profile->bottom_up()->root()); 5573 return reinterpret_cast<const CpuProfileNode*>(profile->bottom_up()->root());
5496 #else
5497 return NULL;
5498 #endif
5499 } 5574 }
5500 5575
5501 5576
5502 const CpuProfileNode* CpuProfile::GetTopDownRoot() const { 5577 const CpuProfileNode* CpuProfile::GetTopDownRoot() const {
5503 #ifdef ENABLE_LOGGING_AND_PROFILING
5504 i::Isolate* isolate = i::Isolate::Current(); 5578 i::Isolate* isolate = i::Isolate::Current();
5505 IsDeadCheck(isolate, "v8::CpuProfile::GetTopDownRoot"); 5579 IsDeadCheck(isolate, "v8::CpuProfile::GetTopDownRoot");
5506 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); 5580 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
5507 return reinterpret_cast<const CpuProfileNode*>(profile->top_down()->root()); 5581 return reinterpret_cast<const CpuProfileNode*>(profile->top_down()->root());
5508 #else
5509 return NULL;
5510 #endif
5511 } 5582 }
5512 5583
5513 5584
5514 int CpuProfiler::GetProfilesCount() { 5585 int CpuProfiler::GetProfilesCount() {
5515 #ifdef ENABLE_LOGGING_AND_PROFILING
5516 i::Isolate* isolate = i::Isolate::Current(); 5586 i::Isolate* isolate = i::Isolate::Current();
5517 IsDeadCheck(isolate, "v8::CpuProfiler::GetProfilesCount"); 5587 IsDeadCheck(isolate, "v8::CpuProfiler::GetProfilesCount");
5518 return i::CpuProfiler::GetProfilesCount(); 5588 return i::CpuProfiler::GetProfilesCount();
5519 #else
5520 return 0;
5521 #endif
5522 } 5589 }
5523 5590
5524 5591
5525 const CpuProfile* CpuProfiler::GetProfile(int index, 5592 const CpuProfile* CpuProfiler::GetProfile(int index,
5526 Handle<Value> security_token) { 5593 Handle<Value> security_token) {
5527 #ifdef ENABLE_LOGGING_AND_PROFILING
5528 i::Isolate* isolate = i::Isolate::Current(); 5594 i::Isolate* isolate = i::Isolate::Current();
5529 IsDeadCheck(isolate, "v8::CpuProfiler::GetProfile"); 5595 IsDeadCheck(isolate, "v8::CpuProfiler::GetProfile");
5530 return reinterpret_cast<const CpuProfile*>( 5596 return reinterpret_cast<const CpuProfile*>(
5531 i::CpuProfiler::GetProfile( 5597 i::CpuProfiler::GetProfile(
5532 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), 5598 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
5533 index)); 5599 index));
5534 #else
5535 return NULL;
5536 #endif
5537 } 5600 }
5538 5601
5539 5602
5540 const CpuProfile* CpuProfiler::FindProfile(unsigned uid, 5603 const CpuProfile* CpuProfiler::FindProfile(unsigned uid,
5541 Handle<Value> security_token) { 5604 Handle<Value> security_token) {
5542 #ifdef ENABLE_LOGGING_AND_PROFILING
5543 i::Isolate* isolate = i::Isolate::Current(); 5605 i::Isolate* isolate = i::Isolate::Current();
5544 IsDeadCheck(isolate, "v8::CpuProfiler::FindProfile"); 5606 IsDeadCheck(isolate, "v8::CpuProfiler::FindProfile");
5545 return reinterpret_cast<const CpuProfile*>( 5607 return reinterpret_cast<const CpuProfile*>(
5546 i::CpuProfiler::FindProfile( 5608 i::CpuProfiler::FindProfile(
5547 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), 5609 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
5548 uid)); 5610 uid));
5549 #else
5550 return NULL;
5551 #endif
5552 } 5611 }
5553 5612
5554 5613
5555 void CpuProfiler::StartProfiling(Handle<String> title) { 5614 void CpuProfiler::StartProfiling(Handle<String> title) {
5556 #ifdef ENABLE_LOGGING_AND_PROFILING
5557 i::Isolate* isolate = i::Isolate::Current(); 5615 i::Isolate* isolate = i::Isolate::Current();
5558 IsDeadCheck(isolate, "v8::CpuProfiler::StartProfiling"); 5616 IsDeadCheck(isolate, "v8::CpuProfiler::StartProfiling");
5559 i::CpuProfiler::StartProfiling(*Utils::OpenHandle(*title)); 5617 i::CpuProfiler::StartProfiling(*Utils::OpenHandle(*title));
5560 #endif
5561 } 5618 }
5562 5619
5563 5620
5564 const CpuProfile* CpuProfiler::StopProfiling(Handle<String> title, 5621 const CpuProfile* CpuProfiler::StopProfiling(Handle<String> title,
5565 Handle<Value> security_token) { 5622 Handle<Value> security_token) {
5566 #ifdef ENABLE_LOGGING_AND_PROFILING
5567 i::Isolate* isolate = i::Isolate::Current(); 5623 i::Isolate* isolate = i::Isolate::Current();
5568 IsDeadCheck(isolate, "v8::CpuProfiler::StopProfiling"); 5624 IsDeadCheck(isolate, "v8::CpuProfiler::StopProfiling");
5569 return reinterpret_cast<const CpuProfile*>( 5625 return reinterpret_cast<const CpuProfile*>(
5570 i::CpuProfiler::StopProfiling( 5626 i::CpuProfiler::StopProfiling(
5571 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), 5627 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
5572 *Utils::OpenHandle(*title))); 5628 *Utils::OpenHandle(*title)));
5573 #else
5574 return NULL;
5575 #endif
5576 } 5629 }
5577 5630
5578 5631
5579 void CpuProfiler::DeleteAllProfiles() { 5632 void CpuProfiler::DeleteAllProfiles() {
5580 #ifdef ENABLE_LOGGING_AND_PROFILING
5581 i::Isolate* isolate = i::Isolate::Current(); 5633 i::Isolate* isolate = i::Isolate::Current();
5582 IsDeadCheck(isolate, "v8::CpuProfiler::DeleteAllProfiles"); 5634 IsDeadCheck(isolate, "v8::CpuProfiler::DeleteAllProfiles");
5583 i::CpuProfiler::DeleteAllProfiles(); 5635 i::CpuProfiler::DeleteAllProfiles();
5584 #endif
5585 } 5636 }
5586 5637
5587 5638
5588 #ifdef ENABLE_LOGGING_AND_PROFILING
5589 static i::HeapGraphEdge* ToInternal(const HeapGraphEdge* edge) { 5639 static i::HeapGraphEdge* ToInternal(const HeapGraphEdge* edge) {
5590 return const_cast<i::HeapGraphEdge*>( 5640 return const_cast<i::HeapGraphEdge*>(
5591 reinterpret_cast<const i::HeapGraphEdge*>(edge)); 5641 reinterpret_cast<const i::HeapGraphEdge*>(edge));
5592 } 5642 }
5593 #endif
5594 5643
5595 5644
5596 HeapGraphEdge::Type HeapGraphEdge::GetType() const { 5645 HeapGraphEdge::Type HeapGraphEdge::GetType() const {
5597 #ifdef ENABLE_LOGGING_AND_PROFILING
5598 i::Isolate* isolate = i::Isolate::Current(); 5646 i::Isolate* isolate = i::Isolate::Current();
5599 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetType"); 5647 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetType");
5600 return static_cast<HeapGraphEdge::Type>(ToInternal(this)->type()); 5648 return static_cast<HeapGraphEdge::Type>(ToInternal(this)->type());
5601 #else
5602 return static_cast<HeapGraphEdge::Type>(0);
5603 #endif
5604 } 5649 }
5605 5650
5606 5651
5607 Handle<Value> HeapGraphEdge::GetName() const { 5652 Handle<Value> HeapGraphEdge::GetName() const {
5608 #ifdef ENABLE_LOGGING_AND_PROFILING
5609 i::Isolate* isolate = i::Isolate::Current(); 5653 i::Isolate* isolate = i::Isolate::Current();
5610 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetName"); 5654 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetName");
5611 i::HeapGraphEdge* edge = ToInternal(this); 5655 i::HeapGraphEdge* edge = ToInternal(this);
5612 switch (edge->type()) { 5656 switch (edge->type()) {
5613 case i::HeapGraphEdge::kContextVariable: 5657 case i::HeapGraphEdge::kContextVariable:
5614 case i::HeapGraphEdge::kInternal: 5658 case i::HeapGraphEdge::kInternal:
5615 case i::HeapGraphEdge::kProperty: 5659 case i::HeapGraphEdge::kProperty:
5616 case i::HeapGraphEdge::kShortcut: 5660 case i::HeapGraphEdge::kShortcut:
5617 return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol( 5661 return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol(
5618 edge->name()))); 5662 edge->name())));
5619 case i::HeapGraphEdge::kElement: 5663 case i::HeapGraphEdge::kElement:
5620 case i::HeapGraphEdge::kHidden: 5664 case i::HeapGraphEdge::kHidden:
5621 return Handle<Number>(ToApi<Number>(isolate->factory()->NewNumberFromInt( 5665 return Handle<Number>(ToApi<Number>(isolate->factory()->NewNumberFromInt(
5622 edge->index()))); 5666 edge->index())));
5623 default: UNREACHABLE(); 5667 default: UNREACHABLE();
5624 } 5668 }
5625 #endif
5626 return v8::Undefined(); 5669 return v8::Undefined();
5627 } 5670 }
5628 5671
5629 5672
5630 const HeapGraphNode* HeapGraphEdge::GetFromNode() const { 5673 const HeapGraphNode* HeapGraphEdge::GetFromNode() const {
5631 #ifdef ENABLE_LOGGING_AND_PROFILING
5632 i::Isolate* isolate = i::Isolate::Current(); 5674 i::Isolate* isolate = i::Isolate::Current();
5633 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetFromNode"); 5675 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetFromNode");
5634 const i::HeapEntry* from = ToInternal(this)->From(); 5676 const i::HeapEntry* from = ToInternal(this)->From();
5635 return reinterpret_cast<const HeapGraphNode*>(from); 5677 return reinterpret_cast<const HeapGraphNode*>(from);
5636 #else
5637 return NULL;
5638 #endif
5639 } 5678 }
5640 5679
5641 5680
5642 const HeapGraphNode* HeapGraphEdge::GetToNode() const { 5681 const HeapGraphNode* HeapGraphEdge::GetToNode() const {
5643 #ifdef ENABLE_LOGGING_AND_PROFILING
5644 i::Isolate* isolate = i::Isolate::Current(); 5682 i::Isolate* isolate = i::Isolate::Current();
5645 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetToNode"); 5683 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetToNode");
5646 const i::HeapEntry* to = ToInternal(this)->to(); 5684 const i::HeapEntry* to = ToInternal(this)->to();
5647 return reinterpret_cast<const HeapGraphNode*>(to); 5685 return reinterpret_cast<const HeapGraphNode*>(to);
5648 #else
5649 return NULL;
5650 #endif
5651 } 5686 }
5652 5687
5653 5688
5654 #ifdef ENABLE_LOGGING_AND_PROFILING
5655 static i::HeapEntry* ToInternal(const HeapGraphNode* entry) { 5689 static i::HeapEntry* ToInternal(const HeapGraphNode* entry) {
5656 return const_cast<i::HeapEntry*>( 5690 return const_cast<i::HeapEntry*>(
5657 reinterpret_cast<const i::HeapEntry*>(entry)); 5691 reinterpret_cast<const i::HeapEntry*>(entry));
5658 } 5692 }
5659 #endif
5660 5693
5661 5694
5662 HeapGraphNode::Type HeapGraphNode::GetType() const { 5695 HeapGraphNode::Type HeapGraphNode::GetType() const {
5663 #ifdef ENABLE_LOGGING_AND_PROFILING
5664 i::Isolate* isolate = i::Isolate::Current(); 5696 i::Isolate* isolate = i::Isolate::Current();
5665 IsDeadCheck(isolate, "v8::HeapGraphNode::GetType"); 5697 IsDeadCheck(isolate, "v8::HeapGraphNode::GetType");
5666 return static_cast<HeapGraphNode::Type>(ToInternal(this)->type()); 5698 return static_cast<HeapGraphNode::Type>(ToInternal(this)->type());
5667 #else
5668 return static_cast<HeapGraphNode::Type>(0);
5669 #endif
5670 } 5699 }
5671 5700
5672 5701
5673 Handle<String> HeapGraphNode::GetName() const { 5702 Handle<String> HeapGraphNode::GetName() const {
5674 #ifdef ENABLE_LOGGING_AND_PROFILING
5675 i::Isolate* isolate = i::Isolate::Current(); 5703 i::Isolate* isolate = i::Isolate::Current();
5676 IsDeadCheck(isolate, "v8::HeapGraphNode::GetName"); 5704 IsDeadCheck(isolate, "v8::HeapGraphNode::GetName");
5677 return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol( 5705 return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol(
5678 ToInternal(this)->name()))); 5706 ToInternal(this)->name())));
5679 #else
5680 return v8::String::Empty();
5681 #endif
5682 } 5707 }
5683 5708
5684 5709
5685 uint64_t HeapGraphNode::GetId() const { 5710 uint64_t HeapGraphNode::GetId() const {
5686 #ifdef ENABLE_LOGGING_AND_PROFILING
5687 i::Isolate* isolate = i::Isolate::Current(); 5711 i::Isolate* isolate = i::Isolate::Current();
5688 IsDeadCheck(isolate, "v8::HeapGraphNode::GetId"); 5712 IsDeadCheck(isolate, "v8::HeapGraphNode::GetId");
5689 return ToInternal(this)->id(); 5713 return ToInternal(this)->id();
5690 #else
5691 return 0;
5692 #endif
5693 } 5714 }
5694 5715
5695 5716
5696 int HeapGraphNode::GetSelfSize() const { 5717 int HeapGraphNode::GetSelfSize() const {
5697 #ifdef ENABLE_LOGGING_AND_PROFILING
5698 i::Isolate* isolate = i::Isolate::Current(); 5718 i::Isolate* isolate = i::Isolate::Current();
5699 IsDeadCheck(isolate, "v8::HeapGraphNode::GetSelfSize"); 5719 IsDeadCheck(isolate, "v8::HeapGraphNode::GetSelfSize");
5700 return ToInternal(this)->self_size(); 5720 return ToInternal(this)->self_size();
5701 #else
5702 return 0;
5703 #endif
5704 } 5721 }
5705 5722
5706 5723
5707 int HeapGraphNode::GetRetainedSize(bool exact) const { 5724 int HeapGraphNode::GetRetainedSize(bool exact) const {
5708 #ifdef ENABLE_LOGGING_AND_PROFILING
5709 i::Isolate* isolate = i::Isolate::Current(); 5725 i::Isolate* isolate = i::Isolate::Current();
5710 IsDeadCheck(isolate, "v8::HeapSnapshot::GetRetainedSize"); 5726 IsDeadCheck(isolate, "v8::HeapSnapshot::GetRetainedSize");
5711 return ToInternal(this)->RetainedSize(exact); 5727 return ToInternal(this)->RetainedSize(exact);
5712 #else
5713 return 0;
5714 #endif
5715 } 5728 }
5716 5729
5717 5730
5718 int HeapGraphNode::GetChildrenCount() const { 5731 int HeapGraphNode::GetChildrenCount() const {
5719 #ifdef ENABLE_LOGGING_AND_PROFILING
5720 i::Isolate* isolate = i::Isolate::Current(); 5732 i::Isolate* isolate = i::Isolate::Current();
5721 IsDeadCheck(isolate, "v8::HeapSnapshot::GetChildrenCount"); 5733 IsDeadCheck(isolate, "v8::HeapSnapshot::GetChildrenCount");
5722 return ToInternal(this)->children().length(); 5734 return ToInternal(this)->children().length();
5723 #else
5724 return 0;
5725 #endif
5726 } 5735 }
5727 5736
5728 5737
5729 const HeapGraphEdge* HeapGraphNode::GetChild(int index) const { 5738 const HeapGraphEdge* HeapGraphNode::GetChild(int index) const {
5730 #ifdef ENABLE_LOGGING_AND_PROFILING
5731 i::Isolate* isolate = i::Isolate::Current(); 5739 i::Isolate* isolate = i::Isolate::Current();
5732 IsDeadCheck(isolate, "v8::HeapSnapshot::GetChild"); 5740 IsDeadCheck(isolate, "v8::HeapSnapshot::GetChild");
5733 return reinterpret_cast<const HeapGraphEdge*>( 5741 return reinterpret_cast<const HeapGraphEdge*>(
5734 &ToInternal(this)->children()[index]); 5742 &ToInternal(this)->children()[index]);
5735 #else
5736 return NULL;
5737 #endif
5738 } 5743 }
5739 5744
5740 5745
5741 int HeapGraphNode::GetRetainersCount() const { 5746 int HeapGraphNode::GetRetainersCount() const {
5742 #ifdef ENABLE_LOGGING_AND_PROFILING
5743 i::Isolate* isolate = i::Isolate::Current(); 5747 i::Isolate* isolate = i::Isolate::Current();
5744 IsDeadCheck(isolate, "v8::HeapSnapshot::GetRetainersCount"); 5748 IsDeadCheck(isolate, "v8::HeapSnapshot::GetRetainersCount");
5745 return ToInternal(this)->retainers().length(); 5749 return ToInternal(this)->retainers().length();
5746 #else
5747 return 0;
5748 #endif
5749 } 5750 }
5750 5751
5751 5752
5752 const HeapGraphEdge* HeapGraphNode::GetRetainer(int index) const { 5753 const HeapGraphEdge* HeapGraphNode::GetRetainer(int index) const {
5753 #ifdef ENABLE_LOGGING_AND_PROFILING
5754 i::Isolate* isolate = i::Isolate::Current(); 5754 i::Isolate* isolate = i::Isolate::Current();
5755 IsDeadCheck(isolate, "v8::HeapSnapshot::GetRetainer"); 5755 IsDeadCheck(isolate, "v8::HeapSnapshot::GetRetainer");
5756 return reinterpret_cast<const HeapGraphEdge*>( 5756 return reinterpret_cast<const HeapGraphEdge*>(
5757 ToInternal(this)->retainers()[index]); 5757 ToInternal(this)->retainers()[index]);
5758 #else
5759 return NULL;
5760 #endif
5761 } 5758 }
5762 5759
5763 5760
5764 const HeapGraphNode* HeapGraphNode::GetDominatorNode() const { 5761 const HeapGraphNode* HeapGraphNode::GetDominatorNode() const {
5765 #ifdef ENABLE_LOGGING_AND_PROFILING
5766 i::Isolate* isolate = i::Isolate::Current(); 5762 i::Isolate* isolate = i::Isolate::Current();
5767 IsDeadCheck(isolate, "v8::HeapSnapshot::GetDominatorNode"); 5763 IsDeadCheck(isolate, "v8::HeapSnapshot::GetDominatorNode");
5768 return reinterpret_cast<const HeapGraphNode*>(ToInternal(this)->dominator()); 5764 return reinterpret_cast<const HeapGraphNode*>(ToInternal(this)->dominator());
5769 #else
5770 return NULL;
5771 #endif
5772 } 5765 }
5773 5766
5774 5767
5775 #ifdef ENABLE_LOGGING_AND_PROFILING
5776 static i::HeapSnapshot* ToInternal(const HeapSnapshot* snapshot) { 5768 static i::HeapSnapshot* ToInternal(const HeapSnapshot* snapshot) {
5777 return const_cast<i::HeapSnapshot*>( 5769 return const_cast<i::HeapSnapshot*>(
5778 reinterpret_cast<const i::HeapSnapshot*>(snapshot)); 5770 reinterpret_cast<const i::HeapSnapshot*>(snapshot));
5779 } 5771 }
5780 #endif
5781 5772
5782 5773
5783 void HeapSnapshot::Delete() { 5774 void HeapSnapshot::Delete() {
5784 #ifdef ENABLE_LOGGING_AND_PROFILING
5785 i::Isolate* isolate = i::Isolate::Current(); 5775 i::Isolate* isolate = i::Isolate::Current();
5786 IsDeadCheck(isolate, "v8::HeapSnapshot::Delete"); 5776 IsDeadCheck(isolate, "v8::HeapSnapshot::Delete");
5787 if (i::HeapProfiler::GetSnapshotsCount() > 1) { 5777 if (i::HeapProfiler::GetSnapshotsCount() > 1) {
5788 ToInternal(this)->Delete(); 5778 ToInternal(this)->Delete();
5789 } else { 5779 } else {
5790 // If this is the last snapshot, clean up all accessory data as well. 5780 // If this is the last snapshot, clean up all accessory data as well.
5791 i::HeapProfiler::DeleteAllSnapshots(); 5781 i::HeapProfiler::DeleteAllSnapshots();
5792 } 5782 }
5793 #endif
5794 } 5783 }
5795 5784
5796 5785
5797 HeapSnapshot::Type HeapSnapshot::GetType() const { 5786 HeapSnapshot::Type HeapSnapshot::GetType() const {
5798 #ifdef ENABLE_LOGGING_AND_PROFILING
5799 i::Isolate* isolate = i::Isolate::Current(); 5787 i::Isolate* isolate = i::Isolate::Current();
5800 IsDeadCheck(isolate, "v8::HeapSnapshot::GetType"); 5788 IsDeadCheck(isolate, "v8::HeapSnapshot::GetType");
5801 return static_cast<HeapSnapshot::Type>(ToInternal(this)->type()); 5789 return static_cast<HeapSnapshot::Type>(ToInternal(this)->type());
5802 #else
5803 return static_cast<HeapSnapshot::Type>(0);
5804 #endif
5805 } 5790 }
5806 5791
5807 5792
5808 unsigned HeapSnapshot::GetUid() const { 5793 unsigned HeapSnapshot::GetUid() const {
5809 #ifdef ENABLE_LOGGING_AND_PROFILING
5810 i::Isolate* isolate = i::Isolate::Current(); 5794 i::Isolate* isolate = i::Isolate::Current();
5811 IsDeadCheck(isolate, "v8::HeapSnapshot::GetUid"); 5795 IsDeadCheck(isolate, "v8::HeapSnapshot::GetUid");
5812 return ToInternal(this)->uid(); 5796 return ToInternal(this)->uid();
5813 #else
5814 return 0;
5815 #endif
5816 } 5797 }
5817 5798
5818 5799
5819 Handle<String> HeapSnapshot::GetTitle() const { 5800 Handle<String> HeapSnapshot::GetTitle() const {
5820 #ifdef ENABLE_LOGGING_AND_PROFILING
5821 i::Isolate* isolate = i::Isolate::Current(); 5801 i::Isolate* isolate = i::Isolate::Current();
5822 IsDeadCheck(isolate, "v8::HeapSnapshot::GetTitle"); 5802 IsDeadCheck(isolate, "v8::HeapSnapshot::GetTitle");
5823 return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol( 5803 return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol(
5824 ToInternal(this)->title()))); 5804 ToInternal(this)->title())));
5825 #else
5826 return v8::String::Empty();
5827 #endif
5828 } 5805 }
5829 5806
5830 5807
5831 const HeapGraphNode* HeapSnapshot::GetRoot() const { 5808 const HeapGraphNode* HeapSnapshot::GetRoot() const {
5832 #ifdef ENABLE_LOGGING_AND_PROFILING
5833 i::Isolate* isolate = i::Isolate::Current(); 5809 i::Isolate* isolate = i::Isolate::Current();
5834 IsDeadCheck(isolate, "v8::HeapSnapshot::GetHead"); 5810 IsDeadCheck(isolate, "v8::HeapSnapshot::GetHead");
5835 return reinterpret_cast<const HeapGraphNode*>(ToInternal(this)->root()); 5811 return reinterpret_cast<const HeapGraphNode*>(ToInternal(this)->root());
5836 #else
5837 return 0;
5838 #endif
5839 } 5812 }
5840 5813
5841 5814
5842 const HeapGraphNode* HeapSnapshot::GetNodeById(uint64_t id) const { 5815 const HeapGraphNode* HeapSnapshot::GetNodeById(uint64_t id) const {
5843 #ifdef ENABLE_LOGGING_AND_PROFILING
5844 i::Isolate* isolate = i::Isolate::Current(); 5816 i::Isolate* isolate = i::Isolate::Current();
5845 IsDeadCheck(isolate, "v8::HeapSnapshot::GetNodeById"); 5817 IsDeadCheck(isolate, "v8::HeapSnapshot::GetNodeById");
5846 return reinterpret_cast<const HeapGraphNode*>( 5818 return reinterpret_cast<const HeapGraphNode*>(
5847 ToInternal(this)->GetEntryById(id)); 5819 ToInternal(this)->GetEntryById(id));
5848 #else
5849 return NULL;
5850 #endif
5851 } 5820 }
5852 5821
5853 5822
5854 int HeapSnapshot::GetNodesCount() const { 5823 int HeapSnapshot::GetNodesCount() const {
5855 #ifdef ENABLE_LOGGING_AND_PROFILING
5856 i::Isolate* isolate = i::Isolate::Current(); 5824 i::Isolate* isolate = i::Isolate::Current();
5857 IsDeadCheck(isolate, "v8::HeapSnapshot::GetNodesCount"); 5825 IsDeadCheck(isolate, "v8::HeapSnapshot::GetNodesCount");
5858 return ToInternal(this)->entries()->length(); 5826 return ToInternal(this)->entries()->length();
5859 #else
5860 return 0;
5861 #endif
5862 } 5827 }
5863 5828
5864 5829
5865 const HeapGraphNode* HeapSnapshot::GetNode(int index) const { 5830 const HeapGraphNode* HeapSnapshot::GetNode(int index) const {
5866 #ifdef ENABLE_LOGGING_AND_PROFILING
5867 i::Isolate* isolate = i::Isolate::Current(); 5831 i::Isolate* isolate = i::Isolate::Current();
5868 IsDeadCheck(isolate, "v8::HeapSnapshot::GetNode"); 5832 IsDeadCheck(isolate, "v8::HeapSnapshot::GetNode");
5869 return reinterpret_cast<const HeapGraphNode*>( 5833 return reinterpret_cast<const HeapGraphNode*>(
5870 ToInternal(this)->entries()->at(index)); 5834 ToInternal(this)->entries()->at(index));
5871 #else
5872 return 0;
5873 #endif
5874 } 5835 }
5875 5836
5876 5837
5877 void HeapSnapshot::Serialize(OutputStream* stream, 5838 void HeapSnapshot::Serialize(OutputStream* stream,
5878 HeapSnapshot::SerializationFormat format) const { 5839 HeapSnapshot::SerializationFormat format) const {
5879 #ifdef ENABLE_LOGGING_AND_PROFILING
5880 i::Isolate* isolate = i::Isolate::Current(); 5840 i::Isolate* isolate = i::Isolate::Current();
5881 IsDeadCheck(isolate, "v8::HeapSnapshot::Serialize"); 5841 IsDeadCheck(isolate, "v8::HeapSnapshot::Serialize");
5882 ApiCheck(format == kJSON, 5842 ApiCheck(format == kJSON,
5883 "v8::HeapSnapshot::Serialize", 5843 "v8::HeapSnapshot::Serialize",
5884 "Unknown serialization format"); 5844 "Unknown serialization format");
5885 ApiCheck(stream->GetOutputEncoding() == OutputStream::kAscii, 5845 ApiCheck(stream->GetOutputEncoding() == OutputStream::kAscii,
5886 "v8::HeapSnapshot::Serialize", 5846 "v8::HeapSnapshot::Serialize",
5887 "Unsupported output encoding"); 5847 "Unsupported output encoding");
5888 ApiCheck(stream->GetChunkSize() > 0, 5848 ApiCheck(stream->GetChunkSize() > 0,
5889 "v8::HeapSnapshot::Serialize", 5849 "v8::HeapSnapshot::Serialize",
5890 "Invalid stream chunk size"); 5850 "Invalid stream chunk size");
5891 i::HeapSnapshotJSONSerializer serializer(ToInternal(this)); 5851 i::HeapSnapshotJSONSerializer serializer(ToInternal(this));
5892 serializer.Serialize(stream); 5852 serializer.Serialize(stream);
5893 #endif
5894 } 5853 }
5895 5854
5896 5855
5897 int HeapProfiler::GetSnapshotsCount() { 5856 int HeapProfiler::GetSnapshotsCount() {
5898 #ifdef ENABLE_LOGGING_AND_PROFILING
5899 i::Isolate* isolate = i::Isolate::Current(); 5857 i::Isolate* isolate = i::Isolate::Current();
5900 IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshotsCount"); 5858 IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshotsCount");
5901 return i::HeapProfiler::GetSnapshotsCount(); 5859 return i::HeapProfiler::GetSnapshotsCount();
5902 #else
5903 return 0;
5904 #endif
5905 } 5860 }
5906 5861
5907 5862
5908 const HeapSnapshot* HeapProfiler::GetSnapshot(int index) { 5863 const HeapSnapshot* HeapProfiler::GetSnapshot(int index) {
5909 #ifdef ENABLE_LOGGING_AND_PROFILING
5910 i::Isolate* isolate = i::Isolate::Current(); 5864 i::Isolate* isolate = i::Isolate::Current();
5911 IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshot"); 5865 IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshot");
5912 return reinterpret_cast<const HeapSnapshot*>( 5866 return reinterpret_cast<const HeapSnapshot*>(
5913 i::HeapProfiler::GetSnapshot(index)); 5867 i::HeapProfiler::GetSnapshot(index));
5914 #else
5915 return NULL;
5916 #endif
5917 } 5868 }
5918 5869
5919 5870
5920 const HeapSnapshot* HeapProfiler::FindSnapshot(unsigned uid) { 5871 const HeapSnapshot* HeapProfiler::FindSnapshot(unsigned uid) {
5921 #ifdef ENABLE_LOGGING_AND_PROFILING
5922 i::Isolate* isolate = i::Isolate::Current(); 5872 i::Isolate* isolate = i::Isolate::Current();
5923 IsDeadCheck(isolate, "v8::HeapProfiler::FindSnapshot"); 5873 IsDeadCheck(isolate, "v8::HeapProfiler::FindSnapshot");
5924 return reinterpret_cast<const HeapSnapshot*>( 5874 return reinterpret_cast<const HeapSnapshot*>(
5925 i::HeapProfiler::FindSnapshot(uid)); 5875 i::HeapProfiler::FindSnapshot(uid));
5926 #else
5927 return NULL;
5928 #endif
5929 } 5876 }
5930 5877
5931 5878
5932 const HeapSnapshot* HeapProfiler::TakeSnapshot(Handle<String> title, 5879 const HeapSnapshot* HeapProfiler::TakeSnapshot(Handle<String> title,
5933 HeapSnapshot::Type type, 5880 HeapSnapshot::Type type,
5934 ActivityControl* control) { 5881 ActivityControl* control) {
5935 #ifdef ENABLE_LOGGING_AND_PROFILING
5936 i::Isolate* isolate = i::Isolate::Current(); 5882 i::Isolate* isolate = i::Isolate::Current();
5937 IsDeadCheck(isolate, "v8::HeapProfiler::TakeSnapshot"); 5883 IsDeadCheck(isolate, "v8::HeapProfiler::TakeSnapshot");
5938 i::HeapSnapshot::Type internal_type = i::HeapSnapshot::kFull; 5884 i::HeapSnapshot::Type internal_type = i::HeapSnapshot::kFull;
5939 switch (type) { 5885 switch (type) {
5940 case HeapSnapshot::kFull: 5886 case HeapSnapshot::kFull:
5941 internal_type = i::HeapSnapshot::kFull; 5887 internal_type = i::HeapSnapshot::kFull;
5942 break; 5888 break;
5943 default: 5889 default:
5944 UNREACHABLE(); 5890 UNREACHABLE();
5945 } 5891 }
5946 return reinterpret_cast<const HeapSnapshot*>( 5892 return reinterpret_cast<const HeapSnapshot*>(
5947 i::HeapProfiler::TakeSnapshot( 5893 i::HeapProfiler::TakeSnapshot(
5948 *Utils::OpenHandle(*title), internal_type, control)); 5894 *Utils::OpenHandle(*title), internal_type, control));
5949 #else
5950 return NULL;
5951 #endif
5952 } 5895 }
5953 5896
5954 5897
5955 void HeapProfiler::DeleteAllSnapshots() { 5898 void HeapProfiler::DeleteAllSnapshots() {
5956 #ifdef ENABLE_LOGGING_AND_PROFILING
5957 i::Isolate* isolate = i::Isolate::Current(); 5899 i::Isolate* isolate = i::Isolate::Current();
5958 IsDeadCheck(isolate, "v8::HeapProfiler::DeleteAllSnapshots"); 5900 IsDeadCheck(isolate, "v8::HeapProfiler::DeleteAllSnapshots");
5959 i::HeapProfiler::DeleteAllSnapshots(); 5901 i::HeapProfiler::DeleteAllSnapshots();
5960 #endif
5961 } 5902 }
5962 5903
5963 5904
5964 void HeapProfiler::DefineWrapperClass(uint16_t class_id, 5905 void HeapProfiler::DefineWrapperClass(uint16_t class_id,
5965 WrapperInfoCallback callback) { 5906 WrapperInfoCallback callback) {
5966 #ifdef ENABLE_LOGGING_AND_PROFILING
5967 i::Isolate::Current()->heap_profiler()->DefineWrapperClass(class_id, 5907 i::Isolate::Current()->heap_profiler()->DefineWrapperClass(class_id,
5968 callback); 5908 callback);
5969 #endif
5970 } 5909 }
5971 5910
5972 5911
5973 5912
5974 v8::Testing::StressType internal::Testing::stress_type_ = 5913 v8::Testing::StressType internal::Testing::stress_type_ =
5975 v8::Testing::kStressTypeOpt; 5914 v8::Testing::kStressTypeOpt;
5976 5915
5977 5916
5978 void Testing::SetStressRunType(Testing::StressType type) { 5917 void Testing::SetStressRunType(Testing::StressType type) {
5979 internal::Testing::set_stress_type(type); 5918 internal::Testing::set_stress_type(type);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
6098 6037
6099 6038
6100 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 6039 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
6101 HandleScopeImplementer* scope_implementer = 6040 HandleScopeImplementer* scope_implementer =
6102 reinterpret_cast<HandleScopeImplementer*>(storage); 6041 reinterpret_cast<HandleScopeImplementer*>(storage);
6103 scope_implementer->IterateThis(v); 6042 scope_implementer->IterateThis(v);
6104 return storage + ArchiveSpacePerThread(); 6043 return storage + ArchiveSpacePerThread();
6105 } 6044 }
6106 6045
6107 } } // namespace v8::internal 6046 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/SConscript ('k') | src/apinatives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698