OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 25 matching lines...) Expand all Loading... |
36 #include "platform.h" | 36 #include "platform.h" |
37 #include "serialize.h" | 37 #include "serialize.h" |
38 #include "snapshot.h" | 38 #include "snapshot.h" |
39 #include "v8threads.h" | 39 #include "v8threads.h" |
40 | 40 |
41 | 41 |
42 #define LOG_API(expr) LOG(ApiEntryCall(expr)) | 42 #define LOG_API(expr) LOG(ApiEntryCall(expr)) |
43 | 43 |
44 #ifdef ENABLE_HEAP_PROTECTION | 44 #ifdef ENABLE_HEAP_PROTECTION |
45 #define ENTER_V8 i::VMState __state__(i::OTHER) | 45 #define ENTER_V8 i::VMState __state__(i::OTHER) |
| 46 #define LEAVE_V8 i::VMState __state__(i::EXTERNAL) |
46 #else | 47 #else |
47 #define ENTER_V8 ((void) 0) | 48 #define ENTER_V8 ((void) 0) |
| 49 #define LEAVE_V8 ((void) 0) |
48 #endif | 50 #endif |
49 | 51 |
50 | |
51 namespace v8 { | 52 namespace v8 { |
52 | 53 |
53 | 54 |
54 #define ON_BAILOUT(location, code) \ | 55 #define ON_BAILOUT(location, code) \ |
55 if (IsDeadCheck(location)) { \ | 56 if (IsDeadCheck(location)) { \ |
56 code; \ | 57 code; \ |
57 UNREACHABLE(); \ | 58 UNREACHABLE(); \ |
58 } | 59 } |
59 | 60 |
60 | 61 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 97 |
97 // --- E x c e p t i o n B e h a v i o r --- | 98 // --- E x c e p t i o n B e h a v i o r --- |
98 | 99 |
99 | 100 |
100 static bool has_shut_down = false; | 101 static bool has_shut_down = false; |
101 static FatalErrorCallback exception_behavior = NULL; | 102 static FatalErrorCallback exception_behavior = NULL; |
102 | 103 |
103 | 104 |
104 static void DefaultFatalErrorHandler(const char* location, | 105 static void DefaultFatalErrorHandler(const char* location, |
105 const char* message) { | 106 const char* message) { |
| 107 ENTER_V8; |
106 API_Fatal(location, message); | 108 API_Fatal(location, message); |
107 } | 109 } |
108 | 110 |
109 | 111 |
110 | 112 |
111 static FatalErrorCallback& GetFatalErrorHandler() { | 113 static FatalErrorCallback& GetFatalErrorHandler() { |
112 if (exception_behavior == NULL) { | 114 if (exception_behavior == NULL) { |
113 exception_behavior = DefaultFatalErrorHandler; | 115 exception_behavior = DefaultFatalErrorHandler; |
114 } | 116 } |
115 return exception_behavior; | 117 return exception_behavior; |
116 } | 118 } |
117 | 119 |
118 | 120 |
119 | 121 |
120 // When V8 cannot allocated memory FatalProcessOutOfMemory is called. | 122 // When V8 cannot allocated memory FatalProcessOutOfMemory is called. |
121 // The default fatal error handler is called and execution is stopped. | 123 // The default fatal error handler is called and execution is stopped. |
122 void i::V8::FatalProcessOutOfMemory(const char* location) { | 124 void i::V8::FatalProcessOutOfMemory(const char* location) { |
123 has_shut_down = true; | 125 has_shut_down = true; |
124 FatalErrorCallback callback = GetFatalErrorHandler(); | 126 FatalErrorCallback callback = GetFatalErrorHandler(); |
125 callback(location, "Allocation failed - process out of memory"); | 127 { |
| 128 LEAVE_V8; |
| 129 callback(location, "Allocation failed - process out of memory"); |
| 130 } |
126 // If the callback returns, we stop execution. | 131 // If the callback returns, we stop execution. |
127 UNREACHABLE(); | 132 UNREACHABLE(); |
128 } | 133 } |
129 | 134 |
130 | 135 |
131 void V8::SetFatalErrorHandler(FatalErrorCallback that) { | 136 void V8::SetFatalErrorHandler(FatalErrorCallback that) { |
132 exception_behavior = that; | 137 exception_behavior = that; |
133 } | 138 } |
134 | 139 |
135 | 140 |
136 bool Utils::ReportApiFailure(const char* location, const char* message) { | 141 bool Utils::ReportApiFailure(const char* location, const char* message) { |
137 FatalErrorCallback callback = GetFatalErrorHandler(); | 142 FatalErrorCallback callback = GetFatalErrorHandler(); |
138 callback(location, message); | 143 { |
| 144 LEAVE_V8; |
| 145 callback(location, message); |
| 146 } |
139 has_shut_down = true; | 147 has_shut_down = true; |
140 return false; | 148 return false; |
141 } | 149 } |
142 | 150 |
143 | 151 |
144 bool V8::IsDead() { | 152 bool V8::IsDead() { |
145 return has_shut_down; | 153 return has_shut_down; |
146 } | 154 } |
147 | 155 |
148 | 156 |
149 static inline bool ApiCheck(bool condition, | 157 static inline bool ApiCheck(bool condition, |
150 const char* location, | 158 const char* location, |
151 const char* message) { | 159 const char* message) { |
152 return condition ? true : Utils::ReportApiFailure(location, message); | 160 return condition ? true : Utils::ReportApiFailure(location, message); |
153 } | 161 } |
154 | 162 |
155 | 163 |
156 static bool ReportV8Dead(const char* location) { | 164 static bool ReportV8Dead(const char* location) { |
157 FatalErrorCallback callback = GetFatalErrorHandler(); | 165 FatalErrorCallback callback = GetFatalErrorHandler(); |
158 callback(location, "V8 is no longer usable"); | 166 { |
| 167 LEAVE_V8; |
| 168 callback(location, "V8 is no longer usable"); |
| 169 } |
159 return true; | 170 return true; |
160 } | 171 } |
161 | 172 |
162 | 173 |
163 static bool ReportEmptyHandle(const char* location) { | 174 static bool ReportEmptyHandle(const char* location) { |
164 FatalErrorCallback callback = GetFatalErrorHandler(); | 175 FatalErrorCallback callback = GetFatalErrorHandler(); |
165 callback(location, "Reading from empty handle"); | 176 { |
| 177 LEAVE_V8; |
| 178 callback(location, "Reading from empty handle"); |
| 179 } |
166 return true; | 180 return true; |
167 } | 181 } |
168 | 182 |
169 | 183 |
170 /** | 184 /** |
171 * IsDeadCheck checks that the vm is usable. If, for instance, the vm has been | 185 * IsDeadCheck checks that the vm is usable. If, for instance, the vm has been |
172 * out of memory at some point this check will fail. It should be called on | 186 * out of memory at some point this check will fail. It should be called on |
173 * entry to all methods that touch anything in the heap, except destructors | 187 * entry to all methods that touch anything in the heap, except destructors |
174 * which you sometimes can't avoid calling after the vm has crashed. Functions | 188 * which you sometimes can't avoid calling after the vm has crashed. Functions |
175 * that call EnsureInitialized or ON_BAILOUT don't have to also call | 189 * that call EnsureInitialized or ON_BAILOUT don't have to also call |
(...skipping 17 matching lines...) Expand all Loading... |
193 return (obj == 0) ? ReportEmptyHandle(location) : false; | 207 return (obj == 0) ? ReportEmptyHandle(location) : false; |
194 } | 208 } |
195 | 209 |
196 // --- S t a t i c s --- | 210 // --- S t a t i c s --- |
197 | 211 |
198 | 212 |
199 static i::StringInputBuffer write_input_buffer; | 213 static i::StringInputBuffer write_input_buffer; |
200 | 214 |
201 | 215 |
202 static void EnsureInitialized(const char* location) { | 216 static void EnsureInitialized(const char* location) { |
| 217 ENTER_V8; |
203 if (IsDeadCheck(location)) return; | 218 if (IsDeadCheck(location)) return; |
204 ApiCheck(v8::V8::Initialize(), location, "Error initializing V8"); | 219 ApiCheck(v8::V8::Initialize(), location, "Error initializing V8"); |
205 } | 220 } |
206 | 221 |
207 | 222 |
208 ImplementationUtilities::HandleScopeData* | 223 ImplementationUtilities::HandleScopeData* |
209 ImplementationUtilities::CurrentHandleScope() { | 224 ImplementationUtilities::CurrentHandleScope() { |
210 return &i::HandleScope::current_; | 225 return &i::HandleScope::current_; |
211 } | 226 } |
212 | 227 |
213 | 228 |
214 #ifdef DEBUG | 229 #ifdef DEBUG |
215 void ImplementationUtilities::ZapHandleRange(void** begin, void** end) { | 230 void ImplementationUtilities::ZapHandleRange(void** begin, void** end) { |
216 i::HandleScope::ZapRange(begin, end); | 231 i::HandleScope::ZapRange(begin, end); |
217 } | 232 } |
218 #endif | 233 #endif |
219 | 234 |
220 | 235 |
221 v8::Handle<v8::Primitive> ImplementationUtilities::Undefined() { | 236 v8::Handle<v8::Primitive> ImplementationUtilities::Undefined() { |
| 237 ENTER_V8; |
222 if (IsDeadCheck("v8::Undefined()")) return v8::Handle<v8::Primitive>(); | 238 if (IsDeadCheck("v8::Undefined()")) return v8::Handle<v8::Primitive>(); |
223 EnsureInitialized("v8::Undefined()"); | 239 EnsureInitialized("v8::Undefined()"); |
224 return v8::Handle<Primitive>(ToApi<Primitive>(i::Factory::undefined_value())); | 240 return v8::Handle<Primitive>(ToApi<Primitive>(i::Factory::undefined_value())); |
225 } | 241 } |
226 | 242 |
227 | 243 |
228 v8::Handle<v8::Primitive> ImplementationUtilities::Null() { | 244 v8::Handle<v8::Primitive> ImplementationUtilities::Null() { |
| 245 ENTER_V8; |
229 if (IsDeadCheck("v8::Null()")) return v8::Handle<v8::Primitive>(); | 246 if (IsDeadCheck("v8::Null()")) return v8::Handle<v8::Primitive>(); |
230 EnsureInitialized("v8::Null()"); | 247 EnsureInitialized("v8::Null()"); |
231 return v8::Handle<Primitive>(ToApi<Primitive>(i::Factory::null_value())); | 248 return v8::Handle<Primitive>(ToApi<Primitive>(i::Factory::null_value())); |
232 } | 249 } |
233 | 250 |
234 | 251 |
235 v8::Handle<v8::Boolean> ImplementationUtilities::True() { | 252 v8::Handle<v8::Boolean> ImplementationUtilities::True() { |
| 253 ENTER_V8; |
236 if (IsDeadCheck("v8::True()")) return v8::Handle<v8::Boolean>(); | 254 if (IsDeadCheck("v8::True()")) return v8::Handle<v8::Boolean>(); |
237 EnsureInitialized("v8::True()"); | 255 EnsureInitialized("v8::True()"); |
238 return v8::Handle<v8::Boolean>(ToApi<Boolean>(i::Factory::true_value())); | 256 return v8::Handle<v8::Boolean>(ToApi<Boolean>(i::Factory::true_value())); |
239 } | 257 } |
240 | 258 |
241 | 259 |
242 v8::Handle<v8::Boolean> ImplementationUtilities::False() { | 260 v8::Handle<v8::Boolean> ImplementationUtilities::False() { |
| 261 ENTER_V8; |
243 if (IsDeadCheck("v8::False()")) return v8::Handle<v8::Boolean>(); | 262 if (IsDeadCheck("v8::False()")) return v8::Handle<v8::Boolean>(); |
244 EnsureInitialized("v8::False()"); | 263 EnsureInitialized("v8::False()"); |
245 return v8::Handle<v8::Boolean>(ToApi<Boolean>(i::Factory::false_value())); | 264 return v8::Handle<v8::Boolean>(ToApi<Boolean>(i::Factory::false_value())); |
246 } | 265 } |
247 | 266 |
248 | 267 |
249 void V8::SetFlagsFromString(const char* str, int length) { | 268 void V8::SetFlagsFromString(const char* str, int length) { |
250 i::FlagList::SetFlagsFromString(str, length); | 269 i::FlagList::SetFlagsFromString(str, length); |
251 } | 270 } |
252 | 271 |
253 | 272 |
254 void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) { | 273 void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) { |
255 i::FlagList::SetFlagsFromCommandLine(argc, argv, remove_flags); | 274 i::FlagList::SetFlagsFromCommandLine(argc, argv, remove_flags); |
256 } | 275 } |
257 | 276 |
258 | 277 |
259 v8::Handle<Value> ThrowException(v8::Handle<v8::Value> value) { | 278 v8::Handle<Value> ThrowException(v8::Handle<v8::Value> value) { |
| 279 ENTER_V8; |
260 if (IsDeadCheck("v8::ThrowException()")) return v8::Handle<Value>(); | 280 if (IsDeadCheck("v8::ThrowException()")) return v8::Handle<Value>(); |
261 // If we're passed an empty handle, we throw an undefined exception | 281 // If we're passed an empty handle, we throw an undefined exception |
262 // to deal more gracefully with out of memory situations. | 282 // to deal more gracefully with out of memory situations. |
263 if (value.IsEmpty()) { | 283 if (value.IsEmpty()) { |
264 i::Top::ScheduleThrow(i::Heap::undefined_value()); | 284 i::Top::ScheduleThrow(i::Heap::undefined_value()); |
265 } else { | 285 } else { |
266 i::Top::ScheduleThrow(*Utils::OpenHandle(*value)); | 286 i::Top::ScheduleThrow(*Utils::OpenHandle(*value)); |
267 } | 287 } |
268 return v8::Undefined(); | 288 return v8::Undefined(); |
269 } | 289 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 if (!result) return false; | 355 if (!result) return false; |
336 if (constraints->stack_limit() != NULL) { | 356 if (constraints->stack_limit() != NULL) { |
337 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints->stack_limit()); | 357 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints->stack_limit()); |
338 i::StackGuard::SetStackLimit(limit); | 358 i::StackGuard::SetStackLimit(limit); |
339 } | 359 } |
340 return true; | 360 return true; |
341 } | 361 } |
342 | 362 |
343 | 363 |
344 void** V8::GlobalizeReference(void** obj) { | 364 void** V8::GlobalizeReference(void** obj) { |
| 365 ENTER_V8; |
345 LOG_API("Persistent::New"); | 366 LOG_API("Persistent::New"); |
346 if (IsDeadCheck("V8::Persistent::New")) return NULL; | 367 if (IsDeadCheck("V8::Persistent::New")) return NULL; |
347 i::Handle<i::Object> result = | 368 i::Handle<i::Object> result = |
348 i::GlobalHandles::Create(*reinterpret_cast<i::Object**>(obj)); | 369 i::GlobalHandles::Create(*reinterpret_cast<i::Object**>(obj)); |
349 return reinterpret_cast<void**>(result.location()); | 370 return reinterpret_cast<void**>(result.location()); |
350 } | 371 } |
351 | 372 |
352 | 373 |
353 void V8::MakeWeak(void** object, void* parameters, | 374 void V8::MakeWeak(void** object, void* parameters, |
354 WeakReferenceCallback callback) { | 375 WeakReferenceCallback callback) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 return i::HandleScope::NumberOfHandles(); | 427 return i::HandleScope::NumberOfHandles(); |
407 } | 428 } |
408 | 429 |
409 | 430 |
410 void** v8::HandleScope::CreateHandle(void* value) { | 431 void** v8::HandleScope::CreateHandle(void* value) { |
411 return i::HandleScope::CreateHandle(value); | 432 return i::HandleScope::CreateHandle(value); |
412 } | 433 } |
413 | 434 |
414 | 435 |
415 void Context::Enter() { | 436 void Context::Enter() { |
| 437 ENTER_V8; |
416 if (IsDeadCheck("v8::Context::Enter()")) return; | 438 if (IsDeadCheck("v8::Context::Enter()")) return; |
417 i::Handle<i::Context> env = Utils::OpenHandle(this); | 439 i::Handle<i::Context> env = Utils::OpenHandle(this); |
418 thread_local.EnterContext(env); | 440 thread_local.EnterContext(env); |
419 | 441 |
420 thread_local.SaveContext(i::GlobalHandles::Create(i::Top::context())); | 442 thread_local.SaveContext(i::GlobalHandles::Create(i::Top::context())); |
421 i::Top::set_context(*env); | 443 i::Top::set_context(*env); |
422 } | 444 } |
423 | 445 |
424 | 446 |
425 void Context::Exit() { | 447 void Context::Exit() { |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 | 569 |
548 // --- F u n c t i o n T e m p l a t e --- | 570 // --- F u n c t i o n T e m p l a t e --- |
549 static void InitializeFunctionTemplate( | 571 static void InitializeFunctionTemplate( |
550 i::Handle<i::FunctionTemplateInfo> info) { | 572 i::Handle<i::FunctionTemplateInfo> info) { |
551 info->set_tag(i::Smi::FromInt(Consts::FUNCTION_TEMPLATE)); | 573 info->set_tag(i::Smi::FromInt(Consts::FUNCTION_TEMPLATE)); |
552 info->set_flag(0); | 574 info->set_flag(0); |
553 } | 575 } |
554 | 576 |
555 | 577 |
556 Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() { | 578 Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() { |
| 579 ENTER_V8; |
557 if (IsDeadCheck("v8::FunctionTemplate::PrototypeTemplate()")) { | 580 if (IsDeadCheck("v8::FunctionTemplate::PrototypeTemplate()")) { |
558 return Local<ObjectTemplate>(); | 581 return Local<ObjectTemplate>(); |
559 } | 582 } |
560 i::Handle<i::Object> result(Utils::OpenHandle(this)->prototype_template()); | 583 i::Handle<i::Object> result(Utils::OpenHandle(this)->prototype_template()); |
561 if (result->IsUndefined()) { | 584 if (result->IsUndefined()) { |
562 result = Utils::OpenHandle(*ObjectTemplate::New()); | 585 result = Utils::OpenHandle(*ObjectTemplate::New()); |
563 Utils::OpenHandle(this)->set_prototype_template(*result); | 586 Utils::OpenHandle(this)->set_prototype_template(*result); |
564 } | 587 } |
565 return Local<ObjectTemplate>(ToApi<ObjectTemplate>(result)); | 588 return Local<ObjectTemplate>(ToApi<ObjectTemplate>(result)); |
566 } | 589 } |
567 | 590 |
568 | 591 |
569 void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) { | 592 void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) { |
| 593 ENTER_V8; |
570 if (IsDeadCheck("v8::FunctionTemplate::Inherit()")) return; | 594 if (IsDeadCheck("v8::FunctionTemplate::Inherit()")) return; |
571 Utils::OpenHandle(this)->set_parent_template(*Utils::OpenHandle(*value)); | 595 Utils::OpenHandle(this)->set_parent_template(*Utils::OpenHandle(*value)); |
572 } | 596 } |
573 | 597 |
574 | 598 |
575 // To distinguish the function templates, so that we can find them in the | 599 // To distinguish the function templates, so that we can find them in the |
576 // function cache of the global context. | 600 // function cache of the global context. |
577 static int next_serial_number = 0; | 601 static int next_serial_number = 0; |
578 | 602 |
579 | 603 |
(...skipping 16 matching lines...) Expand all Loading... |
596 obj->set_needs_access_check(false); | 620 obj->set_needs_access_check(false); |
597 | 621 |
598 if (!signature.IsEmpty()) | 622 if (!signature.IsEmpty()) |
599 obj->set_signature(*Utils::OpenHandle(*signature)); | 623 obj->set_signature(*Utils::OpenHandle(*signature)); |
600 return Utils::ToLocal(obj); | 624 return Utils::ToLocal(obj); |
601 } | 625 } |
602 | 626 |
603 | 627 |
604 Local<Signature> Signature::New(Handle<FunctionTemplate> receiver, | 628 Local<Signature> Signature::New(Handle<FunctionTemplate> receiver, |
605 int argc, Handle<FunctionTemplate> argv[]) { | 629 int argc, Handle<FunctionTemplate> argv[]) { |
| 630 ENTER_V8; |
606 EnsureInitialized("v8::Signature::New()"); | 631 EnsureInitialized("v8::Signature::New()"); |
607 LOG_API("Signature::New"); | 632 LOG_API("Signature::New"); |
608 i::Handle<i::Struct> struct_obj = | 633 i::Handle<i::Struct> struct_obj = |
609 i::Factory::NewStruct(i::SIGNATURE_INFO_TYPE); | 634 i::Factory::NewStruct(i::SIGNATURE_INFO_TYPE); |
610 i::Handle<i::SignatureInfo> obj = | 635 i::Handle<i::SignatureInfo> obj = |
611 i::Handle<i::SignatureInfo>::cast(struct_obj); | 636 i::Handle<i::SignatureInfo>::cast(struct_obj); |
612 if (!receiver.IsEmpty()) obj->set_receiver(*Utils::OpenHandle(*receiver)); | 637 if (!receiver.IsEmpty()) obj->set_receiver(*Utils::OpenHandle(*receiver)); |
613 if (argc > 0) { | 638 if (argc > 0) { |
614 i::Handle<i::FixedArray> args = i::Factory::NewFixedArray(argc); | 639 i::Handle<i::FixedArray> args = i::Factory::NewFixedArray(argc); |
615 for (int i = 0; i < argc; i++) { | 640 for (int i = 0; i < argc; i++) { |
616 if (!argv[i].IsEmpty()) | 641 if (!argv[i].IsEmpty()) |
617 args->set(i, *Utils::OpenHandle(*argv[i])); | 642 args->set(i, *Utils::OpenHandle(*argv[i])); |
618 } | 643 } |
619 obj->set_args(*args); | 644 obj->set_args(*args); |
620 } | 645 } |
621 return Utils::ToLocal(obj); | 646 return Utils::ToLocal(obj); |
622 } | 647 } |
623 | 648 |
624 | 649 |
625 Local<TypeSwitch> TypeSwitch::New(Handle<FunctionTemplate> type) { | 650 Local<TypeSwitch> TypeSwitch::New(Handle<FunctionTemplate> type) { |
626 Handle<FunctionTemplate> types[1] = { type }; | 651 Handle<FunctionTemplate> types[1] = { type }; |
627 return TypeSwitch::New(1, types); | 652 return TypeSwitch::New(1, types); |
628 } | 653 } |
629 | 654 |
630 | 655 |
631 Local<TypeSwitch> TypeSwitch::New(int argc, Handle<FunctionTemplate> types[]) { | 656 Local<TypeSwitch> TypeSwitch::New(int argc, Handle<FunctionTemplate> types[]) { |
| 657 ENTER_V8; |
632 EnsureInitialized("v8::TypeSwitch::New()"); | 658 EnsureInitialized("v8::TypeSwitch::New()"); |
633 LOG_API("TypeSwitch::New"); | 659 LOG_API("TypeSwitch::New"); |
634 i::Handle<i::FixedArray> vector = i::Factory::NewFixedArray(argc); | 660 i::Handle<i::FixedArray> vector = i::Factory::NewFixedArray(argc); |
635 for (int i = 0; i < argc; i++) | 661 for (int i = 0; i < argc; i++) |
636 vector->set(i, *Utils::OpenHandle(*types[i])); | 662 vector->set(i, *Utils::OpenHandle(*types[i])); |
637 i::Handle<i::Struct> struct_obj = | 663 i::Handle<i::Struct> struct_obj = |
638 i::Factory::NewStruct(i::TYPE_SWITCH_INFO_TYPE); | 664 i::Factory::NewStruct(i::TYPE_SWITCH_INFO_TYPE); |
639 i::Handle<i::TypeSwitchInfo> obj = | 665 i::Handle<i::TypeSwitchInfo> obj = |
640 i::Handle<i::TypeSwitchInfo>::cast(struct_obj); | 666 i::Handle<i::TypeSwitchInfo>::cast(struct_obj); |
641 obj->set_types(*vector); | 667 obj->set_types(*vector); |
642 return Utils::ToLocal(obj); | 668 return Utils::ToLocal(obj); |
643 } | 669 } |
644 | 670 |
645 | 671 |
646 int TypeSwitch::match(v8::Handle<Value> value) { | 672 int TypeSwitch::match(v8::Handle<Value> value) { |
647 LOG_API("TypeSwitch::match"); | 673 LOG_API("TypeSwitch::match"); |
648 i::Handle<i::Object> obj = Utils::OpenHandle(*value); | 674 i::Handle<i::Object> obj = Utils::OpenHandle(*value); |
649 i::Handle<i::TypeSwitchInfo> info = Utils::OpenHandle(this); | 675 i::Handle<i::TypeSwitchInfo> info = Utils::OpenHandle(this); |
650 i::FixedArray* types = i::FixedArray::cast(info->types()); | 676 i::FixedArray* types = i::FixedArray::cast(info->types()); |
651 for (int i = 0; i < types->length(); i++) { | 677 for (int i = 0; i < types->length(); i++) { |
652 if (obj->IsInstanceOf(i::FunctionTemplateInfo::cast(types->get(i)))) | 678 if (obj->IsInstanceOf(i::FunctionTemplateInfo::cast(types->get(i)))) |
653 return i + 1; | 679 return i + 1; |
654 } | 680 } |
655 return 0; | 681 return 0; |
656 } | 682 } |
657 | 683 |
658 | 684 |
659 void FunctionTemplate::SetCallHandler(InvocationCallback callback, | 685 void FunctionTemplate::SetCallHandler(InvocationCallback callback, |
660 v8::Handle<Value> data) { | 686 v8::Handle<Value> data) { |
| 687 ENTER_V8; |
661 if (IsDeadCheck("v8::FunctionTemplate::SetCallHandler()")) return; | 688 if (IsDeadCheck("v8::FunctionTemplate::SetCallHandler()")) return; |
662 HandleScope scope; | 689 HandleScope scope; |
663 i::Handle<i::Struct> struct_obj = | 690 i::Handle<i::Struct> struct_obj = |
664 i::Factory::NewStruct(i::CALL_HANDLER_INFO_TYPE); | 691 i::Factory::NewStruct(i::CALL_HANDLER_INFO_TYPE); |
665 i::Handle<i::CallHandlerInfo> obj = | 692 i::Handle<i::CallHandlerInfo> obj = |
666 i::Handle<i::CallHandlerInfo>::cast(struct_obj); | 693 i::Handle<i::CallHandlerInfo>::cast(struct_obj); |
667 obj->set_callback(*FromCData(callback)); | 694 obj->set_callback(*FromCData(callback)); |
668 if (data.IsEmpty()) data = v8::Undefined(); | 695 if (data.IsEmpty()) data = v8::Undefined(); |
669 obj->set_data(*Utils::OpenHandle(*data)); | 696 obj->set_data(*Utils::OpenHandle(*data)); |
670 Utils::OpenHandle(this)->set_call_code(*obj); | 697 Utils::OpenHandle(this)->set_call_code(*obj); |
671 } | 698 } |
672 | 699 |
673 | 700 |
674 void FunctionTemplate::AddInstancePropertyAccessor( | 701 void FunctionTemplate::AddInstancePropertyAccessor( |
675 v8::Handle<String> name, | 702 v8::Handle<String> name, |
676 AccessorGetter getter, | 703 AccessorGetter getter, |
677 AccessorSetter setter, | 704 AccessorSetter setter, |
678 v8::Handle<Value> data, | 705 v8::Handle<Value> data, |
679 v8::AccessControl settings, | 706 v8::AccessControl settings, |
680 v8::PropertyAttribute attributes) { | 707 v8::PropertyAttribute attributes) { |
| 708 ENTER_V8; |
681 if (IsDeadCheck("v8::FunctionTemplate::AddInstancePropertyAccessor()")) { | 709 if (IsDeadCheck("v8::FunctionTemplate::AddInstancePropertyAccessor()")) { |
682 return; | 710 return; |
683 } | 711 } |
684 HandleScope scope; | 712 HandleScope scope; |
685 i::Handle<i::AccessorInfo> obj = i::Factory::NewAccessorInfo(); | 713 i::Handle<i::AccessorInfo> obj = i::Factory::NewAccessorInfo(); |
686 ASSERT(getter != NULL); | 714 ASSERT(getter != NULL); |
687 obj->set_getter(*FromCData(getter)); | 715 obj->set_getter(*FromCData(getter)); |
688 obj->set_setter(*FromCData(setter)); | 716 obj->set_setter(*FromCData(setter)); |
689 if (data.IsEmpty()) data = v8::Undefined(); | 717 if (data.IsEmpty()) data = v8::Undefined(); |
690 obj->set_data(*Utils::OpenHandle(*data)); | 718 obj->set_data(*Utils::OpenHandle(*data)); |
691 obj->set_name(*Utils::OpenHandle(*name)); | 719 obj->set_name(*Utils::OpenHandle(*name)); |
692 if (settings & ALL_CAN_READ) obj->set_all_can_read(true); | 720 if (settings & ALL_CAN_READ) obj->set_all_can_read(true); |
693 if (settings & ALL_CAN_WRITE) obj->set_all_can_write(true); | 721 if (settings & ALL_CAN_WRITE) obj->set_all_can_write(true); |
694 if (settings & PROHIBITS_OVERWRITING) obj->set_prohibits_overwriting(true); | 722 if (settings & PROHIBITS_OVERWRITING) obj->set_prohibits_overwriting(true); |
695 obj->set_property_attributes(static_cast<PropertyAttributes>(attributes)); | 723 obj->set_property_attributes(static_cast<PropertyAttributes>(attributes)); |
696 | 724 |
697 i::Handle<i::Object> list(Utils::OpenHandle(this)->property_accessors()); | 725 i::Handle<i::Object> list(Utils::OpenHandle(this)->property_accessors()); |
698 if (list->IsUndefined()) { | 726 if (list->IsUndefined()) { |
699 list = NeanderArray().value(); | 727 list = NeanderArray().value(); |
700 Utils::OpenHandle(this)->set_property_accessors(*list); | 728 Utils::OpenHandle(this)->set_property_accessors(*list); |
701 } | 729 } |
702 NeanderArray array(list); | 730 NeanderArray array(list); |
703 array.add(obj); | 731 array.add(obj); |
704 } | 732 } |
705 | 733 |
706 | 734 |
707 Local<ObjectTemplate> FunctionTemplate::InstanceTemplate() { | 735 Local<ObjectTemplate> FunctionTemplate::InstanceTemplate() { |
| 736 ENTER_V8; |
708 if (IsDeadCheck("v8::FunctionTemplate::InstanceTemplate()") | 737 if (IsDeadCheck("v8::FunctionTemplate::InstanceTemplate()") |
709 || EmptyCheck("v8::FunctionTemplate::InstanceTemplate()", this)) | 738 || EmptyCheck("v8::FunctionTemplate::InstanceTemplate()", this)) |
710 return Local<ObjectTemplate>(); | 739 return Local<ObjectTemplate>(); |
711 if (Utils::OpenHandle(this)->instance_template()->IsUndefined()) { | 740 if (Utils::OpenHandle(this)->instance_template()->IsUndefined()) { |
712 Local<ObjectTemplate> templ = | 741 Local<ObjectTemplate> templ = |
713 ObjectTemplate::New(v8::Handle<FunctionTemplate>(this)); | 742 ObjectTemplate::New(v8::Handle<FunctionTemplate>(this)); |
714 Utils::OpenHandle(this)->set_instance_template(*Utils::OpenHandle(*templ)); | 743 Utils::OpenHandle(this)->set_instance_template(*Utils::OpenHandle(*templ)); |
715 } | 744 } |
716 i::Handle<i::ObjectTemplateInfo> result(i::ObjectTemplateInfo::cast( | 745 i::Handle<i::ObjectTemplateInfo> result(i::ObjectTemplateInfo::cast( |
717 Utils::OpenHandle(this)->instance_template())); | 746 Utils::OpenHandle(this)->instance_template())); |
718 return Utils::ToLocal(result); | 747 return Utils::ToLocal(result); |
719 } | 748 } |
720 | 749 |
721 | 750 |
722 void FunctionTemplate::SetClassName(Handle<String> name) { | 751 void FunctionTemplate::SetClassName(Handle<String> name) { |
| 752 ENTER_V8; |
723 if (IsDeadCheck("v8::FunctionTemplate::SetClassName()")) return; | 753 if (IsDeadCheck("v8::FunctionTemplate::SetClassName()")) return; |
724 Utils::OpenHandle(this)->set_class_name(*Utils::OpenHandle(*name)); | 754 Utils::OpenHandle(this)->set_class_name(*Utils::OpenHandle(*name)); |
725 } | 755 } |
726 | 756 |
727 | 757 |
728 void FunctionTemplate::SetHiddenPrototype(bool value) { | 758 void FunctionTemplate::SetHiddenPrototype(bool value) { |
| 759 ENTER_V8; |
729 if (IsDeadCheck("v8::FunctionTemplate::SetHiddenPrototype()")) return; | 760 if (IsDeadCheck("v8::FunctionTemplate::SetHiddenPrototype()")) return; |
730 Utils::OpenHandle(this)->set_hidden_prototype(value); | 761 Utils::OpenHandle(this)->set_hidden_prototype(value); |
731 } | 762 } |
732 | 763 |
733 | 764 |
734 void FunctionTemplate::SetNamedInstancePropertyHandler( | 765 void FunctionTemplate::SetNamedInstancePropertyHandler( |
735 NamedPropertyGetter getter, | 766 NamedPropertyGetter getter, |
736 NamedPropertySetter setter, | 767 NamedPropertySetter setter, |
737 NamedPropertyQuery query, | 768 NamedPropertyQuery query, |
738 NamedPropertyDeleter remover, | 769 NamedPropertyDeleter remover, |
739 NamedPropertyEnumerator enumerator, | 770 NamedPropertyEnumerator enumerator, |
740 Handle<Value> data) { | 771 Handle<Value> data) { |
| 772 ENTER_V8; |
741 if (IsDeadCheck("v8::FunctionTemplate::SetNamedInstancePropertyHandler()")) { | 773 if (IsDeadCheck("v8::FunctionTemplate::SetNamedInstancePropertyHandler()")) { |
742 return; | 774 return; |
743 } | 775 } |
744 HandleScope scope; | 776 HandleScope scope; |
745 i::Handle<i::Struct> struct_obj = | 777 i::Handle<i::Struct> struct_obj = |
746 i::Factory::NewStruct(i::INTERCEPTOR_INFO_TYPE); | 778 i::Factory::NewStruct(i::INTERCEPTOR_INFO_TYPE); |
747 i::Handle<i::InterceptorInfo> obj = | 779 i::Handle<i::InterceptorInfo> obj = |
748 i::Handle<i::InterceptorInfo>::cast(struct_obj); | 780 i::Handle<i::InterceptorInfo>::cast(struct_obj); |
749 if (getter != 0) obj->set_getter(*FromCData(getter)); | 781 if (getter != 0) obj->set_getter(*FromCData(getter)); |
750 if (setter != 0) obj->set_setter(*FromCData(setter)); | 782 if (setter != 0) obj->set_setter(*FromCData(setter)); |
751 if (query != 0) obj->set_query(*FromCData(query)); | 783 if (query != 0) obj->set_query(*FromCData(query)); |
752 if (remover != 0) obj->set_deleter(*FromCData(remover)); | 784 if (remover != 0) obj->set_deleter(*FromCData(remover)); |
753 if (enumerator != 0) obj->set_enumerator(*FromCData(enumerator)); | 785 if (enumerator != 0) obj->set_enumerator(*FromCData(enumerator)); |
754 if (data.IsEmpty()) data = v8::Undefined(); | 786 if (data.IsEmpty()) data = v8::Undefined(); |
755 obj->set_data(*Utils::OpenHandle(*data)); | 787 obj->set_data(*Utils::OpenHandle(*data)); |
756 Utils::OpenHandle(this)->set_named_property_handler(*obj); | 788 Utils::OpenHandle(this)->set_named_property_handler(*obj); |
757 } | 789 } |
758 | 790 |
759 | 791 |
760 void FunctionTemplate::SetIndexedInstancePropertyHandler( | 792 void FunctionTemplate::SetIndexedInstancePropertyHandler( |
761 IndexedPropertyGetter getter, | 793 IndexedPropertyGetter getter, |
762 IndexedPropertySetter setter, | 794 IndexedPropertySetter setter, |
763 IndexedPropertyQuery query, | 795 IndexedPropertyQuery query, |
764 IndexedPropertyDeleter remover, | 796 IndexedPropertyDeleter remover, |
765 IndexedPropertyEnumerator enumerator, | 797 IndexedPropertyEnumerator enumerator, |
766 Handle<Value> data) { | 798 Handle<Value> data) { |
| 799 ENTER_V8; |
767 if (IsDeadCheck( | 800 if (IsDeadCheck( |
768 "v8::FunctionTemplate::SetIndexedInstancePropertyHandler()")) { | 801 "v8::FunctionTemplate::SetIndexedInstancePropertyHandler()")) { |
769 return; | 802 return; |
770 } | 803 } |
771 HandleScope scope; | 804 HandleScope scope; |
772 i::Handle<i::Struct> struct_obj = | 805 i::Handle<i::Struct> struct_obj = |
773 i::Factory::NewStruct(i::INTERCEPTOR_INFO_TYPE); | 806 i::Factory::NewStruct(i::INTERCEPTOR_INFO_TYPE); |
774 i::Handle<i::InterceptorInfo> obj = | 807 i::Handle<i::InterceptorInfo> obj = |
775 i::Handle<i::InterceptorInfo>::cast(struct_obj); | 808 i::Handle<i::InterceptorInfo>::cast(struct_obj); |
776 if (getter != 0) obj->set_getter(*FromCData(getter)); | 809 if (getter != 0) obj->set_getter(*FromCData(getter)); |
777 if (setter != 0) obj->set_setter(*FromCData(setter)); | 810 if (setter != 0) obj->set_setter(*FromCData(setter)); |
778 if (query != 0) obj->set_query(*FromCData(query)); | 811 if (query != 0) obj->set_query(*FromCData(query)); |
779 if (remover != 0) obj->set_deleter(*FromCData(remover)); | 812 if (remover != 0) obj->set_deleter(*FromCData(remover)); |
780 if (enumerator != 0) obj->set_enumerator(*FromCData(enumerator)); | 813 if (enumerator != 0) obj->set_enumerator(*FromCData(enumerator)); |
781 if (data.IsEmpty()) data = v8::Undefined(); | 814 if (data.IsEmpty()) data = v8::Undefined(); |
782 obj->set_data(*Utils::OpenHandle(*data)); | 815 obj->set_data(*Utils::OpenHandle(*data)); |
783 Utils::OpenHandle(this)->set_indexed_property_handler(*obj); | 816 Utils::OpenHandle(this)->set_indexed_property_handler(*obj); |
784 } | 817 } |
785 | 818 |
786 | 819 |
787 void FunctionTemplate::SetInstanceCallAsFunctionHandler( | 820 void FunctionTemplate::SetInstanceCallAsFunctionHandler( |
788 InvocationCallback callback, | 821 InvocationCallback callback, |
789 Handle<Value> data) { | 822 Handle<Value> data) { |
| 823 ENTER_V8; |
790 if (IsDeadCheck("v8::FunctionTemplate::SetInstanceCallAsFunctionHandler()")) { | 824 if (IsDeadCheck("v8::FunctionTemplate::SetInstanceCallAsFunctionHandler()")) { |
791 return; | 825 return; |
792 } | 826 } |
793 HandleScope scope; | 827 HandleScope scope; |
794 i::Handle<i::Struct> struct_obj = | 828 i::Handle<i::Struct> struct_obj = |
795 i::Factory::NewStruct(i::CALL_HANDLER_INFO_TYPE); | 829 i::Factory::NewStruct(i::CALL_HANDLER_INFO_TYPE); |
796 i::Handle<i::CallHandlerInfo> obj = | 830 i::Handle<i::CallHandlerInfo> obj = |
797 i::Handle<i::CallHandlerInfo>::cast(struct_obj); | 831 i::Handle<i::CallHandlerInfo>::cast(struct_obj); |
798 obj->set_callback(*FromCData(callback)); | 832 obj->set_callback(*FromCData(callback)); |
799 if (data.IsEmpty()) data = v8::Undefined(); | 833 if (data.IsEmpty()) data = v8::Undefined(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 } | 873 } |
840 } | 874 } |
841 | 875 |
842 | 876 |
843 void ObjectTemplate::SetAccessor(v8::Handle<String> name, | 877 void ObjectTemplate::SetAccessor(v8::Handle<String> name, |
844 AccessorGetter getter, | 878 AccessorGetter getter, |
845 AccessorSetter setter, | 879 AccessorSetter setter, |
846 v8::Handle<Value> data, | 880 v8::Handle<Value> data, |
847 AccessControl settings, | 881 AccessControl settings, |
848 PropertyAttribute attribute) { | 882 PropertyAttribute attribute) { |
| 883 ENTER_V8; |
849 if (IsDeadCheck("v8::ObjectTemplate::SetAccessor()")) return; | 884 if (IsDeadCheck("v8::ObjectTemplate::SetAccessor()")) return; |
850 HandleScope scope; | 885 HandleScope scope; |
851 EnsureConstructor(this); | 886 EnsureConstructor(this); |
852 i::FunctionTemplateInfo* constructor = | 887 i::FunctionTemplateInfo* constructor = |
853 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); | 888 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); |
854 i::Handle<i::FunctionTemplateInfo> cons(constructor); | 889 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
855 Utils::ToLocal(cons)->AddInstancePropertyAccessor(name, | 890 Utils::ToLocal(cons)->AddInstancePropertyAccessor(name, |
856 getter, | 891 getter, |
857 setter, | 892 setter, |
858 data, | 893 data, |
859 settings, | 894 settings, |
860 attribute); | 895 attribute); |
861 } | 896 } |
862 | 897 |
863 | 898 |
864 void ObjectTemplate::SetNamedPropertyHandler(NamedPropertyGetter getter, | 899 void ObjectTemplate::SetNamedPropertyHandler(NamedPropertyGetter getter, |
865 NamedPropertySetter setter, | 900 NamedPropertySetter setter, |
866 NamedPropertyQuery query, | 901 NamedPropertyQuery query, |
867 NamedPropertyDeleter remover, | 902 NamedPropertyDeleter remover, |
868 NamedPropertyEnumerator enumerator, | 903 NamedPropertyEnumerator enumerator, |
869 Handle<Value> data) { | 904 Handle<Value> data) { |
| 905 ENTER_V8; |
870 if (IsDeadCheck("v8::ObjectTemplate::SetNamedPropertyHandler()")) return; | 906 if (IsDeadCheck("v8::ObjectTemplate::SetNamedPropertyHandler()")) return; |
871 HandleScope scope; | 907 HandleScope scope; |
872 EnsureConstructor(this); | 908 EnsureConstructor(this); |
873 i::FunctionTemplateInfo* constructor = | 909 i::FunctionTemplateInfo* constructor = |
874 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); | 910 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); |
875 i::Handle<i::FunctionTemplateInfo> cons(constructor); | 911 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
876 Utils::ToLocal(cons)->SetNamedInstancePropertyHandler(getter, | 912 Utils::ToLocal(cons)->SetNamedInstancePropertyHandler(getter, |
877 setter, | 913 setter, |
878 query, | 914 query, |
879 remover, | 915 remover, |
880 enumerator, | 916 enumerator, |
881 data); | 917 data); |
882 } | 918 } |
883 | 919 |
884 | 920 |
885 void ObjectTemplate::MarkAsUndetectable() { | 921 void ObjectTemplate::MarkAsUndetectable() { |
| 922 ENTER_V8; |
886 if (IsDeadCheck("v8::ObjectTemplate::MarkAsUndetectable()")) return; | 923 if (IsDeadCheck("v8::ObjectTemplate::MarkAsUndetectable()")) return; |
887 HandleScope scope; | 924 HandleScope scope; |
888 EnsureConstructor(this); | 925 EnsureConstructor(this); |
889 i::FunctionTemplateInfo* constructor = | 926 i::FunctionTemplateInfo* constructor = |
890 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); | 927 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); |
891 i::Handle<i::FunctionTemplateInfo> cons(constructor); | 928 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
892 cons->set_undetectable(true); | 929 cons->set_undetectable(true); |
893 } | 930 } |
894 | 931 |
895 | 932 |
896 void ObjectTemplate::SetAccessCheckCallbacks( | 933 void ObjectTemplate::SetAccessCheckCallbacks( |
897 NamedSecurityCallback named_callback, | 934 NamedSecurityCallback named_callback, |
898 IndexedSecurityCallback indexed_callback, | 935 IndexedSecurityCallback indexed_callback, |
899 Handle<Value> data, | 936 Handle<Value> data, |
900 bool turned_on_by_default) { | 937 bool turned_on_by_default) { |
| 938 ENTER_V8; |
901 if (IsDeadCheck("v8::ObjectTemplate::SetAccessCheckCallbacks()")) return; | 939 if (IsDeadCheck("v8::ObjectTemplate::SetAccessCheckCallbacks()")) return; |
902 HandleScope scope; | 940 HandleScope scope; |
903 EnsureConstructor(this); | 941 EnsureConstructor(this); |
904 | 942 |
905 i::Handle<i::Struct> struct_info = | 943 i::Handle<i::Struct> struct_info = |
906 i::Factory::NewStruct(i::ACCESS_CHECK_INFO_TYPE); | 944 i::Factory::NewStruct(i::ACCESS_CHECK_INFO_TYPE); |
907 i::Handle<i::AccessCheckInfo> info = | 945 i::Handle<i::AccessCheckInfo> info = |
908 i::Handle<i::AccessCheckInfo>::cast(struct_info); | 946 i::Handle<i::AccessCheckInfo>::cast(struct_info); |
909 info->set_named_callback(*FromCData(named_callback)); | 947 info->set_named_callback(*FromCData(named_callback)); |
910 info->set_indexed_callback(*FromCData(indexed_callback)); | 948 info->set_indexed_callback(*FromCData(indexed_callback)); |
911 if (data.IsEmpty()) data = v8::Undefined(); | 949 if (data.IsEmpty()) data = v8::Undefined(); |
912 info->set_data(*Utils::OpenHandle(*data)); | 950 info->set_data(*Utils::OpenHandle(*data)); |
913 | 951 |
914 i::FunctionTemplateInfo* constructor = | 952 i::FunctionTemplateInfo* constructor = |
915 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); | 953 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); |
916 i::Handle<i::FunctionTemplateInfo> cons(constructor); | 954 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
917 cons->set_access_check_info(*info); | 955 cons->set_access_check_info(*info); |
918 cons->set_needs_access_check(turned_on_by_default); | 956 cons->set_needs_access_check(turned_on_by_default); |
919 } | 957 } |
920 | 958 |
921 | 959 |
922 void ObjectTemplate::SetIndexedPropertyHandler( | 960 void ObjectTemplate::SetIndexedPropertyHandler( |
923 IndexedPropertyGetter getter, | 961 IndexedPropertyGetter getter, |
924 IndexedPropertySetter setter, | 962 IndexedPropertySetter setter, |
925 IndexedPropertyQuery query, | 963 IndexedPropertyQuery query, |
926 IndexedPropertyDeleter remover, | 964 IndexedPropertyDeleter remover, |
927 IndexedPropertyEnumerator enumerator, | 965 IndexedPropertyEnumerator enumerator, |
928 Handle<Value> data) { | 966 Handle<Value> data) { |
| 967 ENTER_V8; |
929 if (IsDeadCheck("v8::ObjectTemplate::SetIndexedPropertyHandler()")) return; | 968 if (IsDeadCheck("v8::ObjectTemplate::SetIndexedPropertyHandler()")) return; |
930 HandleScope scope; | 969 HandleScope scope; |
931 EnsureConstructor(this); | 970 EnsureConstructor(this); |
932 i::FunctionTemplateInfo* constructor = | 971 i::FunctionTemplateInfo* constructor = |
933 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); | 972 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); |
934 i::Handle<i::FunctionTemplateInfo> cons(constructor); | 973 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
935 Utils::ToLocal(cons)->SetIndexedInstancePropertyHandler(getter, | 974 Utils::ToLocal(cons)->SetIndexedInstancePropertyHandler(getter, |
936 setter, | 975 setter, |
937 query, | 976 query, |
938 remover, | 977 remover, |
939 enumerator, | 978 enumerator, |
940 data); | 979 data); |
941 } | 980 } |
942 | 981 |
943 | 982 |
944 void ObjectTemplate::SetCallAsFunctionHandler(InvocationCallback callback, | 983 void ObjectTemplate::SetCallAsFunctionHandler(InvocationCallback callback, |
945 Handle<Value> data) { | 984 Handle<Value> data) { |
| 985 ENTER_V8; |
946 if (IsDeadCheck("v8::ObjectTemplate::SetCallAsFunctionHandler()")) return; | 986 if (IsDeadCheck("v8::ObjectTemplate::SetCallAsFunctionHandler()")) return; |
947 HandleScope scope; | 987 HandleScope scope; |
948 EnsureConstructor(this); | 988 EnsureConstructor(this); |
949 i::FunctionTemplateInfo* constructor = | 989 i::FunctionTemplateInfo* constructor = |
950 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); | 990 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); |
951 i::Handle<i::FunctionTemplateInfo> cons(constructor); | 991 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
952 Utils::ToLocal(cons)->SetInstanceCallAsFunctionHandler(callback, data); | 992 Utils::ToLocal(cons)->SetInstanceCallAsFunctionHandler(callback, data); |
953 } | 993 } |
954 | 994 |
955 | 995 |
956 int ObjectTemplate::InternalFieldCount() { | 996 int ObjectTemplate::InternalFieldCount() { |
| 997 ENTER_V8; |
957 if (IsDeadCheck("v8::ObjectTemplate::InternalFieldCount()")) { | 998 if (IsDeadCheck("v8::ObjectTemplate::InternalFieldCount()")) { |
958 return 0; | 999 return 0; |
959 } | 1000 } |
960 return i::Smi::cast(Utils::OpenHandle(this)->internal_field_count())->value(); | 1001 return i::Smi::cast(Utils::OpenHandle(this)->internal_field_count())->value(); |
961 } | 1002 } |
962 | 1003 |
963 | 1004 |
964 void ObjectTemplate::SetInternalFieldCount(int value) { | 1005 void ObjectTemplate::SetInternalFieldCount(int value) { |
| 1006 ENTER_V8; |
965 if (IsDeadCheck("v8::ObjectTemplate::SetInternalFieldCount()")) return; | 1007 if (IsDeadCheck("v8::ObjectTemplate::SetInternalFieldCount()")) return; |
966 if (!ApiCheck(i::Smi::IsValid(value), | 1008 if (!ApiCheck(i::Smi::IsValid(value), |
967 "v8::ObjectTemplate::SetInternalFieldCount()", | 1009 "v8::ObjectTemplate::SetInternalFieldCount()", |
968 "Invalid internal field count")) { | 1010 "Invalid internal field count")) { |
969 return; | 1011 return; |
970 } | 1012 } |
971 if (value > 0) { | 1013 if (value > 0) { |
972 // The internal field count is set by the constructor function's | 1014 // The internal field count is set by the constructor function's |
973 // construct code, so we ensure that there is a constructor | 1015 // construct code, so we ensure that there is a constructor |
974 // function to do the setting. | 1016 // function to do the setting. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 | 1082 |
1041 | 1083 |
1042 Local<Script> Script::Compile(v8::Handle<String> source, | 1084 Local<Script> Script::Compile(v8::Handle<String> source, |
1043 v8::Handle<Value> file_name) { | 1085 v8::Handle<Value> file_name) { |
1044 ScriptOrigin origin(file_name); | 1086 ScriptOrigin origin(file_name); |
1045 return Compile(source, &origin); | 1087 return Compile(source, &origin); |
1046 } | 1088 } |
1047 | 1089 |
1048 | 1090 |
1049 Local<Value> Script::Run() { | 1091 Local<Value> Script::Run() { |
| 1092 ENTER_V8; |
1050 ON_BAILOUT("v8::Script::Run()", return Local<Value>()); | 1093 ON_BAILOUT("v8::Script::Run()", return Local<Value>()); |
1051 LOG_API("Script::Run"); | 1094 LOG_API("Script::Run"); |
1052 i::Object* raw_result = NULL; | 1095 i::Object* raw_result = NULL; |
1053 { | 1096 { |
1054 HandleScope scope; | 1097 HandleScope scope; |
1055 i::Handle<i::JSFunction> fun = Utils::OpenHandle(this); | 1098 i::Handle<i::JSFunction> fun = Utils::OpenHandle(this); |
1056 EXCEPTION_PREAMBLE(); | 1099 EXCEPTION_PREAMBLE(); |
1057 i::Handle<i::Object> receiver(i::Top::context()->global_proxy()); | 1100 i::Handle<i::Object> receiver(i::Top::context()->global_proxy()); |
1058 i::Handle<i::Object> result = | 1101 i::Handle<i::Object> result = |
1059 i::Execution::Call(fun, receiver, 0, NULL, &has_pending_exception); | 1102 i::Execution::Call(fun, receiver, 0, NULL, &has_pending_exception); |
1060 EXCEPTION_BAILOUT_CHECK(Local<Value>()); | 1103 EXCEPTION_BAILOUT_CHECK(Local<Value>()); |
1061 raw_result = *result; | 1104 raw_result = *result; |
1062 } | 1105 } |
1063 i::Handle<i::Object> result(raw_result); | 1106 i::Handle<i::Object> result(raw_result); |
1064 return Utils::ToLocal(result); | 1107 return Utils::ToLocal(result); |
1065 } | 1108 } |
1066 | 1109 |
1067 | 1110 |
1068 Local<Value> Script::Id() { | 1111 Local<Value> Script::Id() { |
| 1112 ENTER_V8; |
1069 ON_BAILOUT("v8::Script::Id()", return Local<Value>()); | 1113 ON_BAILOUT("v8::Script::Id()", return Local<Value>()); |
1070 LOG_API("Script::Id"); | 1114 LOG_API("Script::Id"); |
1071 i::Object* raw_id = NULL; | 1115 i::Object* raw_id = NULL; |
1072 { | 1116 { |
1073 HandleScope scope; | 1117 HandleScope scope; |
1074 i::Handle<i::JSFunction> fun = Utils::OpenHandle(this); | 1118 i::Handle<i::JSFunction> fun = Utils::OpenHandle(this); |
1075 i::Handle<i::Script> script(i::Script::cast(fun->shared()->script())); | 1119 i::Handle<i::Script> script(i::Script::cast(fun->shared()->script())); |
1076 i::Handle<i::Object> id(script->id()); | 1120 i::Handle<i::Object> id(script->id()); |
1077 raw_id = *id; | 1121 raw_id = *id; |
1078 } | 1122 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1139 | 1183 |
1140 void v8::TryCatch::SetCaptureMessage(bool value) { | 1184 void v8::TryCatch::SetCaptureMessage(bool value) { |
1141 capture_message_ = value; | 1185 capture_message_ = value; |
1142 } | 1186 } |
1143 | 1187 |
1144 | 1188 |
1145 // --- M e s s a g e --- | 1189 // --- M e s s a g e --- |
1146 | 1190 |
1147 | 1191 |
1148 Local<String> Message::Get() const { | 1192 Local<String> Message::Get() const { |
| 1193 ENTER_V8; |
1149 ON_BAILOUT("v8::Message::Get()", return Local<String>()); | 1194 ON_BAILOUT("v8::Message::Get()", return Local<String>()); |
1150 HandleScope scope; | 1195 HandleScope scope; |
1151 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 1196 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
1152 i::Handle<i::String> raw_result = i::MessageHandler::GetMessage(obj); | 1197 i::Handle<i::String> raw_result = i::MessageHandler::GetMessage(obj); |
1153 Local<String> result = Utils::ToLocal(raw_result); | 1198 Local<String> result = Utils::ToLocal(raw_result); |
1154 return scope.Close(result); | 1199 return scope.Close(result); |
1155 } | 1200 } |
1156 | 1201 |
1157 | 1202 |
1158 v8::Handle<Value> Message::GetScriptResourceName() const { | 1203 v8::Handle<Value> Message::GetScriptResourceName() const { |
| 1204 ENTER_V8; |
1159 if (IsDeadCheck("v8::Message::GetScriptResourceName()")) { | 1205 if (IsDeadCheck("v8::Message::GetScriptResourceName()")) { |
1160 return Local<String>(); | 1206 return Local<String>(); |
1161 } | 1207 } |
1162 HandleScope scope; | 1208 HandleScope scope; |
1163 i::Handle<i::JSObject> obj = | 1209 i::Handle<i::JSObject> obj = |
1164 i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); | 1210 i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); |
1165 // Return this.script.name. | 1211 // Return this.script.name. |
1166 i::Handle<i::JSValue> script = | 1212 i::Handle<i::JSValue> script = |
1167 i::Handle<i::JSValue>::cast(GetProperty(obj, "script")); | 1213 i::Handle<i::JSValue>::cast(GetProperty(obj, "script")); |
1168 i::Handle<i::Object> resource_name(i::Script::cast(script->value())->name()); | 1214 i::Handle<i::Object> resource_name(i::Script::cast(script->value())->name()); |
(...skipping 22 matching lines...) Expand all Loading... |
1191 i::Object** argv[1] = { data.location() }; | 1237 i::Object** argv[1] = { data.location() }; |
1192 return CallV8HeapFunction(name, | 1238 return CallV8HeapFunction(name, |
1193 i::Top::builtins(), | 1239 i::Top::builtins(), |
1194 1, | 1240 1, |
1195 argv, | 1241 argv, |
1196 has_pending_exception); | 1242 has_pending_exception); |
1197 } | 1243 } |
1198 | 1244 |
1199 | 1245 |
1200 int Message::GetLineNumber() const { | 1246 int Message::GetLineNumber() const { |
| 1247 ENTER_V8; |
1201 ON_BAILOUT("v8::Message::GetLineNumber()", return -1); | 1248 ON_BAILOUT("v8::Message::GetLineNumber()", return -1); |
1202 HandleScope scope; | 1249 HandleScope scope; |
1203 EXCEPTION_PREAMBLE(); | 1250 EXCEPTION_PREAMBLE(); |
1204 i::Handle<i::Object> result = CallV8HeapFunction("GetLineNumber", | 1251 i::Handle<i::Object> result = CallV8HeapFunction("GetLineNumber", |
1205 Utils::OpenHandle(this), | 1252 Utils::OpenHandle(this), |
1206 &has_pending_exception); | 1253 &has_pending_exception); |
1207 EXCEPTION_BAILOUT_CHECK(0); | 1254 EXCEPTION_BAILOUT_CHECK(0); |
1208 return static_cast<int>(result->Number()); | 1255 return static_cast<int>(result->Number()); |
1209 } | 1256 } |
1210 | 1257 |
1211 | 1258 |
1212 int Message::GetStartPosition() const { | 1259 int Message::GetStartPosition() const { |
| 1260 ENTER_V8; |
1213 if (IsDeadCheck("v8::Message::GetStartPosition()")) return 0; | 1261 if (IsDeadCheck("v8::Message::GetStartPosition()")) return 0; |
1214 HandleScope scope; | 1262 HandleScope scope; |
1215 | 1263 |
1216 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); | 1264 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); |
1217 return static_cast<int>(GetProperty(data_obj, "startPos")->Number()); | 1265 return static_cast<int>(GetProperty(data_obj, "startPos")->Number()); |
1218 } | 1266 } |
1219 | 1267 |
1220 | 1268 |
1221 int Message::GetEndPosition() const { | 1269 int Message::GetEndPosition() const { |
| 1270 ENTER_V8; |
1222 if (IsDeadCheck("v8::Message::GetEndPosition()")) return 0; | 1271 if (IsDeadCheck("v8::Message::GetEndPosition()")) return 0; |
1223 HandleScope scope; | 1272 HandleScope scope; |
1224 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); | 1273 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); |
1225 return static_cast<int>(GetProperty(data_obj, "endPos")->Number()); | 1274 return static_cast<int>(GetProperty(data_obj, "endPos")->Number()); |
1226 } | 1275 } |
1227 | 1276 |
1228 | 1277 |
1229 int Message::GetStartColumn() const { | 1278 int Message::GetStartColumn() const { |
| 1279 ENTER_V8; |
1230 if (IsDeadCheck("v8::Message::GetStartColumn()")) return 0; | 1280 if (IsDeadCheck("v8::Message::GetStartColumn()")) return 0; |
1231 HandleScope scope; | 1281 HandleScope scope; |
1232 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); | 1282 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); |
1233 EXCEPTION_PREAMBLE(); | 1283 EXCEPTION_PREAMBLE(); |
1234 i::Handle<i::Object> start_col_obj = CallV8HeapFunction( | 1284 i::Handle<i::Object> start_col_obj = CallV8HeapFunction( |
1235 "GetPositionInLine", | 1285 "GetPositionInLine", |
1236 data_obj, | 1286 data_obj, |
1237 &has_pending_exception); | 1287 &has_pending_exception); |
1238 EXCEPTION_BAILOUT_CHECK(0); | 1288 EXCEPTION_BAILOUT_CHECK(0); |
1239 return static_cast<int>(start_col_obj->Number()); | 1289 return static_cast<int>(start_col_obj->Number()); |
1240 } | 1290 } |
1241 | 1291 |
1242 | 1292 |
1243 int Message::GetEndColumn() const { | 1293 int Message::GetEndColumn() const { |
| 1294 ENTER_V8; |
1244 if (IsDeadCheck("v8::Message::GetEndColumn()")) return 0; | 1295 if (IsDeadCheck("v8::Message::GetEndColumn()")) return 0; |
1245 HandleScope scope; | 1296 HandleScope scope; |
1246 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); | 1297 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); |
1247 EXCEPTION_PREAMBLE(); | 1298 EXCEPTION_PREAMBLE(); |
1248 i::Handle<i::Object> start_col_obj = CallV8HeapFunction( | 1299 i::Handle<i::Object> start_col_obj = CallV8HeapFunction( |
1249 "GetPositionInLine", | 1300 "GetPositionInLine", |
1250 data_obj, | 1301 data_obj, |
1251 &has_pending_exception); | 1302 &has_pending_exception); |
1252 EXCEPTION_BAILOUT_CHECK(0); | 1303 EXCEPTION_BAILOUT_CHECK(0); |
1253 int start = static_cast<int>(GetProperty(data_obj, "startPos")->Number()); | 1304 int start = static_cast<int>(GetProperty(data_obj, "startPos")->Number()); |
1254 int end = static_cast<int>(GetProperty(data_obj, "endPos")->Number()); | 1305 int end = static_cast<int>(GetProperty(data_obj, "endPos")->Number()); |
1255 return static_cast<int>(start_col_obj->Number()) + (end - start); | 1306 return static_cast<int>(start_col_obj->Number()) + (end - start); |
1256 } | 1307 } |
1257 | 1308 |
1258 | 1309 |
1259 Local<String> Message::GetSourceLine() const { | 1310 Local<String> Message::GetSourceLine() const { |
| 1311 ENTER_V8; |
1260 ON_BAILOUT("v8::Message::GetSourceLine()", return Local<String>()); | 1312 ON_BAILOUT("v8::Message::GetSourceLine()", return Local<String>()); |
1261 HandleScope scope; | 1313 HandleScope scope; |
1262 EXCEPTION_PREAMBLE(); | 1314 EXCEPTION_PREAMBLE(); |
1263 i::Handle<i::Object> result = CallV8HeapFunction("GetSourceLine", | 1315 i::Handle<i::Object> result = CallV8HeapFunction("GetSourceLine", |
1264 Utils::OpenHandle(this), | 1316 Utils::OpenHandle(this), |
1265 &has_pending_exception); | 1317 &has_pending_exception); |
1266 EXCEPTION_BAILOUT_CHECK(Local<v8::String>()); | 1318 EXCEPTION_BAILOUT_CHECK(Local<v8::String>()); |
1267 if (result->IsString()) { | 1319 if (result->IsString()) { |
1268 return scope.Close(Utils::ToLocal(i::Handle<i::String>::cast(result))); | 1320 return scope.Close(Utils::ToLocal(i::Handle<i::String>::cast(result))); |
1269 } else { | 1321 } else { |
1270 return Local<String>(); | 1322 return Local<String>(); |
1271 } | 1323 } |
1272 } | 1324 } |
1273 | 1325 |
1274 | 1326 |
1275 void Message::PrintCurrentStackTrace(FILE* out) { | 1327 void Message::PrintCurrentStackTrace(FILE* out) { |
| 1328 ENTER_V8; |
1276 if (IsDeadCheck("v8::Message::PrintCurrentStackTrace()")) return; | 1329 if (IsDeadCheck("v8::Message::PrintCurrentStackTrace()")) return; |
1277 i::Top::PrintCurrentStackTrace(out); | 1330 i::Top::PrintCurrentStackTrace(out); |
1278 } | 1331 } |
1279 | 1332 |
1280 | 1333 |
1281 // --- D a t a --- | 1334 // --- D a t a --- |
1282 | 1335 |
1283 bool Value::IsUndefined() const { | 1336 bool Value::IsUndefined() const { |
| 1337 ENTER_V8; |
1284 if (IsDeadCheck("v8::Value::IsUndefined()")) return false; | 1338 if (IsDeadCheck("v8::Value::IsUndefined()")) return false; |
1285 return Utils::OpenHandle(this)->IsUndefined(); | 1339 return Utils::OpenHandle(this)->IsUndefined(); |
1286 } | 1340 } |
1287 | 1341 |
1288 | 1342 |
1289 bool Value::IsNull() const { | 1343 bool Value::IsNull() const { |
| 1344 ENTER_V8; |
1290 if (IsDeadCheck("v8::Value::IsNull()")) return false; | 1345 if (IsDeadCheck("v8::Value::IsNull()")) return false; |
1291 return Utils::OpenHandle(this)->IsNull(); | 1346 return Utils::OpenHandle(this)->IsNull(); |
1292 } | 1347 } |
1293 | 1348 |
1294 | 1349 |
1295 bool Value::IsTrue() const { | 1350 bool Value::IsTrue() const { |
| 1351 ENTER_V8; |
1296 if (IsDeadCheck("v8::Value::IsTrue()")) return false; | 1352 if (IsDeadCheck("v8::Value::IsTrue()")) return false; |
1297 return Utils::OpenHandle(this)->IsTrue(); | 1353 return Utils::OpenHandle(this)->IsTrue(); |
1298 } | 1354 } |
1299 | 1355 |
1300 | 1356 |
1301 bool Value::IsFalse() const { | 1357 bool Value::IsFalse() const { |
| 1358 ENTER_V8; |
1302 if (IsDeadCheck("v8::Value::IsFalse()")) return false; | 1359 if (IsDeadCheck("v8::Value::IsFalse()")) return false; |
1303 return Utils::OpenHandle(this)->IsFalse(); | 1360 return Utils::OpenHandle(this)->IsFalse(); |
1304 } | 1361 } |
1305 | 1362 |
1306 | 1363 |
1307 bool Value::IsFunction() const { | 1364 bool Value::IsFunction() const { |
| 1365 ENTER_V8; |
1308 if (IsDeadCheck("v8::Value::IsFunction()")) return false; | 1366 if (IsDeadCheck("v8::Value::IsFunction()")) return false; |
1309 return Utils::OpenHandle(this)->IsJSFunction(); | 1367 return Utils::OpenHandle(this)->IsJSFunction(); |
1310 } | 1368 } |
1311 | 1369 |
1312 | 1370 |
1313 bool Value::IsString() const { | 1371 bool Value::IsString() const { |
| 1372 ENTER_V8; |
1314 if (IsDeadCheck("v8::Value::IsString()")) return false; | 1373 if (IsDeadCheck("v8::Value::IsString()")) return false; |
1315 return Utils::OpenHandle(this)->IsString(); | 1374 return Utils::OpenHandle(this)->IsString(); |
1316 } | 1375 } |
1317 | 1376 |
1318 | 1377 |
1319 bool Value::IsArray() const { | 1378 bool Value::IsArray() const { |
| 1379 ENTER_V8; |
1320 if (IsDeadCheck("v8::Value::IsArray()")) return false; | 1380 if (IsDeadCheck("v8::Value::IsArray()")) return false; |
1321 return Utils::OpenHandle(this)->IsJSArray(); | 1381 return Utils::OpenHandle(this)->IsJSArray(); |
1322 } | 1382 } |
1323 | 1383 |
1324 | 1384 |
1325 bool Value::IsObject() const { | 1385 bool Value::IsObject() const { |
| 1386 ENTER_V8; |
1326 if (IsDeadCheck("v8::Value::IsObject()")) return false; | 1387 if (IsDeadCheck("v8::Value::IsObject()")) return false; |
1327 return Utils::OpenHandle(this)->IsJSObject(); | 1388 return Utils::OpenHandle(this)->IsJSObject(); |
1328 } | 1389 } |
1329 | 1390 |
1330 | 1391 |
1331 bool Value::IsNumber() const { | 1392 bool Value::IsNumber() const { |
| 1393 ENTER_V8; |
1332 if (IsDeadCheck("v8::Value::IsNumber()")) return false; | 1394 if (IsDeadCheck("v8::Value::IsNumber()")) return false; |
1333 return Utils::OpenHandle(this)->IsNumber(); | 1395 return Utils::OpenHandle(this)->IsNumber(); |
1334 } | 1396 } |
1335 | 1397 |
1336 | 1398 |
1337 bool Value::IsBoolean() const { | 1399 bool Value::IsBoolean() const { |
| 1400 ENTER_V8; |
1338 if (IsDeadCheck("v8::Value::IsBoolean()")) return false; | 1401 if (IsDeadCheck("v8::Value::IsBoolean()")) return false; |
1339 return Utils::OpenHandle(this)->IsBoolean(); | 1402 return Utils::OpenHandle(this)->IsBoolean(); |
1340 } | 1403 } |
1341 | 1404 |
1342 | 1405 |
1343 bool Value::IsExternal() const { | 1406 bool Value::IsExternal() const { |
| 1407 ENTER_V8; |
1344 if (IsDeadCheck("v8::Value::IsExternal()")) return false; | 1408 if (IsDeadCheck("v8::Value::IsExternal()")) return false; |
1345 return Utils::OpenHandle(this)->IsProxy(); | 1409 return Utils::OpenHandle(this)->IsProxy(); |
1346 } | 1410 } |
1347 | 1411 |
1348 | 1412 |
1349 bool Value::IsInt32() const { | 1413 bool Value::IsInt32() const { |
| 1414 ENTER_V8; |
1350 if (IsDeadCheck("v8::Value::IsInt32()")) return false; | 1415 if (IsDeadCheck("v8::Value::IsInt32()")) return false; |
1351 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 1416 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
1352 if (obj->IsSmi()) return true; | 1417 if (obj->IsSmi()) return true; |
1353 if (obj->IsNumber()) { | 1418 if (obj->IsNumber()) { |
1354 double value = obj->Number(); | 1419 double value = obj->Number(); |
1355 return i::FastI2D(i::FastD2I(value)) == value; | 1420 return i::FastI2D(i::FastD2I(value)) == value; |
1356 } | 1421 } |
1357 return false; | 1422 return false; |
1358 } | 1423 } |
1359 | 1424 |
1360 | 1425 |
1361 bool Value::IsDate() const { | 1426 bool Value::IsDate() const { |
| 1427 ENTER_V8; |
1362 if (IsDeadCheck("v8::Value::IsDate()")) return false; | 1428 if (IsDeadCheck("v8::Value::IsDate()")) return false; |
1363 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 1429 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
1364 return obj->HasSpecificClassOf(i::Heap::Date_symbol()); | 1430 return obj->HasSpecificClassOf(i::Heap::Date_symbol()); |
1365 } | 1431 } |
1366 | 1432 |
1367 | 1433 |
1368 Local<String> Value::ToString() const { | 1434 Local<String> Value::ToString() const { |
| 1435 ENTER_V8; |
1369 if (IsDeadCheck("v8::Value::ToString()")) return Local<String>(); | 1436 if (IsDeadCheck("v8::Value::ToString()")) return Local<String>(); |
1370 LOG_API("ToString"); | 1437 LOG_API("ToString"); |
1371 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 1438 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
1372 i::Handle<i::Object> str; | 1439 i::Handle<i::Object> str; |
1373 if (obj->IsString()) { | 1440 if (obj->IsString()) { |
1374 str = obj; | 1441 str = obj; |
1375 } else { | 1442 } else { |
1376 EXCEPTION_PREAMBLE(); | 1443 EXCEPTION_PREAMBLE(); |
1377 str = i::Execution::ToString(obj, &has_pending_exception); | 1444 str = i::Execution::ToString(obj, &has_pending_exception); |
1378 EXCEPTION_BAILOUT_CHECK(Local<String>()); | 1445 EXCEPTION_BAILOUT_CHECK(Local<String>()); |
1379 } | 1446 } |
1380 return Local<String>(ToApi<String>(str)); | 1447 return Local<String>(ToApi<String>(str)); |
1381 } | 1448 } |
1382 | 1449 |
1383 | 1450 |
1384 Local<String> Value::ToDetailString() const { | 1451 Local<String> Value::ToDetailString() const { |
| 1452 ENTER_V8; |
1385 if (IsDeadCheck("v8::Value::ToDetailString()")) return Local<String>(); | 1453 if (IsDeadCheck("v8::Value::ToDetailString()")) return Local<String>(); |
1386 LOG_API("ToDetailString"); | 1454 LOG_API("ToDetailString"); |
1387 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 1455 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
1388 i::Handle<i::Object> str; | 1456 i::Handle<i::Object> str; |
1389 if (obj->IsString()) { | 1457 if (obj->IsString()) { |
1390 str = obj; | 1458 str = obj; |
1391 } else { | 1459 } else { |
1392 EXCEPTION_PREAMBLE(); | 1460 EXCEPTION_PREAMBLE(); |
1393 str = i::Execution::ToDetailString(obj, &has_pending_exception); | 1461 str = i::Execution::ToDetailString(obj, &has_pending_exception); |
1394 EXCEPTION_BAILOUT_CHECK(Local<String>()); | 1462 EXCEPTION_BAILOUT_CHECK(Local<String>()); |
1395 } | 1463 } |
1396 return Local<String>(ToApi<String>(str)); | 1464 return Local<String>(ToApi<String>(str)); |
1397 } | 1465 } |
1398 | 1466 |
1399 | 1467 |
1400 Local<v8::Object> Value::ToObject() const { | 1468 Local<v8::Object> Value::ToObject() const { |
| 1469 ENTER_V8; |
1401 if (IsDeadCheck("v8::Value::ToObject()")) return Local<v8::Object>(); | 1470 if (IsDeadCheck("v8::Value::ToObject()")) return Local<v8::Object>(); |
1402 LOG_API("ToObject"); | 1471 LOG_API("ToObject"); |
1403 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 1472 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
1404 i::Handle<i::Object> val; | 1473 i::Handle<i::Object> val; |
1405 if (obj->IsJSObject()) { | 1474 if (obj->IsJSObject()) { |
1406 val = obj; | 1475 val = obj; |
1407 } else { | 1476 } else { |
1408 EXCEPTION_PREAMBLE(); | 1477 EXCEPTION_PREAMBLE(); |
1409 val = i::Execution::ToObject(obj, &has_pending_exception); | 1478 val = i::Execution::ToObject(obj, &has_pending_exception); |
1410 EXCEPTION_BAILOUT_CHECK(Local<v8::Object>()); | 1479 EXCEPTION_BAILOUT_CHECK(Local<v8::Object>()); |
1411 } | 1480 } |
1412 return Local<v8::Object>(ToApi<Object>(val)); | 1481 return Local<v8::Object>(ToApi<Object>(val)); |
1413 } | 1482 } |
1414 | 1483 |
1415 | 1484 |
1416 Local<Boolean> Value::ToBoolean() const { | 1485 Local<Boolean> Value::ToBoolean() const { |
| 1486 ENTER_V8; |
1417 if (IsDeadCheck("v8::Value::ToBoolean()")) return Local<Boolean>(); | 1487 if (IsDeadCheck("v8::Value::ToBoolean()")) return Local<Boolean>(); |
1418 LOG_API("ToBoolean"); | 1488 LOG_API("ToBoolean"); |
1419 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 1489 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
1420 i::Handle<i::Object> val = | 1490 i::Handle<i::Object> val = |
1421 obj->IsBoolean() ? obj : i::Execution::ToBoolean(obj); | 1491 obj->IsBoolean() ? obj : i::Execution::ToBoolean(obj); |
1422 return Local<Boolean>(ToApi<Boolean>(val)); | 1492 return Local<Boolean>(ToApi<Boolean>(val)); |
1423 } | 1493 } |
1424 | 1494 |
1425 | 1495 |
1426 Local<Number> Value::ToNumber() const { | 1496 Local<Number> Value::ToNumber() const { |
| 1497 ENTER_V8; |
1427 if (IsDeadCheck("v8::Value::ToNumber()")) return Local<Number>(); | 1498 if (IsDeadCheck("v8::Value::ToNumber()")) return Local<Number>(); |
1428 LOG_API("ToNumber"); | 1499 LOG_API("ToNumber"); |
1429 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 1500 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
1430 i::Handle<i::Object> num; | 1501 i::Handle<i::Object> num; |
1431 if (obj->IsNumber()) { | 1502 if (obj->IsNumber()) { |
1432 num = obj; | 1503 num = obj; |
1433 } else { | 1504 } else { |
1434 EXCEPTION_PREAMBLE(); | 1505 EXCEPTION_PREAMBLE(); |
1435 num = i::Execution::ToNumber(obj, &has_pending_exception); | 1506 num = i::Execution::ToNumber(obj, &has_pending_exception); |
1436 EXCEPTION_BAILOUT_CHECK(Local<Number>()); | 1507 EXCEPTION_BAILOUT_CHECK(Local<Number>()); |
1437 } | 1508 } |
1438 return Local<Number>(ToApi<Number>(num)); | 1509 return Local<Number>(ToApi<Number>(num)); |
1439 } | 1510 } |
1440 | 1511 |
1441 | 1512 |
1442 Local<Integer> Value::ToInteger() const { | 1513 Local<Integer> Value::ToInteger() const { |
| 1514 ENTER_V8; |
1443 if (IsDeadCheck("v8::Value::ToInteger()")) return Local<Integer>(); | 1515 if (IsDeadCheck("v8::Value::ToInteger()")) return Local<Integer>(); |
1444 LOG_API("ToInteger"); | 1516 LOG_API("ToInteger"); |
1445 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 1517 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
1446 i::Handle<i::Object> num; | 1518 i::Handle<i::Object> num; |
1447 if (obj->IsSmi()) { | 1519 if (obj->IsSmi()) { |
1448 num = obj; | 1520 num = obj; |
1449 } else { | 1521 } else { |
1450 EXCEPTION_PREAMBLE(); | 1522 EXCEPTION_PREAMBLE(); |
1451 num = i::Execution::ToInteger(obj, &has_pending_exception); | 1523 num = i::Execution::ToInteger(obj, &has_pending_exception); |
1452 EXCEPTION_BAILOUT_CHECK(Local<Integer>()); | 1524 EXCEPTION_BAILOUT_CHECK(Local<Integer>()); |
1453 } | 1525 } |
1454 return Local<Integer>(ToApi<Integer>(num)); | 1526 return Local<Integer>(ToApi<Integer>(num)); |
1455 } | 1527 } |
1456 | 1528 |
1457 | 1529 |
1458 External* External::Cast(v8::Value* that) { | 1530 External* External::Cast(v8::Value* that) { |
| 1531 ENTER_V8; |
1459 if (IsDeadCheck("v8::External::Cast()")) return 0; | 1532 if (IsDeadCheck("v8::External::Cast()")) return 0; |
1460 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 1533 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
1461 ApiCheck(obj->IsProxy(), | 1534 ApiCheck(obj->IsProxy(), |
1462 "v8::External::Cast()", | 1535 "v8::External::Cast()", |
1463 "Could not convert to external"); | 1536 "Could not convert to external"); |
1464 return static_cast<External*>(that); | 1537 return static_cast<External*>(that); |
1465 } | 1538 } |
1466 | 1539 |
1467 | 1540 |
1468 v8::Object* v8::Object::Cast(Value* that) { | 1541 v8::Object* v8::Object::Cast(Value* that) { |
| 1542 ENTER_V8; |
1469 if (IsDeadCheck("v8::Object::Cast()")) return 0; | 1543 if (IsDeadCheck("v8::Object::Cast()")) return 0; |
1470 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 1544 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
1471 ApiCheck(obj->IsJSObject(), | 1545 ApiCheck(obj->IsJSObject(), |
1472 "v8::Object::Cast()", | 1546 "v8::Object::Cast()", |
1473 "Could not convert to object"); | 1547 "Could not convert to object"); |
1474 return static_cast<v8::Object*>(that); | 1548 return static_cast<v8::Object*>(that); |
1475 } | 1549 } |
1476 | 1550 |
1477 | 1551 |
1478 v8::Function* v8::Function::Cast(Value* that) { | 1552 v8::Function* v8::Function::Cast(Value* that) { |
| 1553 ENTER_V8; |
1479 if (IsDeadCheck("v8::Function::Cast()")) return 0; | 1554 if (IsDeadCheck("v8::Function::Cast()")) return 0; |
1480 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 1555 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
1481 ApiCheck(obj->IsJSFunction(), | 1556 ApiCheck(obj->IsJSFunction(), |
1482 "v8::Function::Cast()", | 1557 "v8::Function::Cast()", |
1483 "Could not convert to function"); | 1558 "Could not convert to function"); |
1484 return static_cast<v8::Function*>(that); | 1559 return static_cast<v8::Function*>(that); |
1485 } | 1560 } |
1486 | 1561 |
1487 | 1562 |
1488 v8::String* v8::String::Cast(v8::Value* that) { | 1563 v8::String* v8::String::Cast(v8::Value* that) { |
| 1564 ENTER_V8; |
1489 if (IsDeadCheck("v8::String::Cast()")) return 0; | 1565 if (IsDeadCheck("v8::String::Cast()")) return 0; |
1490 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 1566 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
1491 ApiCheck(obj->IsString(), | 1567 ApiCheck(obj->IsString(), |
1492 "v8::String::Cast()", | 1568 "v8::String::Cast()", |
1493 "Could not convert to string"); | 1569 "Could not convert to string"); |
1494 return static_cast<v8::String*>(that); | 1570 return static_cast<v8::String*>(that); |
1495 } | 1571 } |
1496 | 1572 |
1497 | 1573 |
1498 v8::Number* v8::Number::Cast(v8::Value* that) { | 1574 v8::Number* v8::Number::Cast(v8::Value* that) { |
| 1575 ENTER_V8; |
1499 if (IsDeadCheck("v8::Number::Cast()")) return 0; | 1576 if (IsDeadCheck("v8::Number::Cast()")) return 0; |
1500 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 1577 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
1501 ApiCheck(obj->IsNumber(), | 1578 ApiCheck(obj->IsNumber(), |
1502 "v8::Number::Cast()", | 1579 "v8::Number::Cast()", |
1503 "Could not convert to number"); | 1580 "Could not convert to number"); |
1504 return static_cast<v8::Number*>(that); | 1581 return static_cast<v8::Number*>(that); |
1505 } | 1582 } |
1506 | 1583 |
1507 | 1584 |
1508 v8::Integer* v8::Integer::Cast(v8::Value* that) { | 1585 v8::Integer* v8::Integer::Cast(v8::Value* that) { |
| 1586 ENTER_V8; |
1509 if (IsDeadCheck("v8::Integer::Cast()")) return 0; | 1587 if (IsDeadCheck("v8::Integer::Cast()")) return 0; |
1510 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 1588 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
1511 ApiCheck(obj->IsNumber(), | 1589 ApiCheck(obj->IsNumber(), |
1512 "v8::Integer::Cast()", | 1590 "v8::Integer::Cast()", |
1513 "Could not convert to number"); | 1591 "Could not convert to number"); |
1514 return static_cast<v8::Integer*>(that); | 1592 return static_cast<v8::Integer*>(that); |
1515 } | 1593 } |
1516 | 1594 |
1517 | 1595 |
1518 v8::Array* v8::Array::Cast(Value* that) { | 1596 v8::Array* v8::Array::Cast(Value* that) { |
| 1597 ENTER_V8; |
1519 if (IsDeadCheck("v8::Array::Cast()")) return 0; | 1598 if (IsDeadCheck("v8::Array::Cast()")) return 0; |
1520 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 1599 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
1521 ApiCheck(obj->IsJSArray(), | 1600 ApiCheck(obj->IsJSArray(), |
1522 "v8::Array::Cast()", | 1601 "v8::Array::Cast()", |
1523 "Could not convert to array"); | 1602 "Could not convert to array"); |
1524 return static_cast<v8::Array*>(that); | 1603 return static_cast<v8::Array*>(that); |
1525 } | 1604 } |
1526 | 1605 |
1527 | 1606 |
1528 v8::Date* v8::Date::Cast(v8::Value* that) { | 1607 v8::Date* v8::Date::Cast(v8::Value* that) { |
| 1608 ENTER_V8; |
1529 if (IsDeadCheck("v8::Date::Cast()")) return 0; | 1609 if (IsDeadCheck("v8::Date::Cast()")) return 0; |
1530 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 1610 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
1531 ApiCheck(obj->HasSpecificClassOf(i::Heap::Date_symbol()), | 1611 ApiCheck(obj->HasSpecificClassOf(i::Heap::Date_symbol()), |
1532 "v8::Date::Cast()", | 1612 "v8::Date::Cast()", |
1533 "Could not convert to date"); | 1613 "Could not convert to date"); |
1534 return static_cast<v8::Date*>(that); | 1614 return static_cast<v8::Date*>(that); |
1535 } | 1615 } |
1536 | 1616 |
1537 | 1617 |
1538 bool Value::BooleanValue() const { | 1618 bool Value::BooleanValue() const { |
| 1619 ENTER_V8; |
1539 if (IsDeadCheck("v8::Value::BooleanValue()")) return false; | 1620 if (IsDeadCheck("v8::Value::BooleanValue()")) return false; |
1540 LOG_API("BooleanValue"); | 1621 LOG_API("BooleanValue"); |
1541 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 1622 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
1542 i::Handle<i::Object> value = | 1623 i::Handle<i::Object> value = |
1543 obj->IsBoolean() ? obj : i::Execution::ToBoolean(obj); | 1624 obj->IsBoolean() ? obj : i::Execution::ToBoolean(obj); |
1544 return value->IsTrue(); | 1625 return value->IsTrue(); |
1545 } | 1626 } |
1546 | 1627 |
1547 | 1628 |
1548 double Value::NumberValue() const { | 1629 double Value::NumberValue() const { |
| 1630 ENTER_V8; |
1549 if (IsDeadCheck("v8::Value::NumberValue()")) return i::OS::nan_value(); | 1631 if (IsDeadCheck("v8::Value::NumberValue()")) return i::OS::nan_value(); |
1550 LOG_API("NumberValue"); | 1632 LOG_API("NumberValue"); |
1551 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 1633 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
1552 i::Handle<i::Object> num; | 1634 i::Handle<i::Object> num; |
1553 if (obj->IsNumber()) { | 1635 if (obj->IsNumber()) { |
1554 num = obj; | 1636 num = obj; |
1555 } else { | 1637 } else { |
1556 EXCEPTION_PREAMBLE(); | 1638 EXCEPTION_PREAMBLE(); |
1557 num = i::Execution::ToNumber(obj, &has_pending_exception); | 1639 num = i::Execution::ToNumber(obj, &has_pending_exception); |
1558 EXCEPTION_BAILOUT_CHECK(i::OS::nan_value()); | 1640 EXCEPTION_BAILOUT_CHECK(i::OS::nan_value()); |
1559 } | 1641 } |
1560 return num->Number(); | 1642 return num->Number(); |
1561 } | 1643 } |
1562 | 1644 |
1563 | 1645 |
1564 int64_t Value::IntegerValue() const { | 1646 int64_t Value::IntegerValue() const { |
| 1647 ENTER_V8; |
1565 if (IsDeadCheck("v8::Value::IntegerValue()")) return 0; | 1648 if (IsDeadCheck("v8::Value::IntegerValue()")) return 0; |
1566 LOG_API("IntegerValue"); | 1649 LOG_API("IntegerValue"); |
1567 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 1650 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
1568 i::Handle<i::Object> num; | 1651 i::Handle<i::Object> num; |
1569 if (obj->IsNumber()) { | 1652 if (obj->IsNumber()) { |
1570 num = obj; | 1653 num = obj; |
1571 } else { | 1654 } else { |
1572 EXCEPTION_PREAMBLE(); | 1655 EXCEPTION_PREAMBLE(); |
1573 num = i::Execution::ToInteger(obj, &has_pending_exception); | 1656 num = i::Execution::ToInteger(obj, &has_pending_exception); |
1574 EXCEPTION_BAILOUT_CHECK(0); | 1657 EXCEPTION_BAILOUT_CHECK(0); |
1575 } | 1658 } |
1576 if (num->IsSmi()) { | 1659 if (num->IsSmi()) { |
1577 return i::Smi::cast(*num)->value(); | 1660 return i::Smi::cast(*num)->value(); |
1578 } else { | 1661 } else { |
1579 return static_cast<int64_t>(num->Number()); | 1662 return static_cast<int64_t>(num->Number()); |
1580 } | 1663 } |
1581 } | 1664 } |
1582 | 1665 |
1583 | 1666 |
1584 Local<Int32> Value::ToInt32() const { | 1667 Local<Int32> Value::ToInt32() const { |
| 1668 ENTER_V8; |
1585 if (IsDeadCheck("v8::Value::ToInt32()")) return Local<Int32>(); | 1669 if (IsDeadCheck("v8::Value::ToInt32()")) return Local<Int32>(); |
1586 LOG_API("ToInt32"); | 1670 LOG_API("ToInt32"); |
1587 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 1671 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
1588 i::Handle<i::Object> num; | 1672 i::Handle<i::Object> num; |
1589 if (obj->IsSmi()) { | 1673 if (obj->IsSmi()) { |
1590 num = obj; | 1674 num = obj; |
1591 } else { | 1675 } else { |
1592 EXCEPTION_PREAMBLE(); | 1676 EXCEPTION_PREAMBLE(); |
1593 num = i::Execution::ToInt32(obj, &has_pending_exception); | 1677 num = i::Execution::ToInt32(obj, &has_pending_exception); |
1594 EXCEPTION_BAILOUT_CHECK(Local<Int32>()); | 1678 EXCEPTION_BAILOUT_CHECK(Local<Int32>()); |
1595 } | 1679 } |
1596 return Local<Int32>(ToApi<Int32>(num)); | 1680 return Local<Int32>(ToApi<Int32>(num)); |
1597 } | 1681 } |
1598 | 1682 |
1599 | 1683 |
1600 Local<Uint32> Value::ToUint32() const { | 1684 Local<Uint32> Value::ToUint32() const { |
| 1685 ENTER_V8; |
1601 if (IsDeadCheck("v8::Value::ToUint32()")) return Local<Uint32>(); | 1686 if (IsDeadCheck("v8::Value::ToUint32()")) return Local<Uint32>(); |
1602 LOG_API("ToUInt32"); | 1687 LOG_API("ToUInt32"); |
1603 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 1688 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
1604 i::Handle<i::Object> num; | 1689 i::Handle<i::Object> num; |
1605 if (obj->IsSmi()) { | 1690 if (obj->IsSmi()) { |
1606 num = obj; | 1691 num = obj; |
1607 } else { | 1692 } else { |
1608 EXCEPTION_PREAMBLE(); | 1693 EXCEPTION_PREAMBLE(); |
1609 num = i::Execution::ToUint32(obj, &has_pending_exception); | 1694 num = i::Execution::ToUint32(obj, &has_pending_exception); |
1610 EXCEPTION_BAILOUT_CHECK(Local<Uint32>()); | 1695 EXCEPTION_BAILOUT_CHECK(Local<Uint32>()); |
1611 } | 1696 } |
1612 return Local<Uint32>(ToApi<Uint32>(num)); | 1697 return Local<Uint32>(ToApi<Uint32>(num)); |
1613 } | 1698 } |
1614 | 1699 |
1615 | 1700 |
1616 Local<Uint32> Value::ToArrayIndex() const { | 1701 Local<Uint32> Value::ToArrayIndex() const { |
| 1702 ENTER_V8; |
1617 if (IsDeadCheck("v8::Value::ToArrayIndex()")) return Local<Uint32>(); | 1703 if (IsDeadCheck("v8::Value::ToArrayIndex()")) return Local<Uint32>(); |
1618 LOG_API("ToArrayIndex"); | 1704 LOG_API("ToArrayIndex"); |
1619 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 1705 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
1620 if (obj->IsSmi()) { | 1706 if (obj->IsSmi()) { |
1621 if (i::Smi::cast(*obj)->value() >= 0) return Utils::Uint32ToLocal(obj); | 1707 if (i::Smi::cast(*obj)->value() >= 0) return Utils::Uint32ToLocal(obj); |
1622 return Local<Uint32>(); | 1708 return Local<Uint32>(); |
1623 } | 1709 } |
1624 EXCEPTION_PREAMBLE(); | 1710 EXCEPTION_PREAMBLE(); |
1625 i::Handle<i::Object> string_obj = | 1711 i::Handle<i::Object> string_obj = |
1626 i::Execution::ToString(obj, &has_pending_exception); | 1712 i::Execution::ToString(obj, &has_pending_exception); |
1627 EXCEPTION_BAILOUT_CHECK(Local<Uint32>()); | 1713 EXCEPTION_BAILOUT_CHECK(Local<Uint32>()); |
1628 i::Handle<i::String> str = i::Handle<i::String>::cast(string_obj); | 1714 i::Handle<i::String> str = i::Handle<i::String>::cast(string_obj); |
1629 uint32_t index; | 1715 uint32_t index; |
1630 if (str->AsArrayIndex(&index)) { | 1716 if (str->AsArrayIndex(&index)) { |
1631 i::Handle<i::Object> value; | 1717 i::Handle<i::Object> value; |
1632 if (index <= static_cast<uint32_t>(i::Smi::kMaxValue)) { | 1718 if (index <= static_cast<uint32_t>(i::Smi::kMaxValue)) { |
1633 value = i::Handle<i::Object>(i::Smi::FromInt(index)); | 1719 value = i::Handle<i::Object>(i::Smi::FromInt(index)); |
1634 } else { | 1720 } else { |
1635 value = i::Factory::NewNumber(index); | 1721 value = i::Factory::NewNumber(index); |
1636 } | 1722 } |
1637 return Utils::Uint32ToLocal(value); | 1723 return Utils::Uint32ToLocal(value); |
1638 } | 1724 } |
1639 return Local<Uint32>(); | 1725 return Local<Uint32>(); |
1640 } | 1726 } |
1641 | 1727 |
1642 | 1728 |
1643 int32_t Value::Int32Value() const { | 1729 int32_t Value::Int32Value() const { |
| 1730 ENTER_V8; |
1644 if (IsDeadCheck("v8::Value::Int32Value()")) return 0; | 1731 if (IsDeadCheck("v8::Value::Int32Value()")) return 0; |
1645 LOG_API("Int32Value"); | 1732 LOG_API("Int32Value"); |
1646 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 1733 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
1647 if (obj->IsSmi()) { | 1734 if (obj->IsSmi()) { |
1648 return i::Smi::cast(*obj)->value(); | 1735 return i::Smi::cast(*obj)->value(); |
1649 } else { | 1736 } else { |
1650 LOG_API("Int32Value (slow)"); | 1737 LOG_API("Int32Value (slow)"); |
1651 EXCEPTION_PREAMBLE(); | 1738 EXCEPTION_PREAMBLE(); |
1652 i::Handle<i::Object> num = | 1739 i::Handle<i::Object> num = |
1653 i::Execution::ToInt32(obj, &has_pending_exception); | 1740 i::Execution::ToInt32(obj, &has_pending_exception); |
1654 EXCEPTION_BAILOUT_CHECK(0); | 1741 EXCEPTION_BAILOUT_CHECK(0); |
1655 if (num->IsSmi()) { | 1742 if (num->IsSmi()) { |
1656 return i::Smi::cast(*num)->value(); | 1743 return i::Smi::cast(*num)->value(); |
1657 } else { | 1744 } else { |
1658 return static_cast<int32_t>(num->Number()); | 1745 return static_cast<int32_t>(num->Number()); |
1659 } | 1746 } |
1660 } | 1747 } |
1661 } | 1748 } |
1662 | 1749 |
1663 | 1750 |
1664 bool Value::Equals(Handle<Value> that) const { | 1751 bool Value::Equals(Handle<Value> that) const { |
| 1752 ENTER_V8; |
1665 if (IsDeadCheck("v8::Value::Equals()") | 1753 if (IsDeadCheck("v8::Value::Equals()") |
1666 || EmptyCheck("v8::Value::Equals()", this) | 1754 || EmptyCheck("v8::Value::Equals()", this) |
1667 || EmptyCheck("v8::Value::Equals()", that)) | 1755 || EmptyCheck("v8::Value::Equals()", that)) |
1668 return false; | 1756 return false; |
1669 LOG_API("Equals"); | 1757 LOG_API("Equals"); |
1670 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 1758 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
1671 i::Handle<i::Object> other = Utils::OpenHandle(*that); | 1759 i::Handle<i::Object> other = Utils::OpenHandle(*that); |
1672 i::Object** args[1] = { other.location() }; | 1760 i::Object** args[1] = { other.location() }; |
1673 EXCEPTION_PREAMBLE(); | 1761 EXCEPTION_PREAMBLE(); |
1674 i::Handle<i::Object> result = | 1762 i::Handle<i::Object> result = |
1675 CallV8HeapFunction("EQUALS", obj, 1, args, &has_pending_exception); | 1763 CallV8HeapFunction("EQUALS", obj, 1, args, &has_pending_exception); |
1676 EXCEPTION_BAILOUT_CHECK(false); | 1764 EXCEPTION_BAILOUT_CHECK(false); |
1677 return *result == i::Smi::FromInt(i::EQUAL); | 1765 return *result == i::Smi::FromInt(i::EQUAL); |
1678 } | 1766 } |
1679 | 1767 |
1680 | 1768 |
1681 bool Value::StrictEquals(Handle<Value> that) const { | 1769 bool Value::StrictEquals(Handle<Value> that) const { |
| 1770 ENTER_V8; |
1682 if (IsDeadCheck("v8::Value::StrictEquals()") | 1771 if (IsDeadCheck("v8::Value::StrictEquals()") |
1683 || EmptyCheck("v8::Value::StrictEquals()", this) | 1772 || EmptyCheck("v8::Value::StrictEquals()", this) |
1684 || EmptyCheck("v8::Value::StrictEquals()", that)) | 1773 || EmptyCheck("v8::Value::StrictEquals()", that)) |
1685 return false; | 1774 return false; |
1686 LOG_API("StrictEquals"); | 1775 LOG_API("StrictEquals"); |
1687 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 1776 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
1688 i::Handle<i::Object> other = Utils::OpenHandle(*that); | 1777 i::Handle<i::Object> other = Utils::OpenHandle(*that); |
1689 // Must check HeapNumber first, since NaN !== NaN. | 1778 // Must check HeapNumber first, since NaN !== NaN. |
1690 if (obj->IsHeapNumber()) { | 1779 if (obj->IsHeapNumber()) { |
1691 if (!other->IsNumber()) return false; | 1780 if (!other->IsNumber()) return false; |
(...skipping 10 matching lines...) Expand all Loading... |
1702 i::String::cast(*obj)->Equals(i::String::cast(*other)); | 1791 i::String::cast(*obj)->Equals(i::String::cast(*other)); |
1703 } else if (obj->IsUndefined() || obj->IsUndetectableObject()) { | 1792 } else if (obj->IsUndefined() || obj->IsUndetectableObject()) { |
1704 return other->IsUndefined() || other->IsUndetectableObject(); | 1793 return other->IsUndefined() || other->IsUndetectableObject(); |
1705 } else { | 1794 } else { |
1706 return false; | 1795 return false; |
1707 } | 1796 } |
1708 } | 1797 } |
1709 | 1798 |
1710 | 1799 |
1711 uint32_t Value::Uint32Value() const { | 1800 uint32_t Value::Uint32Value() const { |
| 1801 ENTER_V8; |
1712 if (IsDeadCheck("v8::Value::Uint32Value()")) return 0; | 1802 if (IsDeadCheck("v8::Value::Uint32Value()")) return 0; |
1713 LOG_API("Uint32Value"); | 1803 LOG_API("Uint32Value"); |
1714 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 1804 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
1715 if (obj->IsSmi()) { | 1805 if (obj->IsSmi()) { |
1716 return i::Smi::cast(*obj)->value(); | 1806 return i::Smi::cast(*obj)->value(); |
1717 } else { | 1807 } else { |
1718 EXCEPTION_PREAMBLE(); | 1808 EXCEPTION_PREAMBLE(); |
1719 i::Handle<i::Object> num = | 1809 i::Handle<i::Object> num = |
1720 i::Execution::ToUint32(obj, &has_pending_exception); | 1810 i::Execution::ToUint32(obj, &has_pending_exception); |
1721 EXCEPTION_BAILOUT_CHECK(0); | 1811 EXCEPTION_BAILOUT_CHECK(0); |
1722 if (num->IsSmi()) { | 1812 if (num->IsSmi()) { |
1723 return i::Smi::cast(*num)->value(); | 1813 return i::Smi::cast(*num)->value(); |
1724 } else { | 1814 } else { |
1725 return static_cast<uint32_t>(num->Number()); | 1815 return static_cast<uint32_t>(num->Number()); |
1726 } | 1816 } |
1727 } | 1817 } |
1728 } | 1818 } |
1729 | 1819 |
1730 | 1820 |
1731 bool v8::Object::Set(v8::Handle<Value> key, v8::Handle<Value> value, | 1821 bool v8::Object::Set(v8::Handle<Value> key, v8::Handle<Value> value, |
1732 v8::PropertyAttribute attribs) { | 1822 v8::PropertyAttribute attribs) { |
| 1823 ENTER_V8; |
1733 ON_BAILOUT("v8::Object::Set()", return false); | 1824 ON_BAILOUT("v8::Object::Set()", return false); |
1734 i::Handle<i::Object> self = Utils::OpenHandle(this); | 1825 i::Handle<i::Object> self = Utils::OpenHandle(this); |
1735 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); | 1826 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); |
1736 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); | 1827 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
1737 EXCEPTION_PREAMBLE(); | 1828 EXCEPTION_PREAMBLE(); |
1738 i::Handle<i::Object> obj = i::SetProperty( | 1829 i::Handle<i::Object> obj = i::SetProperty( |
1739 self, | 1830 self, |
1740 key_obj, | 1831 key_obj, |
1741 value_obj, | 1832 value_obj, |
1742 static_cast<PropertyAttributes>(attribs)); | 1833 static_cast<PropertyAttributes>(attribs)); |
1743 has_pending_exception = obj.is_null(); | 1834 has_pending_exception = obj.is_null(); |
1744 EXCEPTION_BAILOUT_CHECK(false); | 1835 EXCEPTION_BAILOUT_CHECK(false); |
1745 return true; | 1836 return true; |
1746 } | 1837 } |
1747 | 1838 |
1748 | 1839 |
1749 Local<Value> v8::Object::Get(v8::Handle<Value> key) { | 1840 Local<Value> v8::Object::Get(v8::Handle<Value> key) { |
| 1841 ENTER_V8; |
1750 ON_BAILOUT("v8::Object::Get()", return Local<v8::Value>()); | 1842 ON_BAILOUT("v8::Object::Get()", return Local<v8::Value>()); |
1751 i::Handle<i::Object> self = Utils::OpenHandle(this); | 1843 i::Handle<i::Object> self = Utils::OpenHandle(this); |
1752 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); | 1844 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); |
1753 EXCEPTION_PREAMBLE(); | 1845 EXCEPTION_PREAMBLE(); |
1754 i::Handle<i::Object> result = i::GetProperty(self, key_obj); | 1846 i::Handle<i::Object> result = i::GetProperty(self, key_obj); |
1755 has_pending_exception = result.is_null(); | 1847 has_pending_exception = result.is_null(); |
1756 EXCEPTION_BAILOUT_CHECK(Local<Value>()); | 1848 EXCEPTION_BAILOUT_CHECK(Local<Value>()); |
1757 return Utils::ToLocal(result); | 1849 return Utils::ToLocal(result); |
1758 } | 1850 } |
1759 | 1851 |
1760 | 1852 |
1761 Local<Value> v8::Object::GetPrototype() { | 1853 Local<Value> v8::Object::GetPrototype() { |
| 1854 ENTER_V8; |
1762 ON_BAILOUT("v8::Object::GetPrototype()", return Local<v8::Value>()); | 1855 ON_BAILOUT("v8::Object::GetPrototype()", return Local<v8::Value>()); |
1763 i::Handle<i::Object> self = Utils::OpenHandle(this); | 1856 i::Handle<i::Object> self = Utils::OpenHandle(this); |
1764 i::Handle<i::Object> result = i::GetPrototype(self); | 1857 i::Handle<i::Object> result = i::GetPrototype(self); |
1765 return Utils::ToLocal(result); | 1858 return Utils::ToLocal(result); |
1766 } | 1859 } |
1767 | 1860 |
1768 | 1861 |
1769 Local<Array> v8::Object::GetPropertyNames() { | 1862 Local<Array> v8::Object::GetPropertyNames() { |
| 1863 ENTER_V8; |
1770 ON_BAILOUT("v8::Object::GetPropertyNames()", return Local<v8::Array>()); | 1864 ON_BAILOUT("v8::Object::GetPropertyNames()", return Local<v8::Array>()); |
1771 v8::HandleScope scope; | 1865 v8::HandleScope scope; |
1772 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 1866 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
1773 i::Handle<i::FixedArray> value = i::GetKeysInFixedArrayFor(self); | 1867 i::Handle<i::FixedArray> value = i::GetKeysInFixedArrayFor(self); |
1774 // Because we use caching to speed up enumeration it is important | 1868 // Because we use caching to speed up enumeration it is important |
1775 // to never change the result of the basic enumeration function so | 1869 // to never change the result of the basic enumeration function so |
1776 // we clone the result. | 1870 // we clone the result. |
1777 i::Handle<i::FixedArray> elms = i::Factory::CopyFixedArray(value); | 1871 i::Handle<i::FixedArray> elms = i::Factory::CopyFixedArray(value); |
1778 i::Handle<i::JSArray> result = i::Factory::NewJSArrayWithElements(elms); | 1872 i::Handle<i::JSArray> result = i::Factory::NewJSArrayWithElements(elms); |
1779 return scope.Close(Utils::ToLocal(result)); | 1873 return scope.Close(Utils::ToLocal(result)); |
1780 } | 1874 } |
1781 | 1875 |
1782 | 1876 |
1783 Local<String> v8::Object::ObjectProtoToString() { | 1877 Local<String> v8::Object::ObjectProtoToString() { |
| 1878 ENTER_V8; |
1784 ON_BAILOUT("v8::Object::ObjectProtoToString()", return Local<v8::String>()); | 1879 ON_BAILOUT("v8::Object::ObjectProtoToString()", return Local<v8::String>()); |
1785 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 1880 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
1786 | 1881 |
1787 i::Handle<i::Object> name(self->class_name()); | 1882 i::Handle<i::Object> name(self->class_name()); |
1788 | 1883 |
1789 // Native implementation of Object.prototype.toString (v8natives.js): | 1884 // Native implementation of Object.prototype.toString (v8natives.js): |
1790 // var c = %ClassOf(this); | 1885 // var c = %ClassOf(this); |
1791 // if (c === 'Arguments') c = 'Object'; | 1886 // if (c === 'Arguments') c = 'Object'; |
1792 // return "[object " + c + "]"; | 1887 // return "[object " + c + "]"; |
1793 | 1888 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1826 // Copy the buffer into a heap-allocated string and return it. | 1921 // Copy the buffer into a heap-allocated string and return it. |
1827 Local<String> result = v8::String::New(buf, buf_len); | 1922 Local<String> result = v8::String::New(buf, buf_len); |
1828 i::DeleteArray(buf); | 1923 i::DeleteArray(buf); |
1829 return result; | 1924 return result; |
1830 } | 1925 } |
1831 } | 1926 } |
1832 } | 1927 } |
1833 | 1928 |
1834 | 1929 |
1835 bool v8::Object::Delete(v8::Handle<String> key) { | 1930 bool v8::Object::Delete(v8::Handle<String> key) { |
| 1931 ENTER_V8; |
1836 ON_BAILOUT("v8::Object::Delete()", return false); | 1932 ON_BAILOUT("v8::Object::Delete()", return false); |
1837 HandleScope scope; | 1933 HandleScope scope; |
1838 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 1934 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
1839 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); | 1935 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); |
1840 return i::DeleteProperty(self, key_obj)->IsTrue(); | 1936 return i::DeleteProperty(self, key_obj)->IsTrue(); |
1841 } | 1937 } |
1842 | 1938 |
1843 | 1939 |
1844 bool v8::Object::Has(v8::Handle<String> key) { | 1940 bool v8::Object::Has(v8::Handle<String> key) { |
| 1941 ENTER_V8; |
1845 ON_BAILOUT("v8::Object::Has()", return false); | 1942 ON_BAILOUT("v8::Object::Has()", return false); |
1846 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 1943 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
1847 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); | 1944 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); |
1848 return self->HasProperty(*key_obj); | 1945 return self->HasProperty(*key_obj); |
1849 } | 1946 } |
1850 | 1947 |
1851 | 1948 |
1852 bool v8::Object::Delete(uint32_t index) { | 1949 bool v8::Object::Delete(uint32_t index) { |
| 1950 ENTER_V8; |
1853 ON_BAILOUT("v8::Object::DeleteProperty()", return false); | 1951 ON_BAILOUT("v8::Object::DeleteProperty()", return false); |
1854 HandleScope scope; | 1952 HandleScope scope; |
1855 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 1953 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
1856 return i::DeleteElement(self, index)->IsTrue(); | 1954 return i::DeleteElement(self, index)->IsTrue(); |
1857 } | 1955 } |
1858 | 1956 |
1859 | 1957 |
1860 bool v8::Object::Has(uint32_t index) { | 1958 bool v8::Object::Has(uint32_t index) { |
| 1959 ENTER_V8; |
1861 ON_BAILOUT("v8::Object::HasProperty()", return false); | 1960 ON_BAILOUT("v8::Object::HasProperty()", return false); |
1862 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 1961 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
1863 return self->HasElement(index); | 1962 return self->HasElement(index); |
1864 } | 1963 } |
1865 | 1964 |
1866 | 1965 |
1867 bool v8::Object::HasRealNamedProperty(Handle<String> key) { | 1966 bool v8::Object::HasRealNamedProperty(Handle<String> key) { |
| 1967 ENTER_V8; |
1868 ON_BAILOUT("v8::Object::HasRealNamedProperty()", return false); | 1968 ON_BAILOUT("v8::Object::HasRealNamedProperty()", return false); |
1869 return Utils::OpenHandle(this)->HasRealNamedProperty( | 1969 return Utils::OpenHandle(this)->HasRealNamedProperty( |
1870 *Utils::OpenHandle(*key)); | 1970 *Utils::OpenHandle(*key)); |
1871 } | 1971 } |
1872 | 1972 |
1873 | 1973 |
1874 bool v8::Object::HasRealIndexedProperty(uint32_t index) { | 1974 bool v8::Object::HasRealIndexedProperty(uint32_t index) { |
| 1975 ENTER_V8; |
1875 ON_BAILOUT("v8::Object::HasRealIndexedProperty()", return false); | 1976 ON_BAILOUT("v8::Object::HasRealIndexedProperty()", return false); |
1876 return Utils::OpenHandle(this)->HasRealElementProperty(index); | 1977 return Utils::OpenHandle(this)->HasRealElementProperty(index); |
1877 } | 1978 } |
1878 | 1979 |
1879 | 1980 |
1880 bool v8::Object::HasRealNamedCallbackProperty(Handle<String> key) { | 1981 bool v8::Object::HasRealNamedCallbackProperty(Handle<String> key) { |
| 1982 ENTER_V8; |
1881 ON_BAILOUT("v8::Object::HasRealNamedCallbackProperty()", return false); | 1983 ON_BAILOUT("v8::Object::HasRealNamedCallbackProperty()", return false); |
1882 return Utils::OpenHandle(this)->HasRealNamedCallbackProperty( | 1984 return Utils::OpenHandle(this)->HasRealNamedCallbackProperty( |
1883 *Utils::OpenHandle(*key)); | 1985 *Utils::OpenHandle(*key)); |
1884 } | 1986 } |
1885 | 1987 |
1886 | 1988 |
1887 bool v8::Object::HasNamedLookupInterceptor() { | 1989 bool v8::Object::HasNamedLookupInterceptor() { |
| 1990 ENTER_V8; |
1888 ON_BAILOUT("v8::Object::HasNamedLookupInterceptor()", return false); | 1991 ON_BAILOUT("v8::Object::HasNamedLookupInterceptor()", return false); |
1889 return Utils::OpenHandle(this)->HasNamedInterceptor(); | 1992 return Utils::OpenHandle(this)->HasNamedInterceptor(); |
1890 } | 1993 } |
1891 | 1994 |
1892 | 1995 |
1893 bool v8::Object::HasIndexedLookupInterceptor() { | 1996 bool v8::Object::HasIndexedLookupInterceptor() { |
| 1997 ENTER_V8; |
1894 ON_BAILOUT("v8::Object::HasIndexedLookupInterceptor()", return false); | 1998 ON_BAILOUT("v8::Object::HasIndexedLookupInterceptor()", return false); |
1895 return Utils::OpenHandle(this)->HasIndexedInterceptor(); | 1999 return Utils::OpenHandle(this)->HasIndexedInterceptor(); |
1896 } | 2000 } |
1897 | 2001 |
1898 | 2002 |
1899 Handle<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( | 2003 Handle<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( |
1900 Handle<String> key) { | 2004 Handle<String> key) { |
| 2005 ENTER_V8; |
1901 ON_BAILOUT("v8::Object::GetRealNamedPropertyInPrototypeChain()", | 2006 ON_BAILOUT("v8::Object::GetRealNamedPropertyInPrototypeChain()", |
1902 return Local<Value>()); | 2007 return Local<Value>()); |
1903 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); | 2008 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); |
1904 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); | 2009 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); |
1905 i::LookupResult lookup; | 2010 i::LookupResult lookup; |
1906 self_obj->LookupRealNamedPropertyInPrototypes(*key_obj, &lookup); | 2011 self_obj->LookupRealNamedPropertyInPrototypes(*key_obj, &lookup); |
1907 if (lookup.IsValid()) { | 2012 if (lookup.IsValid()) { |
1908 PropertyAttributes attributes; | 2013 PropertyAttributes attributes; |
1909 i::Handle<i::Object> result(self_obj->GetProperty(*self_obj, | 2014 i::Handle<i::Object> result(self_obj->GetProperty(*self_obj, |
1910 &lookup, | 2015 &lookup, |
1911 *key_obj, | 2016 *key_obj, |
1912 &attributes)); | 2017 &attributes)); |
1913 return Utils::ToLocal(result); | 2018 return Utils::ToLocal(result); |
1914 } | 2019 } |
1915 return Local<Value>(); // No real property was found in prototype chain. | 2020 return Local<Value>(); // No real property was found in prototype chain. |
1916 } | 2021 } |
1917 | 2022 |
1918 | 2023 |
1919 // Turns on access checks by copying the map and setting the check flag. | 2024 // Turns on access checks by copying the map and setting the check flag. |
1920 // Because the object gets a new map, existing inline cache caching | 2025 // Because the object gets a new map, existing inline cache caching |
1921 // the old map of this object will fail. | 2026 // the old map of this object will fail. |
1922 void v8::Object::TurnOnAccessCheck() { | 2027 void v8::Object::TurnOnAccessCheck() { |
| 2028 ENTER_V8; |
1923 ON_BAILOUT("v8::Object::TurnOnAccessCheck()", return); | 2029 ON_BAILOUT("v8::Object::TurnOnAccessCheck()", return); |
1924 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); | 2030 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
1925 | 2031 |
1926 i::Handle<i::Map> new_map = | 2032 i::Handle<i::Map> new_map = |
1927 i::Factory::CopyMapDropTransitions(i::Handle<i::Map>(obj->map())); | 2033 i::Factory::CopyMapDropTransitions(i::Handle<i::Map>(obj->map())); |
1928 new_map->set_is_access_check_needed(true); | 2034 new_map->set_is_access_check_needed(true); |
1929 obj->set_map(*new_map); | 2035 obj->set_map(*new_map); |
1930 } | 2036 } |
1931 | 2037 |
1932 | 2038 |
1933 Local<v8::Object> v8::Object::Clone() { | 2039 Local<v8::Object> v8::Object::Clone() { |
| 2040 ENTER_V8; |
1934 ON_BAILOUT("v8::Object::Clone()", return Local<Object>()); | 2041 ON_BAILOUT("v8::Object::Clone()", return Local<Object>()); |
1935 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2042 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
1936 EXCEPTION_PREAMBLE(); | 2043 EXCEPTION_PREAMBLE(); |
1937 i::Handle<i::JSObject> result = i::Copy(self); | 2044 i::Handle<i::JSObject> result = i::Copy(self); |
1938 has_pending_exception = result.is_null(); | 2045 has_pending_exception = result.is_null(); |
1939 EXCEPTION_BAILOUT_CHECK(Local<Object>()); | 2046 EXCEPTION_BAILOUT_CHECK(Local<Object>()); |
1940 return Utils::ToLocal(result); | 2047 return Utils::ToLocal(result); |
1941 } | 2048 } |
1942 | 2049 |
1943 | 2050 |
1944 int v8::Object::GetIdentityHash() { | 2051 int v8::Object::GetIdentityHash() { |
| 2052 ENTER_V8; |
1945 ON_BAILOUT("v8::Object::GetIdentityHash()", return 0); | 2053 ON_BAILOUT("v8::Object::GetIdentityHash()", return 0); |
1946 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2054 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
1947 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, true)); | 2055 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, true)); |
1948 i::Handle<i::Object> hash_symbol = i::Factory::identity_hash_symbol(); | 2056 i::Handle<i::Object> hash_symbol = i::Factory::identity_hash_symbol(); |
1949 i::Handle<i::Object> hash = i::GetProperty(hidden_props, hash_symbol); | 2057 i::Handle<i::Object> hash = i::GetProperty(hidden_props, hash_symbol); |
1950 int hash_value; | 2058 int hash_value; |
1951 if (hash->IsSmi()) { | 2059 if (hash->IsSmi()) { |
1952 hash_value = i::Smi::cast(*hash)->value(); | 2060 hash_value = i::Smi::cast(*hash)->value(); |
1953 } else { | 2061 } else { |
1954 hash_value = random() & i::Smi::kMaxValue; // Limit range to fit a smi. | 2062 hash_value = random() & i::Smi::kMaxValue; // Limit range to fit a smi. |
1955 i::SetProperty(hidden_props, | 2063 i::SetProperty(hidden_props, |
1956 hash_symbol, | 2064 hash_symbol, |
1957 i::Handle<i::Object>(i::Smi::FromInt(hash_value)), | 2065 i::Handle<i::Object>(i::Smi::FromInt(hash_value)), |
1958 static_cast<PropertyAttributes>(None)); | 2066 static_cast<PropertyAttributes>(None)); |
1959 } | 2067 } |
1960 return hash_value; | 2068 return hash_value; |
1961 } | 2069 } |
1962 | 2070 |
1963 | 2071 |
1964 bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key, | 2072 bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key, |
1965 v8::Handle<v8::Value> value) { | 2073 v8::Handle<v8::Value> value) { |
| 2074 ENTER_V8; |
1966 ON_BAILOUT("v8::Object::SetHiddenValue()", return false); | 2075 ON_BAILOUT("v8::Object::SetHiddenValue()", return false); |
1967 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2076 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
1968 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, true)); | 2077 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, true)); |
1969 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); | 2078 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); |
1970 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); | 2079 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
1971 EXCEPTION_PREAMBLE(); | 2080 EXCEPTION_PREAMBLE(); |
1972 i::Handle<i::Object> obj = i::SetProperty( | 2081 i::Handle<i::Object> obj = i::SetProperty( |
1973 hidden_props, | 2082 hidden_props, |
1974 key_obj, | 2083 key_obj, |
1975 value_obj, | 2084 value_obj, |
1976 static_cast<PropertyAttributes>(None)); | 2085 static_cast<PropertyAttributes>(None)); |
1977 has_pending_exception = obj.is_null(); | 2086 has_pending_exception = obj.is_null(); |
1978 EXCEPTION_BAILOUT_CHECK(false); | 2087 EXCEPTION_BAILOUT_CHECK(false); |
1979 return true; | 2088 return true; |
1980 } | 2089 } |
1981 | 2090 |
1982 | 2091 |
1983 v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Handle<v8::String> key) { | 2092 v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Handle<v8::String> key) { |
| 2093 ENTER_V8; |
1984 ON_BAILOUT("v8::Object::GetHiddenValue()", return Local<v8::Value>()); | 2094 ON_BAILOUT("v8::Object::GetHiddenValue()", return Local<v8::Value>()); |
1985 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2095 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
1986 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, false)); | 2096 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, false)); |
1987 if (hidden_props->IsUndefined()) { | 2097 if (hidden_props->IsUndefined()) { |
1988 return v8::Local<v8::Value>(); | 2098 return v8::Local<v8::Value>(); |
1989 } | 2099 } |
1990 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); | 2100 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); |
1991 EXCEPTION_PREAMBLE(); | 2101 EXCEPTION_PREAMBLE(); |
1992 i::Handle<i::Object> result = i::GetProperty(hidden_props, key_obj); | 2102 i::Handle<i::Object> result = i::GetProperty(hidden_props, key_obj); |
1993 has_pending_exception = result.is_null(); | 2103 has_pending_exception = result.is_null(); |
1994 EXCEPTION_BAILOUT_CHECK(v8::Local<v8::Value>()); | 2104 EXCEPTION_BAILOUT_CHECK(v8::Local<v8::Value>()); |
1995 if (result->IsUndefined()) { | 2105 if (result->IsUndefined()) { |
1996 return v8::Local<v8::Value>(); | 2106 return v8::Local<v8::Value>(); |
1997 } | 2107 } |
1998 return Utils::ToLocal(result); | 2108 return Utils::ToLocal(result); |
1999 } | 2109 } |
2000 | 2110 |
2001 | 2111 |
2002 bool v8::Object::DeleteHiddenValue(v8::Handle<v8::String> key) { | 2112 bool v8::Object::DeleteHiddenValue(v8::Handle<v8::String> key) { |
| 2113 ENTER_V8; |
2003 ON_BAILOUT("v8::DeleteHiddenValue()", return false); | 2114 ON_BAILOUT("v8::DeleteHiddenValue()", return false); |
2004 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2115 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
2005 i::Handle<i::JSObject> hidden_props( | 2116 i::Handle<i::JSObject> hidden_props( |
2006 i::JSObject::cast(*i::GetHiddenProperties(self, false))); | 2117 i::JSObject::cast(*i::GetHiddenProperties(self, false))); |
2007 if (hidden_props->IsUndefined()) { | 2118 if (hidden_props->IsUndefined()) { |
2008 return false; | 2119 return false; |
2009 } | 2120 } |
2010 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); | 2121 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); |
2011 return i::DeleteProperty(hidden_props, key_obj)->IsTrue(); | 2122 return i::DeleteProperty(hidden_props, key_obj)->IsTrue(); |
2012 } | 2123 } |
2013 | 2124 |
2014 | 2125 |
2015 Local<v8::Object> Function::NewInstance() const { | 2126 Local<v8::Object> Function::NewInstance() const { |
2016 return NewInstance(0, NULL); | 2127 return NewInstance(0, NULL); |
2017 } | 2128 } |
2018 | 2129 |
2019 | 2130 |
2020 Local<v8::Object> Function::NewInstance(int argc, | 2131 Local<v8::Object> Function::NewInstance(int argc, |
2021 v8::Handle<v8::Value> argv[]) const { | 2132 v8::Handle<v8::Value> argv[]) const { |
| 2133 ENTER_V8; |
2022 ON_BAILOUT("v8::Function::NewInstance()", return Local<v8::Object>()); | 2134 ON_BAILOUT("v8::Function::NewInstance()", return Local<v8::Object>()); |
2023 LOG_API("Function::NewInstance"); | 2135 LOG_API("Function::NewInstance"); |
2024 HandleScope scope; | 2136 HandleScope scope; |
2025 i::Handle<i::JSFunction> function = Utils::OpenHandle(this); | 2137 i::Handle<i::JSFunction> function = Utils::OpenHandle(this); |
2026 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); | 2138 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); |
2027 i::Object*** args = reinterpret_cast<i::Object***>(argv); | 2139 i::Object*** args = reinterpret_cast<i::Object***>(argv); |
2028 EXCEPTION_PREAMBLE(); | 2140 EXCEPTION_PREAMBLE(); |
2029 i::Handle<i::Object> returned = | 2141 i::Handle<i::Object> returned = |
2030 i::Execution::New(function, argc, args, &has_pending_exception); | 2142 i::Execution::New(function, argc, args, &has_pending_exception); |
2031 EXCEPTION_BAILOUT_CHECK(Local<v8::Object>()); | 2143 EXCEPTION_BAILOUT_CHECK(Local<v8::Object>()); |
2032 return scope.Close(Utils::ToLocal(i::Handle<i::JSObject>::cast(returned))); | 2144 return scope.Close(Utils::ToLocal(i::Handle<i::JSObject>::cast(returned))); |
2033 } | 2145 } |
2034 | 2146 |
2035 | 2147 |
2036 Local<v8::Value> Function::Call(v8::Handle<v8::Object> recv, int argc, | 2148 Local<v8::Value> Function::Call(v8::Handle<v8::Object> recv, int argc, |
2037 v8::Handle<v8::Value> argv[]) { | 2149 v8::Handle<v8::Value> argv[]) { |
| 2150 ENTER_V8; |
2038 ON_BAILOUT("v8::Function::Call()", return Local<v8::Value>()); | 2151 ON_BAILOUT("v8::Function::Call()", return Local<v8::Value>()); |
2039 LOG_API("Function::Call"); | 2152 LOG_API("Function::Call"); |
2040 i::Object* raw_result = NULL; | 2153 i::Object* raw_result = NULL; |
2041 { | 2154 { |
2042 HandleScope scope; | 2155 HandleScope scope; |
2043 i::Handle<i::JSFunction> fun = Utils::OpenHandle(this); | 2156 i::Handle<i::JSFunction> fun = Utils::OpenHandle(this); |
2044 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); | 2157 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); |
2045 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); | 2158 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); |
2046 i::Object*** args = reinterpret_cast<i::Object***>(argv); | 2159 i::Object*** args = reinterpret_cast<i::Object***>(argv); |
2047 EXCEPTION_PREAMBLE(); | 2160 EXCEPTION_PREAMBLE(); |
2048 i::Handle<i::Object> returned = | 2161 i::Handle<i::Object> returned = |
2049 i::Execution::Call(fun, recv_obj, argc, args, &has_pending_exception); | 2162 i::Execution::Call(fun, recv_obj, argc, args, &has_pending_exception); |
2050 EXCEPTION_BAILOUT_CHECK(Local<Object>()); | 2163 EXCEPTION_BAILOUT_CHECK(Local<Object>()); |
2051 raw_result = *returned; | 2164 raw_result = *returned; |
2052 } | 2165 } |
2053 i::Handle<i::Object> result(raw_result); | 2166 i::Handle<i::Object> result(raw_result); |
2054 return Utils::ToLocal(result); | 2167 return Utils::ToLocal(result); |
2055 } | 2168 } |
2056 | 2169 |
2057 | 2170 |
2058 void Function::SetName(v8::Handle<v8::String> name) { | 2171 void Function::SetName(v8::Handle<v8::String> name) { |
| 2172 ENTER_V8; |
2059 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); | 2173 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); |
2060 func->shared()->set_name(*Utils::OpenHandle(*name)); | 2174 func->shared()->set_name(*Utils::OpenHandle(*name)); |
2061 } | 2175 } |
2062 | 2176 |
2063 | 2177 |
2064 Handle<Value> Function::GetName() const { | 2178 Handle<Value> Function::GetName() const { |
2065 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); | 2179 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); |
2066 return Utils::ToLocal(i::Handle<i::Object>(func->shared()->name())); | 2180 return Utils::ToLocal(i::Handle<i::Object>(func->shared()->name())); |
2067 } | 2181 } |
2068 | 2182 |
2069 | 2183 |
2070 int String::Length() const { | 2184 int String::Length() const { |
| 2185 ENTER_V8; |
2071 if (IsDeadCheck("v8::String::Length()")) return 0; | 2186 if (IsDeadCheck("v8::String::Length()")) return 0; |
2072 return Utils::OpenHandle(this)->length(); | 2187 return Utils::OpenHandle(this)->length(); |
2073 } | 2188 } |
2074 | 2189 |
2075 | 2190 |
2076 int String::Utf8Length() const { | 2191 int String::Utf8Length() const { |
| 2192 ENTER_V8; |
2077 if (IsDeadCheck("v8::String::Utf8Length()")) return 0; | 2193 if (IsDeadCheck("v8::String::Utf8Length()")) return 0; |
2078 return Utils::OpenHandle(this)->Utf8Length(); | 2194 return Utils::OpenHandle(this)->Utf8Length(); |
2079 } | 2195 } |
2080 | 2196 |
2081 | 2197 |
2082 int String::WriteUtf8(char* buffer, int capacity) const { | 2198 int String::WriteUtf8(char* buffer, int capacity) const { |
| 2199 ENTER_V8; |
2083 if (IsDeadCheck("v8::String::WriteUtf8()")) return 0; | 2200 if (IsDeadCheck("v8::String::WriteUtf8()")) return 0; |
2084 LOG_API("String::WriteUtf8"); | 2201 LOG_API("String::WriteUtf8"); |
2085 i::Handle<i::String> str = Utils::OpenHandle(this); | 2202 i::Handle<i::String> str = Utils::OpenHandle(this); |
2086 write_input_buffer.Reset(0, *str); | 2203 write_input_buffer.Reset(0, *str); |
2087 int len = str->length(); | 2204 int len = str->length(); |
2088 // Encode the first K - 3 bytes directly into the buffer since we | 2205 // Encode the first K - 3 bytes directly into the buffer since we |
2089 // know there's room for them. If no capacity is given we copy all | 2206 // know there's room for them. If no capacity is given we copy all |
2090 // of them here. | 2207 // of them here. |
2091 int fast_end = capacity - (unibrow::Utf8::kMaxEncodedSize - 1); | 2208 int fast_end = capacity - (unibrow::Utf8::kMaxEncodedSize - 1); |
2092 int i; | 2209 int i; |
(...skipping 21 matching lines...) Expand all Loading... |
2114 } | 2231 } |
2115 } | 2232 } |
2116 } | 2233 } |
2117 if (i == len && (capacity == -1 || pos < capacity)) | 2234 if (i == len && (capacity == -1 || pos < capacity)) |
2118 buffer[pos++] = '\0'; | 2235 buffer[pos++] = '\0'; |
2119 return pos; | 2236 return pos; |
2120 } | 2237 } |
2121 | 2238 |
2122 | 2239 |
2123 int String::WriteAscii(char* buffer, int start, int length) const { | 2240 int String::WriteAscii(char* buffer, int start, int length) const { |
| 2241 ENTER_V8; |
2124 if (IsDeadCheck("v8::String::WriteAscii()")) return 0; | 2242 if (IsDeadCheck("v8::String::WriteAscii()")) return 0; |
2125 LOG_API("String::WriteAscii"); | 2243 LOG_API("String::WriteAscii"); |
2126 ASSERT(start >= 0 && length >= -1); | 2244 ASSERT(start >= 0 && length >= -1); |
2127 i::Handle<i::String> str = Utils::OpenHandle(this); | 2245 i::Handle<i::String> str = Utils::OpenHandle(this); |
2128 // Flatten the string for efficiency. This applies whether we are | 2246 // Flatten the string for efficiency. This applies whether we are |
2129 // using StringInputBuffer or Get(i) to access the characters. | 2247 // using StringInputBuffer or Get(i) to access the characters. |
2130 str->TryFlattenIfNotFlat(); | 2248 str->TryFlattenIfNotFlat(); |
2131 int end = length; | 2249 int end = length; |
2132 if ( (length == -1) || (length > str->length() - start) ) | 2250 if ( (length == -1) || (length > str->length() - start) ) |
2133 end = str->length() - start; | 2251 end = str->length() - start; |
2134 if (end < 0) return 0; | 2252 if (end < 0) return 0; |
2135 write_input_buffer.Reset(start, *str); | 2253 write_input_buffer.Reset(start, *str); |
2136 int i; | 2254 int i; |
2137 for (i = 0; i < end; i++) { | 2255 for (i = 0; i < end; i++) { |
2138 char c = static_cast<char>(write_input_buffer.GetNext()); | 2256 char c = static_cast<char>(write_input_buffer.GetNext()); |
2139 if (c == '\0') c = ' '; | 2257 if (c == '\0') c = ' '; |
2140 buffer[i] = c; | 2258 buffer[i] = c; |
2141 } | 2259 } |
2142 if (length == -1 || i < length) | 2260 if (length == -1 || i < length) |
2143 buffer[i] = '\0'; | 2261 buffer[i] = '\0'; |
2144 return i; | 2262 return i; |
2145 } | 2263 } |
2146 | 2264 |
2147 | 2265 |
2148 int String::Write(uint16_t* buffer, int start, int length) const { | 2266 int String::Write(uint16_t* buffer, int start, int length) const { |
| 2267 ENTER_V8; |
2149 if (IsDeadCheck("v8::String::Write()")) return 0; | 2268 if (IsDeadCheck("v8::String::Write()")) return 0; |
2150 LOG_API("String::Write"); | 2269 LOG_API("String::Write"); |
2151 ASSERT(start >= 0 && length >= -1); | 2270 ASSERT(start >= 0 && length >= -1); |
2152 i::Handle<i::String> str = Utils::OpenHandle(this); | 2271 i::Handle<i::String> str = Utils::OpenHandle(this); |
2153 // Flatten the string for efficiency. This applies whether we are | 2272 // Flatten the string for efficiency. This applies whether we are |
2154 // using StringInputBuffer or Get(i) to access the characters. | 2273 // using StringInputBuffer or Get(i) to access the characters. |
2155 str->TryFlattenIfNotFlat(); | 2274 str->TryFlattenIfNotFlat(); |
2156 int end = length; | 2275 int end = length; |
2157 if ( (length == -1) || (length > str->length() - start) ) | 2276 if ( (length == -1) || (length > str->length() - start) ) |
2158 end = str->length() - start; | 2277 end = str->length() - start; |
2159 if (end < 0) return 0; | 2278 if (end < 0) return 0; |
2160 write_input_buffer.Reset(start, *str); | 2279 write_input_buffer.Reset(start, *str); |
2161 int i; | 2280 int i; |
2162 for (i = 0; i < end; i++) | 2281 for (i = 0; i < end; i++) |
2163 buffer[i] = write_input_buffer.GetNext(); | 2282 buffer[i] = write_input_buffer.GetNext(); |
2164 if (length == -1 || i < length) | 2283 if (length == -1 || i < length) |
2165 buffer[i] = '\0'; | 2284 buffer[i] = '\0'; |
2166 return i; | 2285 return i; |
2167 } | 2286 } |
2168 | 2287 |
2169 | 2288 |
2170 bool v8::String::IsExternal() const { | 2289 bool v8::String::IsExternal() const { |
| 2290 ENTER_V8; |
2171 EnsureInitialized("v8::String::IsExternal()"); | 2291 EnsureInitialized("v8::String::IsExternal()"); |
2172 i::Handle<i::String> str = Utils::OpenHandle(this); | 2292 i::Handle<i::String> str = Utils::OpenHandle(this); |
2173 return i::StringShape(*str).IsExternalTwoByte(); | 2293 return i::StringShape(*str).IsExternalTwoByte(); |
2174 } | 2294 } |
2175 | 2295 |
2176 | 2296 |
2177 bool v8::String::IsExternalAscii() const { | 2297 bool v8::String::IsExternalAscii() const { |
| 2298 ENTER_V8; |
2178 EnsureInitialized("v8::String::IsExternalAscii()"); | 2299 EnsureInitialized("v8::String::IsExternalAscii()"); |
2179 i::Handle<i::String> str = Utils::OpenHandle(this); | 2300 i::Handle<i::String> str = Utils::OpenHandle(this); |
2180 return i::StringShape(*str).IsExternalAscii(); | 2301 return i::StringShape(*str).IsExternalAscii(); |
2181 } | 2302 } |
2182 | 2303 |
2183 | 2304 |
2184 v8::String::ExternalStringResource* | 2305 v8::String::ExternalStringResource* |
2185 v8::String::GetExternalStringResource() const { | 2306 v8::String::GetExternalStringResource() const { |
| 2307 ENTER_V8; |
2186 EnsureInitialized("v8::String::GetExternalStringResource()"); | 2308 EnsureInitialized("v8::String::GetExternalStringResource()"); |
2187 i::Handle<i::String> str = Utils::OpenHandle(this); | 2309 i::Handle<i::String> str = Utils::OpenHandle(this); |
2188 ASSERT(str->IsExternalTwoByteString()); | 2310 ASSERT(str->IsExternalTwoByteString()); |
2189 void* resource = i::Handle<i::ExternalTwoByteString>::cast(str)->resource(); | 2311 void* resource = i::Handle<i::ExternalTwoByteString>::cast(str)->resource(); |
2190 return reinterpret_cast<ExternalStringResource*>(resource); | 2312 return reinterpret_cast<ExternalStringResource*>(resource); |
2191 } | 2313 } |
2192 | 2314 |
2193 | 2315 |
2194 v8::String::ExternalAsciiStringResource* | 2316 v8::String::ExternalAsciiStringResource* |
2195 v8::String::GetExternalAsciiStringResource() const { | 2317 v8::String::GetExternalAsciiStringResource() const { |
| 2318 ENTER_V8; |
2196 EnsureInitialized("v8::String::GetExternalAsciiStringResource()"); | 2319 EnsureInitialized("v8::String::GetExternalAsciiStringResource()"); |
2197 i::Handle<i::String> str = Utils::OpenHandle(this); | 2320 i::Handle<i::String> str = Utils::OpenHandle(this); |
2198 ASSERT(str->IsExternalAsciiString()); | 2321 ASSERT(str->IsExternalAsciiString()); |
2199 void* resource = i::Handle<i::ExternalAsciiString>::cast(str)->resource(); | 2322 void* resource = i::Handle<i::ExternalAsciiString>::cast(str)->resource(); |
2200 return reinterpret_cast<ExternalAsciiStringResource*>(resource); | 2323 return reinterpret_cast<ExternalAsciiStringResource*>(resource); |
2201 } | 2324 } |
2202 | 2325 |
2203 | 2326 |
2204 double Number::Value() const { | 2327 double Number::Value() const { |
| 2328 ENTER_V8; |
2205 if (IsDeadCheck("v8::Number::Value()")) return 0; | 2329 if (IsDeadCheck("v8::Number::Value()")) return 0; |
2206 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2330 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2207 return obj->Number(); | 2331 return obj->Number(); |
2208 } | 2332 } |
2209 | 2333 |
2210 | 2334 |
2211 bool Boolean::Value() const { | 2335 bool Boolean::Value() const { |
| 2336 ENTER_V8; |
2212 if (IsDeadCheck("v8::Boolean::Value()")) return false; | 2337 if (IsDeadCheck("v8::Boolean::Value()")) return false; |
2213 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2338 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2214 return obj->IsTrue(); | 2339 return obj->IsTrue(); |
2215 } | 2340 } |
2216 | 2341 |
2217 | 2342 |
2218 int64_t Integer::Value() const { | 2343 int64_t Integer::Value() const { |
| 2344 ENTER_V8; |
2219 if (IsDeadCheck("v8::Integer::Value()")) return 0; | 2345 if (IsDeadCheck("v8::Integer::Value()")) return 0; |
2220 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2346 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2221 if (obj->IsSmi()) { | 2347 if (obj->IsSmi()) { |
2222 return i::Smi::cast(*obj)->value(); | 2348 return i::Smi::cast(*obj)->value(); |
2223 } else { | 2349 } else { |
2224 return static_cast<int64_t>(obj->Number()); | 2350 return static_cast<int64_t>(obj->Number()); |
2225 } | 2351 } |
2226 } | 2352 } |
2227 | 2353 |
2228 | 2354 |
2229 int32_t Int32::Value() const { | 2355 int32_t Int32::Value() const { |
| 2356 ENTER_V8; |
2230 if (IsDeadCheck("v8::Int32::Value()")) return 0; | 2357 if (IsDeadCheck("v8::Int32::Value()")) return 0; |
2231 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2358 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2232 if (obj->IsSmi()) { | 2359 if (obj->IsSmi()) { |
2233 return i::Smi::cast(*obj)->value(); | 2360 return i::Smi::cast(*obj)->value(); |
2234 } else { | 2361 } else { |
2235 return static_cast<int32_t>(obj->Number()); | 2362 return static_cast<int32_t>(obj->Number()); |
2236 } | 2363 } |
2237 } | 2364 } |
2238 | 2365 |
2239 | 2366 |
2240 int v8::Object::InternalFieldCount() { | 2367 int v8::Object::InternalFieldCount() { |
| 2368 ENTER_V8; |
2241 if (IsDeadCheck("v8::Object::InternalFieldCount()")) return 0; | 2369 if (IsDeadCheck("v8::Object::InternalFieldCount()")) return 0; |
2242 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); | 2370 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
2243 return obj->GetInternalFieldCount(); | 2371 return obj->GetInternalFieldCount(); |
2244 } | 2372 } |
2245 | 2373 |
2246 | 2374 |
2247 Local<Value> v8::Object::GetInternalField(int index) { | 2375 Local<Value> v8::Object::GetInternalField(int index) { |
| 2376 ENTER_V8; |
2248 if (IsDeadCheck("v8::Object::GetInternalField()")) return Local<Value>(); | 2377 if (IsDeadCheck("v8::Object::GetInternalField()")) return Local<Value>(); |
2249 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); | 2378 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
2250 if (!ApiCheck(index < obj->GetInternalFieldCount(), | 2379 if (!ApiCheck(index < obj->GetInternalFieldCount(), |
2251 "v8::Object::GetInternalField()", | 2380 "v8::Object::GetInternalField()", |
2252 "Reading internal field out of bounds")) { | 2381 "Reading internal field out of bounds")) { |
2253 return Local<Value>(); | 2382 return Local<Value>(); |
2254 } | 2383 } |
2255 i::Handle<i::Object> value(obj->GetInternalField(index)); | 2384 i::Handle<i::Object> value(obj->GetInternalField(index)); |
2256 return Utils::ToLocal(value); | 2385 return Utils::ToLocal(value); |
2257 } | 2386 } |
2258 | 2387 |
2259 | 2388 |
2260 void v8::Object::SetInternalField(int index, v8::Handle<Value> value) { | 2389 void v8::Object::SetInternalField(int index, v8::Handle<Value> value) { |
| 2390 ENTER_V8; |
2261 if (IsDeadCheck("v8::Object::SetInternalField()")) return; | 2391 if (IsDeadCheck("v8::Object::SetInternalField()")) return; |
2262 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); | 2392 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
2263 if (!ApiCheck(index < obj->GetInternalFieldCount(), | 2393 if (!ApiCheck(index < obj->GetInternalFieldCount(), |
2264 "v8::Object::SetInternalField()", | 2394 "v8::Object::SetInternalField()", |
2265 "Writing internal field out of bounds")) { | 2395 "Writing internal field out of bounds")) { |
2266 return; | 2396 return; |
2267 } | 2397 } |
2268 i::Handle<i::Object> val = Utils::OpenHandle(*value); | 2398 i::Handle<i::Object> val = Utils::OpenHandle(*value); |
2269 obj->SetInternalField(index, *val); | 2399 obj->SetInternalField(index, *val); |
2270 } | 2400 } |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2367 | 2497 |
2368 if (!ApiCheck(!env.is_null(), | 2498 if (!ApiCheck(!env.is_null(), |
2369 "v8::Context::New()", | 2499 "v8::Context::New()", |
2370 "Could not initialize environment")) | 2500 "Could not initialize environment")) |
2371 return Persistent<Context>(); | 2501 return Persistent<Context>(); |
2372 return Persistent<Context>(Utils::ToLocal(env)); | 2502 return Persistent<Context>(Utils::ToLocal(env)); |
2373 } | 2503 } |
2374 | 2504 |
2375 | 2505 |
2376 void v8::Context::SetSecurityToken(Handle<Value> token) { | 2506 void v8::Context::SetSecurityToken(Handle<Value> token) { |
| 2507 ENTER_V8; |
2377 if (IsDeadCheck("v8::Context::SetSecurityToken()")) return; | 2508 if (IsDeadCheck("v8::Context::SetSecurityToken()")) return; |
2378 i::Handle<i::Context> env = Utils::OpenHandle(this); | 2509 i::Handle<i::Context> env = Utils::OpenHandle(this); |
2379 i::Handle<i::Object> token_handle = Utils::OpenHandle(*token); | 2510 i::Handle<i::Object> token_handle = Utils::OpenHandle(*token); |
2380 env->set_security_token(*token_handle); | 2511 env->set_security_token(*token_handle); |
2381 } | 2512 } |
2382 | 2513 |
2383 | 2514 |
2384 void v8::Context::UseDefaultSecurityToken() { | 2515 void v8::Context::UseDefaultSecurityToken() { |
| 2516 ENTER_V8; |
2385 if (IsDeadCheck("v8::Context::UseDefaultSecurityToken()")) return; | 2517 if (IsDeadCheck("v8::Context::UseDefaultSecurityToken()")) return; |
2386 i::Handle<i::Context> env = Utils::OpenHandle(this); | 2518 i::Handle<i::Context> env = Utils::OpenHandle(this); |
2387 env->set_security_token(env->global()); | 2519 env->set_security_token(env->global()); |
2388 } | 2520 } |
2389 | 2521 |
2390 | 2522 |
2391 Handle<Value> v8::Context::GetSecurityToken() { | 2523 Handle<Value> v8::Context::GetSecurityToken() { |
| 2524 ENTER_V8; |
2392 if (IsDeadCheck("v8::Context::GetSecurityToken()")) return Handle<Value>(); | 2525 if (IsDeadCheck("v8::Context::GetSecurityToken()")) return Handle<Value>(); |
2393 i::Handle<i::Context> env = Utils::OpenHandle(this); | 2526 i::Handle<i::Context> env = Utils::OpenHandle(this); |
2394 i::Object* security_token = env->security_token(); | 2527 i::Object* security_token = env->security_token(); |
2395 i::Handle<i::Object> token_handle(security_token); | 2528 i::Handle<i::Object> token_handle(security_token); |
2396 return Utils::ToLocal(token_handle); | 2529 return Utils::ToLocal(token_handle); |
2397 } | 2530 } |
2398 | 2531 |
2399 | 2532 |
2400 bool Context::HasOutOfMemoryException() { | 2533 bool Context::HasOutOfMemoryException() { |
2401 i::Handle<i::Context> env = Utils::OpenHandle(this); | 2534 i::Handle<i::Context> env = Utils::OpenHandle(this); |
2402 return env->has_out_of_memory(); | 2535 return env->has_out_of_memory(); |
2403 } | 2536 } |
2404 | 2537 |
2405 | 2538 |
2406 bool Context::InContext() { | 2539 bool Context::InContext() { |
2407 return i::Top::context() != NULL; | 2540 return i::Top::context() != NULL; |
2408 } | 2541 } |
2409 | 2542 |
2410 | 2543 |
2411 v8::Local<v8::Context> Context::GetEntered() { | 2544 v8::Local<v8::Context> Context::GetEntered() { |
| 2545 ENTER_V8; |
2412 if (IsDeadCheck("v8::Context::GetEntered()")) return Local<Context>(); | 2546 if (IsDeadCheck("v8::Context::GetEntered()")) return Local<Context>(); |
2413 i::Handle<i::Object> last = thread_local.LastEnteredContext(); | 2547 i::Handle<i::Object> last = thread_local.LastEnteredContext(); |
2414 if (last.is_null()) return Local<Context>(); | 2548 if (last.is_null()) return Local<Context>(); |
2415 i::Handle<i::Context> context = i::Handle<i::Context>::cast(last); | 2549 i::Handle<i::Context> context = i::Handle<i::Context>::cast(last); |
2416 return Utils::ToLocal(context); | 2550 return Utils::ToLocal(context); |
2417 } | 2551 } |
2418 | 2552 |
2419 | 2553 |
2420 v8::Local<v8::Context> Context::GetCurrent() { | 2554 v8::Local<v8::Context> Context::GetCurrent() { |
| 2555 ENTER_V8; |
2421 if (IsDeadCheck("v8::Context::GetCurrent()")) return Local<Context>(); | 2556 if (IsDeadCheck("v8::Context::GetCurrent()")) return Local<Context>(); |
2422 i::Handle<i::Context> context(i::Top::global_context()); | 2557 i::Handle<i::Context> context(i::Top::global_context()); |
2423 return Utils::ToLocal(context); | 2558 return Utils::ToLocal(context); |
2424 } | 2559 } |
2425 | 2560 |
2426 | 2561 |
2427 v8::Local<v8::Object> Context::Global() { | 2562 v8::Local<v8::Object> Context::Global() { |
| 2563 ENTER_V8; |
2428 if (IsDeadCheck("v8::Context::Global()")) return Local<v8::Object>(); | 2564 if (IsDeadCheck("v8::Context::Global()")) return Local<v8::Object>(); |
2429 i::Object** ctx = reinterpret_cast<i::Object**>(this); | 2565 i::Object** ctx = reinterpret_cast<i::Object**>(this); |
2430 i::Handle<i::Context> context = | 2566 i::Handle<i::Context> context = |
2431 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx)); | 2567 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx)); |
2432 i::Handle<i::Object> global(context->global_proxy()); | 2568 i::Handle<i::Object> global(context->global_proxy()); |
2433 return Utils::ToLocal(i::Handle<i::JSObject>::cast(global)); | 2569 return Utils::ToLocal(i::Handle<i::JSObject>::cast(global)); |
2434 } | 2570 } |
2435 | 2571 |
2436 | 2572 |
2437 void Context::DetachGlobal() { | 2573 void Context::DetachGlobal() { |
| 2574 ENTER_V8; |
2438 if (IsDeadCheck("v8::Context::DetachGlobal()")) return; | 2575 if (IsDeadCheck("v8::Context::DetachGlobal()")) return; |
2439 i::Object** ctx = reinterpret_cast<i::Object**>(this); | 2576 i::Object** ctx = reinterpret_cast<i::Object**>(this); |
2440 i::Handle<i::Context> context = | 2577 i::Handle<i::Context> context = |
2441 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx)); | 2578 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx)); |
2442 i::Bootstrapper::DetachGlobal(context); | 2579 i::Bootstrapper::DetachGlobal(context); |
2443 } | 2580 } |
2444 | 2581 |
2445 | 2582 |
2446 Local<v8::Object> ObjectTemplate::NewInstance() { | 2583 Local<v8::Object> ObjectTemplate::NewInstance() { |
| 2584 ENTER_V8; |
2447 ON_BAILOUT("v8::ObjectTemplate::NewInstance()", return Local<v8::Object>()); | 2585 ON_BAILOUT("v8::ObjectTemplate::NewInstance()", return Local<v8::Object>()); |
2448 LOG_API("ObjectTemplate::NewInstance"); | 2586 LOG_API("ObjectTemplate::NewInstance"); |
2449 EXCEPTION_PREAMBLE(); | 2587 EXCEPTION_PREAMBLE(); |
2450 i::Handle<i::Object> obj = | 2588 i::Handle<i::Object> obj = |
2451 i::Execution::InstantiateObject(Utils::OpenHandle(this), | 2589 i::Execution::InstantiateObject(Utils::OpenHandle(this), |
2452 &has_pending_exception); | 2590 &has_pending_exception); |
2453 EXCEPTION_BAILOUT_CHECK(Local<v8::Object>()); | 2591 EXCEPTION_BAILOUT_CHECK(Local<v8::Object>()); |
2454 return Utils::ToLocal(i::Handle<i::JSObject>::cast(obj)); | 2592 return Utils::ToLocal(i::Handle<i::JSObject>::cast(obj)); |
2455 } | 2593 } |
2456 | 2594 |
2457 | 2595 |
2458 Local<v8::Function> FunctionTemplate::GetFunction() { | 2596 Local<v8::Function> FunctionTemplate::GetFunction() { |
| 2597 ENTER_V8; |
2459 ON_BAILOUT("v8::FunctionTemplate::GetFunction()", | 2598 ON_BAILOUT("v8::FunctionTemplate::GetFunction()", |
2460 return Local<v8::Function>()); | 2599 return Local<v8::Function>()); |
2461 LOG_API("FunctionTemplate::GetFunction"); | 2600 LOG_API("FunctionTemplate::GetFunction"); |
2462 EXCEPTION_PREAMBLE(); | 2601 EXCEPTION_PREAMBLE(); |
2463 i::Handle<i::Object> obj = | 2602 i::Handle<i::Object> obj = |
2464 i::Execution::InstantiateFunction(Utils::OpenHandle(this), | 2603 i::Execution::InstantiateFunction(Utils::OpenHandle(this), |
2465 &has_pending_exception); | 2604 &has_pending_exception); |
2466 EXCEPTION_BAILOUT_CHECK(Local<v8::Function>()); | 2605 EXCEPTION_BAILOUT_CHECK(Local<v8::Function>()); |
2467 return Utils::ToLocal(i::Handle<i::JSFunction>::cast(obj)); | 2606 return Utils::ToLocal(i::Handle<i::JSFunction>::cast(obj)); |
2468 } | 2607 } |
2469 | 2608 |
2470 | 2609 |
2471 bool FunctionTemplate::HasInstance(v8::Handle<v8::Value> value) { | 2610 bool FunctionTemplate::HasInstance(v8::Handle<v8::Value> value) { |
| 2611 ENTER_V8; |
2472 ON_BAILOUT("v8::FunctionTemplate::HasInstanceOf()", return false); | 2612 ON_BAILOUT("v8::FunctionTemplate::HasInstanceOf()", return false); |
2473 i::Object* obj = *Utils::OpenHandle(*value); | 2613 i::Object* obj = *Utils::OpenHandle(*value); |
2474 return obj->IsInstanceOf(*Utils::OpenHandle(this)); | 2614 return obj->IsInstanceOf(*Utils::OpenHandle(this)); |
2475 } | 2615 } |
2476 | 2616 |
2477 | 2617 |
2478 static Local<External> ExternalNewImpl(void* data) { | 2618 static Local<External> ExternalNewImpl(void* data) { |
2479 return Utils::ToLocal(i::Factory::NewProxy(static_cast<i::Address>(data))); | 2619 return Utils::ToLocal(i::Factory::NewProxy(static_cast<i::Address>(data))); |
2480 } | 2620 } |
2481 | 2621 |
2482 static void* ExternalValueImpl(i::Handle<i::Object> obj) { | 2622 static void* ExternalValueImpl(i::Handle<i::Object> obj) { |
2483 return reinterpret_cast<void*>(i::Proxy::cast(*obj)->proxy()); | 2623 return reinterpret_cast<void*>(i::Proxy::cast(*obj)->proxy()); |
2484 } | 2624 } |
2485 | 2625 |
2486 | 2626 |
2487 static const intptr_t kAlignedPointerMask = 3; | 2627 static const intptr_t kAlignedPointerMask = 3; |
2488 static const int kAlignedPointerShift = 2; | 2628 static const int kAlignedPointerShift = 2; |
2489 | 2629 |
2490 | 2630 |
2491 Local<Value> v8::External::Wrap(void* data) { | 2631 Local<Value> v8::External::Wrap(void* data) { |
| 2632 ENTER_V8; |
2492 STATIC_ASSERT(sizeof(data) == sizeof(i::Address)); | 2633 STATIC_ASSERT(sizeof(data) == sizeof(i::Address)); |
2493 LOG_API("External::Wrap"); | 2634 LOG_API("External::Wrap"); |
2494 EnsureInitialized("v8::External::Wrap()"); | 2635 EnsureInitialized("v8::External::Wrap()"); |
2495 if ((reinterpret_cast<intptr_t>(data) & kAlignedPointerMask) == 0) { | 2636 if ((reinterpret_cast<intptr_t>(data) & kAlignedPointerMask) == 0) { |
2496 uintptr_t data_ptr = reinterpret_cast<uintptr_t>(data); | 2637 uintptr_t data_ptr = reinterpret_cast<uintptr_t>(data); |
2497 int data_value = static_cast<int>(data_ptr >> kAlignedPointerShift); | 2638 int data_value = static_cast<int>(data_ptr >> kAlignedPointerShift); |
2498 STATIC_ASSERT(sizeof(data_ptr) == sizeof(data_value)); | 2639 STATIC_ASSERT(sizeof(data_ptr) == sizeof(data_value)); |
2499 i::Handle<i::Object> obj(i::Smi::FromInt(data_value)); | 2640 i::Handle<i::Object> obj(i::Smi::FromInt(data_value)); |
2500 return Utils::ToLocal(obj); | 2641 return Utils::ToLocal(obj); |
2501 } | 2642 } |
2502 return ExternalNewImpl(data); | 2643 return ExternalNewImpl(data); |
2503 } | 2644 } |
2504 | 2645 |
2505 | 2646 |
2506 void* v8::External::Unwrap(v8::Handle<v8::Value> value) { | 2647 void* v8::External::Unwrap(v8::Handle<v8::Value> value) { |
| 2648 ENTER_V8; |
2507 if (IsDeadCheck("v8::External::Unwrap()")) return 0; | 2649 if (IsDeadCheck("v8::External::Unwrap()")) return 0; |
2508 i::Handle<i::Object> obj = Utils::OpenHandle(*value); | 2650 i::Handle<i::Object> obj = Utils::OpenHandle(*value); |
2509 if (obj->IsSmi()) { | 2651 if (obj->IsSmi()) { |
2510 // The external value was an aligned pointer. | 2652 // The external value was an aligned pointer. |
2511 uintptr_t result = i::Smi::cast(*obj)->value() << kAlignedPointerShift; | 2653 uintptr_t result = i::Smi::cast(*obj)->value() << kAlignedPointerShift; |
2512 return reinterpret_cast<void*>(result); | 2654 return reinterpret_cast<void*>(result); |
2513 } | 2655 } |
2514 return ExternalValueImpl(obj); | 2656 return ExternalValueImpl(obj); |
2515 } | 2657 } |
2516 | 2658 |
2517 | 2659 |
2518 Local<External> v8::External::New(void* data) { | 2660 Local<External> v8::External::New(void* data) { |
| 2661 ENTER_V8; |
2519 STATIC_ASSERT(sizeof(data) == sizeof(i::Address)); | 2662 STATIC_ASSERT(sizeof(data) == sizeof(i::Address)); |
2520 LOG_API("External::New"); | 2663 LOG_API("External::New"); |
2521 EnsureInitialized("v8::External::New()"); | 2664 EnsureInitialized("v8::External::New()"); |
2522 return ExternalNewImpl(data); | 2665 return ExternalNewImpl(data); |
2523 } | 2666 } |
2524 | 2667 |
2525 | 2668 |
2526 void* External::Value() const { | 2669 void* External::Value() const { |
| 2670 ENTER_V8; |
2527 if (IsDeadCheck("v8::External::Value()")) return 0; | 2671 if (IsDeadCheck("v8::External::Value()")) return 0; |
2528 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2672 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2529 return ExternalValueImpl(obj); | 2673 return ExternalValueImpl(obj); |
2530 } | 2674 } |
2531 | 2675 |
2532 | 2676 |
2533 Local<String> v8::String::Empty() { | 2677 Local<String> v8::String::Empty() { |
| 2678 ENTER_V8; |
2534 EnsureInitialized("v8::String::Empty()"); | 2679 EnsureInitialized("v8::String::Empty()"); |
2535 LOG_API("String::Empty()"); | 2680 LOG_API("String::Empty()"); |
2536 return Utils::ToLocal(i::Factory::empty_symbol()); | 2681 return Utils::ToLocal(i::Factory::empty_symbol()); |
2537 } | 2682 } |
2538 | 2683 |
2539 | 2684 |
2540 Local<String> v8::String::New(const char* data, int length) { | 2685 Local<String> v8::String::New(const char* data, int length) { |
2541 ENTER_V8; | 2686 ENTER_V8; |
2542 EnsureInitialized("v8::String::New()"); | 2687 EnsureInitialized("v8::String::New()"); |
2543 LOG_API("String::New(char)"); | 2688 LOG_API("String::New(char)"); |
2544 if (length == 0) return Empty(); | 2689 if (length == 0) return Empty(); |
2545 if (length == -1) length = strlen(data); | 2690 if (length == -1) length = strlen(data); |
2546 i::Handle<i::String> result = | 2691 i::Handle<i::String> result = |
2547 i::Factory::NewStringFromUtf8(i::Vector<const char>(data, length)); | 2692 i::Factory::NewStringFromUtf8(i::Vector<const char>(data, length)); |
2548 return Utils::ToLocal(result); | 2693 return Utils::ToLocal(result); |
2549 } | 2694 } |
2550 | 2695 |
2551 | 2696 |
2552 Local<String> v8::String::NewUndetectable(const char* data, int length) { | 2697 Local<String> v8::String::NewUndetectable(const char* data, int length) { |
| 2698 ENTER_V8; |
2553 EnsureInitialized("v8::String::NewUndetectable()"); | 2699 EnsureInitialized("v8::String::NewUndetectable()"); |
2554 LOG_API("String::NewUndetectable(char)"); | 2700 LOG_API("String::NewUndetectable(char)"); |
2555 if (length == -1) length = strlen(data); | 2701 if (length == -1) length = strlen(data); |
2556 i::Handle<i::String> result = | 2702 i::Handle<i::String> result = |
2557 i::Factory::NewStringFromUtf8(i::Vector<const char>(data, length)); | 2703 i::Factory::NewStringFromUtf8(i::Vector<const char>(data, length)); |
2558 result->MarkAsUndetectable(); | 2704 result->MarkAsUndetectable(); |
2559 return Utils::ToLocal(result); | 2705 return Utils::ToLocal(result); |
2560 } | 2706 } |
2561 | 2707 |
2562 | 2708 |
2563 static int TwoByteStringLength(const uint16_t* data) { | 2709 static int TwoByteStringLength(const uint16_t* data) { |
2564 int length = 0; | 2710 int length = 0; |
2565 while (data[length] != '\0') length++; | 2711 while (data[length] != '\0') length++; |
2566 return length; | 2712 return length; |
2567 } | 2713 } |
2568 | 2714 |
2569 | 2715 |
2570 Local<String> v8::String::New(const uint16_t* data, int length) { | 2716 Local<String> v8::String::New(const uint16_t* data, int length) { |
| 2717 ENTER_V8; |
2571 EnsureInitialized("v8::String::New()"); | 2718 EnsureInitialized("v8::String::New()"); |
2572 LOG_API("String::New(uint16_)"); | 2719 LOG_API("String::New(uint16_)"); |
2573 if (length == 0) return Empty(); | 2720 if (length == 0) return Empty(); |
2574 if (length == -1) length = TwoByteStringLength(data); | 2721 if (length == -1) length = TwoByteStringLength(data); |
2575 i::Handle<i::String> result = | 2722 i::Handle<i::String> result = |
2576 i::Factory::NewStringFromTwoByte(i::Vector<const uint16_t>(data, length)); | 2723 i::Factory::NewStringFromTwoByte(i::Vector<const uint16_t>(data, length)); |
2577 return Utils::ToLocal(result); | 2724 return Utils::ToLocal(result); |
2578 } | 2725 } |
2579 | 2726 |
2580 | 2727 |
2581 Local<String> v8::String::NewUndetectable(const uint16_t* data, int length) { | 2728 Local<String> v8::String::NewUndetectable(const uint16_t* data, int length) { |
| 2729 ENTER_V8; |
2582 EnsureInitialized("v8::String::NewUndetectable()"); | 2730 EnsureInitialized("v8::String::NewUndetectable()"); |
2583 LOG_API("String::NewUndetectable(uint16_)"); | 2731 LOG_API("String::NewUndetectable(uint16_)"); |
2584 if (length == -1) length = TwoByteStringLength(data); | 2732 if (length == -1) length = TwoByteStringLength(data); |
2585 i::Handle<i::String> result = | 2733 i::Handle<i::String> result = |
2586 i::Factory::NewStringFromTwoByte(i::Vector<const uint16_t>(data, length)); | 2734 i::Factory::NewStringFromTwoByte(i::Vector<const uint16_t>(data, length)); |
2587 result->MarkAsUndetectable(); | 2735 result->MarkAsUndetectable(); |
2588 return Utils::ToLocal(result); | 2736 return Utils::ToLocal(result); |
2589 } | 2737 } |
2590 | 2738 |
2591 | 2739 |
2592 i::Handle<i::String> NewExternalStringHandle( | 2740 i::Handle<i::String> NewExternalStringHandle( |
2593 v8::String::ExternalStringResource* resource) { | 2741 v8::String::ExternalStringResource* resource) { |
2594 i::Handle<i::String> result = | 2742 i::Handle<i::String> result = |
2595 i::Factory::NewExternalStringFromTwoByte(resource); | 2743 i::Factory::NewExternalStringFromTwoByte(resource); |
2596 return result; | 2744 return result; |
2597 } | 2745 } |
2598 | 2746 |
2599 | 2747 |
2600 i::Handle<i::String> NewExternalAsciiStringHandle( | 2748 i::Handle<i::String> NewExternalAsciiStringHandle( |
2601 v8::String::ExternalAsciiStringResource* resource) { | 2749 v8::String::ExternalAsciiStringResource* resource) { |
2602 i::Handle<i::String> result = | 2750 i::Handle<i::String> result = |
2603 i::Factory::NewExternalStringFromAscii(resource); | 2751 i::Factory::NewExternalStringFromAscii(resource); |
2604 return result; | 2752 return result; |
2605 } | 2753 } |
2606 | 2754 |
2607 | 2755 |
2608 static void DisposeExternalString(v8::Persistent<v8::Value> obj, | 2756 static void DisposeExternalString(v8::Persistent<v8::Value> obj, |
2609 void* parameter) { | 2757 void* parameter) { |
| 2758 ENTER_V8; |
2610 i::ExternalTwoByteString* str = | 2759 i::ExternalTwoByteString* str = |
2611 i::ExternalTwoByteString::cast(*Utils::OpenHandle(*obj)); | 2760 i::ExternalTwoByteString::cast(*Utils::OpenHandle(*obj)); |
2612 | 2761 |
2613 // External symbols are deleted when they are pruned out of the symbol | 2762 // External symbols are deleted when they are pruned out of the symbol |
2614 // table. Generally external symbols are not registered with the weak handle | 2763 // table. Generally external symbols are not registered with the weak handle |
2615 // callbacks unless they are upgraded to a symbol after being externalized. | 2764 // callbacks unless they are upgraded to a symbol after being externalized. |
2616 if (!str->IsSymbol()) { | 2765 if (!str->IsSymbol()) { |
2617 v8::String::ExternalStringResource* resource = | 2766 v8::String::ExternalStringResource* resource = |
2618 reinterpret_cast<v8::String::ExternalStringResource*>(parameter); | 2767 reinterpret_cast<v8::String::ExternalStringResource*>(parameter); |
2619 if (resource != NULL) { | 2768 if (resource != NULL) { |
2620 const size_t total_size = resource->length() * sizeof(*resource->data()); | 2769 const size_t total_size = resource->length() * sizeof(*resource->data()); |
2621 i::Counters::total_external_string_memory.Decrement(total_size); | 2770 i::Counters::total_external_string_memory.Decrement(total_size); |
2622 | 2771 |
2623 // The object will continue to live in the JavaScript heap until the | 2772 // The object will continue to live in the JavaScript heap until the |
2624 // handle is entirely cleaned out by the next GC. For example the | 2773 // handle is entirely cleaned out by the next GC. For example the |
2625 // destructor for the resource below could bring it back to life again. | 2774 // destructor for the resource below could bring it back to life again. |
2626 // Which is why we make sure to not have a dangling pointer here. | 2775 // Which is why we make sure to not have a dangling pointer here. |
2627 str->set_resource(NULL); | 2776 str->set_resource(NULL); |
2628 delete resource; | 2777 delete resource; |
2629 } | 2778 } |
2630 } | 2779 } |
2631 | 2780 |
2632 // In any case we do not need this handle any longer. | 2781 // In any case we do not need this handle any longer. |
2633 obj.Dispose(); | 2782 obj.Dispose(); |
2634 } | 2783 } |
2635 | 2784 |
2636 | 2785 |
2637 static void DisposeExternalAsciiString(v8::Persistent<v8::Value> obj, | 2786 static void DisposeExternalAsciiString(v8::Persistent<v8::Value> obj, |
2638 void* parameter) { | 2787 void* parameter) { |
| 2788 ENTER_V8; |
2639 i::ExternalAsciiString* str = | 2789 i::ExternalAsciiString* str = |
2640 i::ExternalAsciiString::cast(*Utils::OpenHandle(*obj)); | 2790 i::ExternalAsciiString::cast(*Utils::OpenHandle(*obj)); |
2641 | 2791 |
2642 // External symbols are deleted when they are pruned out of the symbol | 2792 // External symbols are deleted when they are pruned out of the symbol |
2643 // table. Generally external symbols are not registered with the weak handle | 2793 // table. Generally external symbols are not registered with the weak handle |
2644 // callbacks unless they are upgraded to a symbol after being externalized. | 2794 // callbacks unless they are upgraded to a symbol after being externalized. |
2645 if (!str->IsSymbol()) { | 2795 if (!str->IsSymbol()) { |
2646 v8::String::ExternalAsciiStringResource* resource = | 2796 v8::String::ExternalAsciiStringResource* resource = |
2647 reinterpret_cast<v8::String::ExternalAsciiStringResource*>(parameter); | 2797 reinterpret_cast<v8::String::ExternalAsciiStringResource*>(parameter); |
2648 if (resource != NULL) { | 2798 if (resource != NULL) { |
2649 const size_t total_size = resource->length() * sizeof(*resource->data()); | 2799 const size_t total_size = resource->length() * sizeof(*resource->data()); |
2650 i::Counters::total_external_string_memory.Decrement(total_size); | 2800 i::Counters::total_external_string_memory.Decrement(total_size); |
2651 | 2801 |
2652 // The object will continue to live in the JavaScript heap until the | 2802 // The object will continue to live in the JavaScript heap until the |
2653 // handle is entirely cleaned out by the next GC. For example the | 2803 // handle is entirely cleaned out by the next GC. For example the |
2654 // destructor for the resource below could bring it back to life again. | 2804 // destructor for the resource below could bring it back to life again. |
2655 // Which is why we make sure to not have a dangling pointer here. | 2805 // Which is why we make sure to not have a dangling pointer here. |
2656 str->set_resource(NULL); | 2806 str->set_resource(NULL); |
2657 delete resource; | 2807 delete resource; |
2658 } | 2808 } |
2659 } | 2809 } |
2660 | 2810 |
2661 // In any case we do not need this handle any longer. | 2811 // In any case we do not need this handle any longer. |
2662 obj.Dispose(); | 2812 obj.Dispose(); |
2663 } | 2813 } |
2664 | 2814 |
2665 | 2815 |
2666 Local<String> v8::String::NewExternal( | 2816 Local<String> v8::String::NewExternal( |
2667 v8::String::ExternalStringResource* resource) { | 2817 v8::String::ExternalStringResource* resource) { |
| 2818 ENTER_V8; |
2668 EnsureInitialized("v8::String::NewExternal()"); | 2819 EnsureInitialized("v8::String::NewExternal()"); |
2669 LOG_API("String::NewExternal"); | 2820 LOG_API("String::NewExternal"); |
2670 const size_t total_size = resource->length() * sizeof(*resource->data()); | 2821 const size_t total_size = resource->length() * sizeof(*resource->data()); |
2671 i::Counters::total_external_string_memory.Increment(total_size); | 2822 i::Counters::total_external_string_memory.Increment(total_size); |
2672 i::Handle<i::String> result = NewExternalStringHandle(resource); | 2823 i::Handle<i::String> result = NewExternalStringHandle(resource); |
2673 i::Handle<i::Object> handle = i::GlobalHandles::Create(*result); | 2824 i::Handle<i::Object> handle = i::GlobalHandles::Create(*result); |
2674 i::GlobalHandles::MakeWeak(handle.location(), | 2825 i::GlobalHandles::MakeWeak(handle.location(), |
2675 resource, | 2826 resource, |
2676 &DisposeExternalString); | 2827 &DisposeExternalString); |
2677 return Utils::ToLocal(result); | 2828 return Utils::ToLocal(result); |
2678 } | 2829 } |
2679 | 2830 |
2680 | 2831 |
2681 bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) { | 2832 bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) { |
| 2833 ENTER_V8; |
2682 if (IsDeadCheck("v8::String::MakeExternal()")) return false; | 2834 if (IsDeadCheck("v8::String::MakeExternal()")) return false; |
2683 if (this->IsExternal()) return false; // Already an external string. | 2835 if (this->IsExternal()) return false; // Already an external string. |
2684 i::Handle <i::String> obj = Utils::OpenHandle(this); | 2836 i::Handle <i::String> obj = Utils::OpenHandle(this); |
2685 bool result = obj->MakeExternal(resource); | 2837 bool result = obj->MakeExternal(resource); |
2686 if (result && !obj->IsSymbol()) { | 2838 if (result && !obj->IsSymbol()) { |
2687 // Operation was successful and the string is not a symbol. In this case | 2839 // Operation was successful and the string is not a symbol. In this case |
2688 // we need to make sure that the we call the destructor for the external | 2840 // we need to make sure that the we call the destructor for the external |
2689 // resource when no strong references to the string remain. | 2841 // resource when no strong references to the string remain. |
2690 i::Handle<i::Object> handle = i::GlobalHandles::Create(*obj); | 2842 i::Handle<i::Object> handle = i::GlobalHandles::Create(*obj); |
2691 i::GlobalHandles::MakeWeak(handle.location(), | 2843 i::GlobalHandles::MakeWeak(handle.location(), |
2692 resource, | 2844 resource, |
2693 &DisposeExternalString); | 2845 &DisposeExternalString); |
2694 } | 2846 } |
2695 return result; | 2847 return result; |
2696 } | 2848 } |
2697 | 2849 |
2698 | 2850 |
2699 Local<String> v8::String::NewExternal( | 2851 Local<String> v8::String::NewExternal( |
2700 v8::String::ExternalAsciiStringResource* resource) { | 2852 v8::String::ExternalAsciiStringResource* resource) { |
| 2853 ENTER_V8; |
2701 EnsureInitialized("v8::String::NewExternal()"); | 2854 EnsureInitialized("v8::String::NewExternal()"); |
2702 LOG_API("String::NewExternal"); | 2855 LOG_API("String::NewExternal"); |
2703 const size_t total_size = resource->length() * sizeof(*resource->data()); | 2856 const size_t total_size = resource->length() * sizeof(*resource->data()); |
2704 i::Counters::total_external_string_memory.Increment(total_size); | 2857 i::Counters::total_external_string_memory.Increment(total_size); |
2705 i::Handle<i::String> result = NewExternalAsciiStringHandle(resource); | 2858 i::Handle<i::String> result = NewExternalAsciiStringHandle(resource); |
2706 i::Handle<i::Object> handle = i::GlobalHandles::Create(*result); | 2859 i::Handle<i::Object> handle = i::GlobalHandles::Create(*result); |
2707 i::GlobalHandles::MakeWeak(handle.location(), | 2860 i::GlobalHandles::MakeWeak(handle.location(), |
2708 resource, | 2861 resource, |
2709 &DisposeExternalAsciiString); | 2862 &DisposeExternalAsciiString); |
2710 return Utils::ToLocal(result); | 2863 return Utils::ToLocal(result); |
2711 } | 2864 } |
2712 | 2865 |
2713 | 2866 |
2714 bool v8::String::MakeExternal( | 2867 bool v8::String::MakeExternal( |
2715 v8::String::ExternalAsciiStringResource* resource) { | 2868 v8::String::ExternalAsciiStringResource* resource) { |
| 2869 ENTER_V8; |
2716 if (IsDeadCheck("v8::String::MakeExternal()")) return false; | 2870 if (IsDeadCheck("v8::String::MakeExternal()")) return false; |
2717 if (this->IsExternal()) return false; // Already an external string. | 2871 if (this->IsExternal()) return false; // Already an external string. |
2718 i::Handle <i::String> obj = Utils::OpenHandle(this); | 2872 i::Handle <i::String> obj = Utils::OpenHandle(this); |
2719 bool result = obj->MakeExternal(resource); | 2873 bool result = obj->MakeExternal(resource); |
2720 if (result && !obj->IsSymbol()) { | 2874 if (result && !obj->IsSymbol()) { |
2721 // Operation was successful and the string is not a symbol. In this case | 2875 // Operation was successful and the string is not a symbol. In this case |
2722 // we need to make sure that the we call the destructor for the external | 2876 // we need to make sure that the we call the destructor for the external |
2723 // resource when no strong references to the string remain. | 2877 // resource when no strong references to the string remain. |
2724 i::Handle<i::Object> handle = i::GlobalHandles::Create(*obj); | 2878 i::Handle<i::Object> handle = i::GlobalHandles::Create(*obj); |
2725 i::GlobalHandles::MakeWeak(handle.location(), | 2879 i::GlobalHandles::MakeWeak(handle.location(), |
2726 resource, | 2880 resource, |
2727 &DisposeExternalAsciiString); | 2881 &DisposeExternalAsciiString); |
2728 } | 2882 } |
2729 return result; | 2883 return result; |
2730 } | 2884 } |
2731 | 2885 |
2732 | 2886 |
2733 Local<v8::Object> v8::Object::New() { | 2887 Local<v8::Object> v8::Object::New() { |
| 2888 ENTER_V8; |
2734 EnsureInitialized("v8::Object::New()"); | 2889 EnsureInitialized("v8::Object::New()"); |
2735 LOG_API("Object::New"); | 2890 LOG_API("Object::New"); |
2736 i::Handle<i::JSObject> obj = | 2891 i::Handle<i::JSObject> obj = |
2737 i::Factory::NewJSObject(i::Top::object_function()); | 2892 i::Factory::NewJSObject(i::Top::object_function()); |
2738 return Utils::ToLocal(obj); | 2893 return Utils::ToLocal(obj); |
2739 } | 2894 } |
2740 | 2895 |
2741 | 2896 |
2742 Local<v8::Value> v8::Date::New(double time) { | 2897 Local<v8::Value> v8::Date::New(double time) { |
| 2898 ENTER_V8; |
2743 EnsureInitialized("v8::Date::New()"); | 2899 EnsureInitialized("v8::Date::New()"); |
2744 LOG_API("Date::New"); | 2900 LOG_API("Date::New"); |
2745 EXCEPTION_PREAMBLE(); | 2901 EXCEPTION_PREAMBLE(); |
2746 i::Handle<i::Object> obj = | 2902 i::Handle<i::Object> obj = |
2747 i::Execution::NewDate(time, &has_pending_exception); | 2903 i::Execution::NewDate(time, &has_pending_exception); |
2748 EXCEPTION_BAILOUT_CHECK(Local<v8::Value>()); | 2904 EXCEPTION_BAILOUT_CHECK(Local<v8::Value>()); |
2749 return Utils::ToLocal(obj); | 2905 return Utils::ToLocal(obj); |
2750 } | 2906 } |
2751 | 2907 |
2752 | 2908 |
2753 double v8::Date::NumberValue() const { | 2909 double v8::Date::NumberValue() const { |
| 2910 ENTER_V8; |
2754 if (IsDeadCheck("v8::Date::NumberValue()")) return 0; | 2911 if (IsDeadCheck("v8::Date::NumberValue()")) return 0; |
2755 LOG_API("Date::NumberValue"); | 2912 LOG_API("Date::NumberValue"); |
2756 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2913 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2757 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); | 2914 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); |
2758 return jsvalue->value()->Number(); | 2915 return jsvalue->value()->Number(); |
2759 } | 2916 } |
2760 | 2917 |
2761 | 2918 |
2762 Local<v8::Array> v8::Array::New(int length) { | 2919 Local<v8::Array> v8::Array::New(int length) { |
| 2920 ENTER_V8; |
2763 EnsureInitialized("v8::Array::New()"); | 2921 EnsureInitialized("v8::Array::New()"); |
2764 LOG_API("Array::New"); | 2922 LOG_API("Array::New"); |
2765 i::Handle<i::JSArray> obj = i::Factory::NewJSArray(length); | 2923 i::Handle<i::JSArray> obj = i::Factory::NewJSArray(length); |
2766 return Utils::ToLocal(obj); | 2924 return Utils::ToLocal(obj); |
2767 } | 2925 } |
2768 | 2926 |
2769 | 2927 |
2770 uint32_t v8::Array::Length() const { | 2928 uint32_t v8::Array::Length() const { |
| 2929 ENTER_V8; |
2771 if (IsDeadCheck("v8::Array::Length()")) return 0; | 2930 if (IsDeadCheck("v8::Array::Length()")) return 0; |
2772 i::Handle<i::JSArray> obj = Utils::OpenHandle(this); | 2931 i::Handle<i::JSArray> obj = Utils::OpenHandle(this); |
2773 i::Object* length = obj->length(); | 2932 i::Object* length = obj->length(); |
2774 if (length->IsSmi()) { | 2933 if (length->IsSmi()) { |
2775 return i::Smi::cast(length)->value(); | 2934 return i::Smi::cast(length)->value(); |
2776 } else { | 2935 } else { |
2777 return static_cast<uint32_t>(length->Number()); | 2936 return static_cast<uint32_t>(length->Number()); |
2778 } | 2937 } |
2779 } | 2938 } |
2780 | 2939 |
2781 | 2940 |
2782 Local<String> v8::String::NewSymbol(const char* data, int length) { | 2941 Local<String> v8::String::NewSymbol(const char* data, int length) { |
| 2942 ENTER_V8; |
2783 EnsureInitialized("v8::String::NewSymbol()"); | 2943 EnsureInitialized("v8::String::NewSymbol()"); |
2784 LOG_API("String::NewSymbol(char)"); | 2944 LOG_API("String::NewSymbol(char)"); |
2785 if (length == -1) length = strlen(data); | 2945 if (length == -1) length = strlen(data); |
2786 i::Handle<i::String> result = | 2946 i::Handle<i::String> result = |
2787 i::Factory::LookupSymbol(i::Vector<const char>(data, length)); | 2947 i::Factory::LookupSymbol(i::Vector<const char>(data, length)); |
2788 return Utils::ToLocal(result); | 2948 return Utils::ToLocal(result); |
2789 } | 2949 } |
2790 | 2950 |
2791 | 2951 |
2792 Local<Number> v8::Number::New(double value) { | 2952 Local<Number> v8::Number::New(double value) { |
| 2953 ENTER_V8; |
2793 EnsureInitialized("v8::Number::New()"); | 2954 EnsureInitialized("v8::Number::New()"); |
2794 i::Handle<i::Object> result = i::Factory::NewNumber(value); | 2955 i::Handle<i::Object> result = i::Factory::NewNumber(value); |
2795 return Utils::NumberToLocal(result); | 2956 return Utils::NumberToLocal(result); |
2796 } | 2957 } |
2797 | 2958 |
2798 | 2959 |
2799 Local<Integer> v8::Integer::New(int32_t value) { | 2960 Local<Integer> v8::Integer::New(int32_t value) { |
| 2961 ENTER_V8; |
2800 EnsureInitialized("v8::Integer::New()"); | 2962 EnsureInitialized("v8::Integer::New()"); |
2801 if (i::Smi::IsValid(value)) { | 2963 if (i::Smi::IsValid(value)) { |
2802 return Utils::IntegerToLocal(i::Handle<i::Object>(i::Smi::FromInt(value))); | 2964 return Utils::IntegerToLocal(i::Handle<i::Object>(i::Smi::FromInt(value))); |
2803 } | 2965 } |
2804 i::Handle<i::Object> result = i::Factory::NewNumber(value); | 2966 i::Handle<i::Object> result = i::Factory::NewNumber(value); |
2805 return Utils::IntegerToLocal(result); | 2967 return Utils::IntegerToLocal(result); |
2806 } | 2968 } |
2807 | 2969 |
2808 | 2970 |
2809 void V8::IgnoreOutOfMemoryException() { | 2971 void V8::IgnoreOutOfMemoryException() { |
2810 thread_local.SetIgnoreOutOfMemory(true); | 2972 thread_local.SetIgnoreOutOfMemory(true); |
2811 } | 2973 } |
2812 | 2974 |
2813 | 2975 |
2814 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) { | 2976 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) { |
| 2977 ENTER_V8; |
2815 EnsureInitialized("v8::V8::AddMessageListener()"); | 2978 EnsureInitialized("v8::V8::AddMessageListener()"); |
2816 ON_BAILOUT("v8::V8::AddMessageListener()", return false); | 2979 ON_BAILOUT("v8::V8::AddMessageListener()", return false); |
2817 HandleScope scope; | 2980 HandleScope scope; |
2818 NeanderArray listeners(i::Factory::message_listeners()); | 2981 NeanderArray listeners(i::Factory::message_listeners()); |
2819 NeanderObject obj(2); | 2982 NeanderObject obj(2); |
2820 obj.set(0, *i::Factory::NewProxy(FUNCTION_ADDR(that))); | 2983 obj.set(0, *i::Factory::NewProxy(FUNCTION_ADDR(that))); |
2821 obj.set(1, data.IsEmpty() ? | 2984 obj.set(1, data.IsEmpty() ? |
2822 i::Heap::undefined_value() : | 2985 i::Heap::undefined_value() : |
2823 *Utils::OpenHandle(*data)); | 2986 *Utils::OpenHandle(*data)); |
2824 listeners.add(obj.value()); | 2987 listeners.add(obj.value()); |
2825 return true; | 2988 return true; |
2826 } | 2989 } |
2827 | 2990 |
2828 | 2991 |
2829 void V8::RemoveMessageListeners(MessageCallback that) { | 2992 void V8::RemoveMessageListeners(MessageCallback that) { |
| 2993 ENTER_V8; |
2830 EnsureInitialized("v8::V8::RemoveMessageListener()"); | 2994 EnsureInitialized("v8::V8::RemoveMessageListener()"); |
2831 ON_BAILOUT("v8::V8::RemoveMessageListeners()", return); | 2995 ON_BAILOUT("v8::V8::RemoveMessageListeners()", return); |
2832 HandleScope scope; | 2996 HandleScope scope; |
2833 NeanderArray listeners(i::Factory::message_listeners()); | 2997 NeanderArray listeners(i::Factory::message_listeners()); |
2834 for (int i = 0; i < listeners.length(); i++) { | 2998 for (int i = 0; i < listeners.length(); i++) { |
2835 if (listeners.get(i)->IsUndefined()) continue; // skip deleted ones | 2999 if (listeners.get(i)->IsUndefined()) continue; // skip deleted ones |
2836 | 3000 |
2837 NeanderObject listener(i::JSObject::cast(listeners.get(i))); | 3001 NeanderObject listener(i::JSObject::cast(listeners.get(i))); |
2838 i::Handle<i::Proxy> callback_obj(i::Proxy::cast(listener.get(0))); | 3002 i::Handle<i::Proxy> callback_obj(i::Proxy::cast(listener.get(0))); |
2839 if (callback_obj->proxy() == FUNCTION_ADDR(that)) { | 3003 if (callback_obj->proxy() == FUNCTION_ADDR(that)) { |
2840 listeners.set(i, i::Heap::undefined_value()); | 3004 listeners.set(i, i::Heap::undefined_value()); |
2841 } | 3005 } |
2842 } | 3006 } |
2843 } | 3007 } |
2844 | 3008 |
2845 | 3009 |
2846 void V8::SetCounterFunction(CounterLookupCallback callback) { | 3010 void V8::SetCounterFunction(CounterLookupCallback callback) { |
| 3011 ENTER_V8; |
2847 if (IsDeadCheck("v8::V8::SetCounterFunction()")) return; | 3012 if (IsDeadCheck("v8::V8::SetCounterFunction()")) return; |
2848 i::StatsTable::SetCounterFunction(callback); | 3013 i::StatsTable::SetCounterFunction(callback); |
2849 } | 3014 } |
2850 | 3015 |
2851 void V8::SetCreateHistogramFunction(CreateHistogramCallback callback) { | 3016 void V8::SetCreateHistogramFunction(CreateHistogramCallback callback) { |
| 3017 ENTER_V8; |
2852 if (IsDeadCheck("v8::V8::SetCreateHistogramFunction()")) return; | 3018 if (IsDeadCheck("v8::V8::SetCreateHistogramFunction()")) return; |
2853 i::StatsTable::SetCreateHistogramFunction(callback); | 3019 i::StatsTable::SetCreateHistogramFunction(callback); |
2854 } | 3020 } |
2855 | 3021 |
2856 void V8::SetAddHistogramSampleFunction(AddHistogramSampleCallback callback) { | 3022 void V8::SetAddHistogramSampleFunction(AddHistogramSampleCallback callback) { |
| 3023 ENTER_V8; |
2857 if (IsDeadCheck("v8::V8::SetAddHistogramSampleFunction()")) return; | 3024 if (IsDeadCheck("v8::V8::SetAddHistogramSampleFunction()")) return; |
2858 i::StatsTable::SetAddHistogramSampleFunction(callback); | 3025 i::StatsTable::SetAddHistogramSampleFunction(callback); |
2859 } | 3026 } |
2860 | 3027 |
2861 void V8::EnableSlidingStateWindow() { | 3028 void V8::EnableSlidingStateWindow() { |
| 3029 ENTER_V8; |
2862 if (IsDeadCheck("v8::V8::EnableSlidingStateWindow()")) return; | 3030 if (IsDeadCheck("v8::V8::EnableSlidingStateWindow()")) return; |
2863 i::Logger::EnableSlidingStateWindow(); | 3031 i::Logger::EnableSlidingStateWindow(); |
2864 } | 3032 } |
2865 | 3033 |
2866 | 3034 |
2867 void V8::SetFailedAccessCheckCallbackFunction( | 3035 void V8::SetFailedAccessCheckCallbackFunction( |
2868 FailedAccessCheckCallback callback) { | 3036 FailedAccessCheckCallback callback) { |
| 3037 ENTER_V8; |
2869 if (IsDeadCheck("v8::V8::SetFailedAccessCheckCallbackFunction()")) return; | 3038 if (IsDeadCheck("v8::V8::SetFailedAccessCheckCallbackFunction()")) return; |
2870 i::Top::SetFailedAccessCheckCallback(callback); | 3039 i::Top::SetFailedAccessCheckCallback(callback); |
2871 } | 3040 } |
2872 | 3041 |
2873 | 3042 |
2874 void V8::AddObjectGroup(Persistent<Value>* objects, size_t length) { | 3043 void V8::AddObjectGroup(Persistent<Value>* objects, size_t length) { |
| 3044 ENTER_V8; |
2875 if (IsDeadCheck("v8::V8::AddObjectGroup()")) return; | 3045 if (IsDeadCheck("v8::V8::AddObjectGroup()")) return; |
2876 STATIC_ASSERT(sizeof(Persistent<Value>) == sizeof(i::Object**)); | 3046 STATIC_ASSERT(sizeof(Persistent<Value>) == sizeof(i::Object**)); |
2877 i::GlobalHandles::AddGroup(reinterpret_cast<i::Object***>(objects), length); | 3047 i::GlobalHandles::AddGroup(reinterpret_cast<i::Object***>(objects), length); |
2878 } | 3048 } |
2879 | 3049 |
2880 | 3050 |
2881 int V8::AdjustAmountOfExternalAllocatedMemory(int change_in_bytes) { | 3051 int V8::AdjustAmountOfExternalAllocatedMemory(int change_in_bytes) { |
| 3052 ENTER_V8; |
2882 if (IsDeadCheck("v8::V8::AdjustAmountOfExternalAllocatedMemory()")) return 0; | 3053 if (IsDeadCheck("v8::V8::AdjustAmountOfExternalAllocatedMemory()")) return 0; |
2883 return i::Heap::AdjustAmountOfExternalAllocatedMemory(change_in_bytes); | 3054 return i::Heap::AdjustAmountOfExternalAllocatedMemory(change_in_bytes); |
2884 } | 3055 } |
2885 | 3056 |
2886 | 3057 |
2887 void V8::SetGlobalGCPrologueCallback(GCCallback callback) { | 3058 void V8::SetGlobalGCPrologueCallback(GCCallback callback) { |
| 3059 ENTER_V8; |
2888 if (IsDeadCheck("v8::V8::SetGlobalGCPrologueCallback()")) return; | 3060 if (IsDeadCheck("v8::V8::SetGlobalGCPrologueCallback()")) return; |
2889 i::Heap::SetGlobalGCPrologueCallback(callback); | 3061 i::Heap::SetGlobalGCPrologueCallback(callback); |
2890 } | 3062 } |
2891 | 3063 |
2892 | 3064 |
2893 void V8::SetGlobalGCEpilogueCallback(GCCallback callback) { | 3065 void V8::SetGlobalGCEpilogueCallback(GCCallback callback) { |
| 3066 ENTER_V8; |
2894 if (IsDeadCheck("v8::V8::SetGlobalGCEpilogueCallback()")) return; | 3067 if (IsDeadCheck("v8::V8::SetGlobalGCEpilogueCallback()")) return; |
2895 i::Heap::SetGlobalGCEpilogueCallback(callback); | 3068 i::Heap::SetGlobalGCEpilogueCallback(callback); |
2896 } | 3069 } |
2897 | 3070 |
2898 | 3071 |
2899 void V8::PauseProfiler() { | 3072 void V8::PauseProfiler() { |
2900 #ifdef ENABLE_LOGGING_AND_PROFILING | 3073 #ifdef ENABLE_LOGGING_AND_PROFILING |
2901 i::Logger::PauseProfiler(); | 3074 i::Logger::PauseProfiler(); |
2902 #endif | 3075 #endif |
2903 } | 3076 } |
2904 | 3077 |
2905 void V8::ResumeProfiler() { | 3078 void V8::ResumeProfiler() { |
2906 #ifdef ENABLE_LOGGING_AND_PROFILING | 3079 #ifdef ENABLE_LOGGING_AND_PROFILING |
2907 i::Logger::ResumeProfiler(); | 3080 i::Logger::ResumeProfiler(); |
2908 #endif | 3081 #endif |
2909 } | 3082 } |
2910 | 3083 |
2911 | 3084 |
2912 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) { | 3085 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) { |
| 3086 ENTER_V8; |
2913 EnsureInitialized("v8::String::Utf8Value::Utf8Value()"); | 3087 EnsureInitialized("v8::String::Utf8Value::Utf8Value()"); |
2914 if (obj.IsEmpty()) { | 3088 if (obj.IsEmpty()) { |
2915 str_ = NULL; | 3089 str_ = NULL; |
2916 length_ = 0; | 3090 length_ = 0; |
2917 return; | 3091 return; |
2918 } | 3092 } |
2919 HandleScope scope; | 3093 HandleScope scope; |
2920 TryCatch try_catch; | 3094 TryCatch try_catch; |
2921 Handle<String> str = obj->ToString(); | 3095 Handle<String> str = obj->ToString(); |
2922 if (str.IsEmpty()) { | 3096 if (str.IsEmpty()) { |
2923 str_ = NULL; | 3097 str_ = NULL; |
2924 length_ = 0; | 3098 length_ = 0; |
2925 } else { | 3099 } else { |
2926 length_ = str->Utf8Length(); | 3100 length_ = str->Utf8Length(); |
2927 str_ = i::NewArray<char>(length_ + 1); | 3101 str_ = i::NewArray<char>(length_ + 1); |
2928 str->WriteUtf8(str_); | 3102 str->WriteUtf8(str_); |
2929 } | 3103 } |
2930 } | 3104 } |
2931 | 3105 |
2932 | 3106 |
2933 String::Utf8Value::~Utf8Value() { | 3107 String::Utf8Value::~Utf8Value() { |
2934 i::DeleteArray(str_); | 3108 i::DeleteArray(str_); |
2935 } | 3109 } |
2936 | 3110 |
2937 | 3111 |
2938 String::AsciiValue::AsciiValue(v8::Handle<v8::Value> obj) { | 3112 String::AsciiValue::AsciiValue(v8::Handle<v8::Value> obj) { |
| 3113 ENTER_V8; |
2939 EnsureInitialized("v8::String::AsciiValue::AsciiValue()"); | 3114 EnsureInitialized("v8::String::AsciiValue::AsciiValue()"); |
2940 if (obj.IsEmpty()) { | 3115 if (obj.IsEmpty()) { |
2941 str_ = NULL; | 3116 str_ = NULL; |
2942 length_ = 0; | 3117 length_ = 0; |
2943 return; | 3118 return; |
2944 } | 3119 } |
2945 HandleScope scope; | 3120 HandleScope scope; |
2946 TryCatch try_catch; | 3121 TryCatch try_catch; |
2947 Handle<String> str = obj->ToString(); | 3122 Handle<String> str = obj->ToString(); |
2948 if (str.IsEmpty()) { | 3123 if (str.IsEmpty()) { |
2949 str_ = NULL; | 3124 str_ = NULL; |
2950 length_ = 0; | 3125 length_ = 0; |
2951 } else { | 3126 } else { |
2952 length_ = str->Length(); | 3127 length_ = str->Length(); |
2953 str_ = i::NewArray<char>(length_ + 1); | 3128 str_ = i::NewArray<char>(length_ + 1); |
2954 str->WriteAscii(str_); | 3129 str->WriteAscii(str_); |
2955 } | 3130 } |
2956 } | 3131 } |
2957 | 3132 |
2958 | 3133 |
2959 String::AsciiValue::~AsciiValue() { | 3134 String::AsciiValue::~AsciiValue() { |
2960 i::DeleteArray(str_); | 3135 i::DeleteArray(str_); |
2961 } | 3136 } |
2962 | 3137 |
2963 | 3138 |
2964 String::Value::Value(v8::Handle<v8::Value> obj) { | 3139 String::Value::Value(v8::Handle<v8::Value> obj) { |
| 3140 ENTER_V8; |
2965 EnsureInitialized("v8::String::Value::Value()"); | 3141 EnsureInitialized("v8::String::Value::Value()"); |
2966 if (obj.IsEmpty()) { | 3142 if (obj.IsEmpty()) { |
2967 str_ = NULL; | 3143 str_ = NULL; |
2968 length_ = 0; | 3144 length_ = 0; |
2969 return; | 3145 return; |
2970 } | 3146 } |
2971 HandleScope scope; | 3147 HandleScope scope; |
2972 TryCatch try_catch; | 3148 TryCatch try_catch; |
2973 Handle<String> str = obj->ToString(); | 3149 Handle<String> str = obj->ToString(); |
2974 if (str.IsEmpty()) { | 3150 if (str.IsEmpty()) { |
2975 str_ = NULL; | 3151 str_ = NULL; |
2976 length_ = 0; | 3152 length_ = 0; |
2977 } else { | 3153 } else { |
2978 length_ = str->Length(); | 3154 length_ = str->Length(); |
2979 str_ = i::NewArray<uint16_t>(length_ + 1); | 3155 str_ = i::NewArray<uint16_t>(length_ + 1); |
2980 str->Write(str_); | 3156 str->Write(str_); |
2981 } | 3157 } |
2982 } | 3158 } |
2983 | 3159 |
2984 | 3160 |
2985 String::Value::~Value() { | 3161 String::Value::~Value() { |
2986 i::DeleteArray(str_); | 3162 i::DeleteArray(str_); |
2987 } | 3163 } |
2988 | 3164 |
2989 Local<Value> Exception::RangeError(v8::Handle<v8::String> raw_message) { | 3165 Local<Value> Exception::RangeError(v8::Handle<v8::String> raw_message) { |
| 3166 ENTER_V8; |
2990 LOG_API("RangeError"); | 3167 LOG_API("RangeError"); |
2991 ON_BAILOUT("v8::Exception::RangeError()", return Local<Value>()); | 3168 ON_BAILOUT("v8::Exception::RangeError()", return Local<Value>()); |
2992 i::Object* error; | 3169 i::Object* error; |
2993 { | 3170 { |
2994 HandleScope scope; | 3171 HandleScope scope; |
2995 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); | 3172 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); |
2996 i::Handle<i::Object> result = i::Factory::NewRangeError(message); | 3173 i::Handle<i::Object> result = i::Factory::NewRangeError(message); |
2997 error = *result; | 3174 error = *result; |
2998 } | 3175 } |
2999 i::Handle<i::Object> result(error); | 3176 i::Handle<i::Object> result(error); |
3000 return Utils::ToLocal(result); | 3177 return Utils::ToLocal(result); |
3001 } | 3178 } |
3002 | 3179 |
3003 Local<Value> Exception::ReferenceError(v8::Handle<v8::String> raw_message) { | 3180 Local<Value> Exception::ReferenceError(v8::Handle<v8::String> raw_message) { |
| 3181 ENTER_V8; |
3004 LOG_API("ReferenceError"); | 3182 LOG_API("ReferenceError"); |
3005 ON_BAILOUT("v8::Exception::ReferenceError()", return Local<Value>()); | 3183 ON_BAILOUT("v8::Exception::ReferenceError()", return Local<Value>()); |
3006 i::Object* error; | 3184 i::Object* error; |
3007 { | 3185 { |
3008 HandleScope scope; | 3186 HandleScope scope; |
3009 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); | 3187 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); |
3010 i::Handle<i::Object> result = i::Factory::NewReferenceError(message); | 3188 i::Handle<i::Object> result = i::Factory::NewReferenceError(message); |
3011 error = *result; | 3189 error = *result; |
3012 } | 3190 } |
3013 i::Handle<i::Object> result(error); | 3191 i::Handle<i::Object> result(error); |
3014 return Utils::ToLocal(result); | 3192 return Utils::ToLocal(result); |
3015 } | 3193 } |
3016 | 3194 |
3017 Local<Value> Exception::SyntaxError(v8::Handle<v8::String> raw_message) { | 3195 Local<Value> Exception::SyntaxError(v8::Handle<v8::String> raw_message) { |
| 3196 ENTER_V8; |
3018 LOG_API("SyntaxError"); | 3197 LOG_API("SyntaxError"); |
3019 ON_BAILOUT("v8::Exception::SyntaxError()", return Local<Value>()); | 3198 ON_BAILOUT("v8::Exception::SyntaxError()", return Local<Value>()); |
3020 i::Object* error; | 3199 i::Object* error; |
3021 { | 3200 { |
3022 HandleScope scope; | 3201 HandleScope scope; |
3023 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); | 3202 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); |
3024 i::Handle<i::Object> result = i::Factory::NewSyntaxError(message); | 3203 i::Handle<i::Object> result = i::Factory::NewSyntaxError(message); |
3025 error = *result; | 3204 error = *result; |
3026 } | 3205 } |
3027 i::Handle<i::Object> result(error); | 3206 i::Handle<i::Object> result(error); |
3028 return Utils::ToLocal(result); | 3207 return Utils::ToLocal(result); |
3029 } | 3208 } |
3030 | 3209 |
3031 Local<Value> Exception::TypeError(v8::Handle<v8::String> raw_message) { | 3210 Local<Value> Exception::TypeError(v8::Handle<v8::String> raw_message) { |
| 3211 ENTER_V8; |
3032 LOG_API("TypeError"); | 3212 LOG_API("TypeError"); |
3033 ON_BAILOUT("v8::Exception::TypeError()", return Local<Value>()); | 3213 ON_BAILOUT("v8::Exception::TypeError()", return Local<Value>()); |
3034 i::Object* error; | 3214 i::Object* error; |
3035 { | 3215 { |
3036 HandleScope scope; | 3216 HandleScope scope; |
3037 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); | 3217 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); |
3038 i::Handle<i::Object> result = i::Factory::NewTypeError(message); | 3218 i::Handle<i::Object> result = i::Factory::NewTypeError(message); |
3039 error = *result; | 3219 error = *result; |
3040 } | 3220 } |
3041 i::Handle<i::Object> result(error); | 3221 i::Handle<i::Object> result(error); |
3042 return Utils::ToLocal(result); | 3222 return Utils::ToLocal(result); |
3043 } | 3223 } |
3044 | 3224 |
3045 Local<Value> Exception::Error(v8::Handle<v8::String> raw_message) { | 3225 Local<Value> Exception::Error(v8::Handle<v8::String> raw_message) { |
| 3226 ENTER_V8; |
3046 LOG_API("Error"); | 3227 LOG_API("Error"); |
3047 ON_BAILOUT("v8::Exception::Error()", return Local<Value>()); | 3228 ON_BAILOUT("v8::Exception::Error()", return Local<Value>()); |
3048 i::Object* error; | 3229 i::Object* error; |
3049 { | 3230 { |
3050 HandleScope scope; | 3231 HandleScope scope; |
3051 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); | 3232 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); |
3052 i::Handle<i::Object> result = i::Factory::NewError(message); | 3233 i::Handle<i::Object> result = i::Factory::NewError(message); |
3053 error = *result; | 3234 error = *result; |
3054 } | 3235 } |
3055 i::Handle<i::Object> result(error); | 3236 i::Handle<i::Object> result(error); |
3056 return Utils::ToLocal(result); | 3237 return Utils::ToLocal(result); |
3057 } | 3238 } |
3058 | 3239 |
3059 | 3240 |
3060 // --- D e b u g S u p p o r t --- | 3241 // --- D e b u g S u p p o r t --- |
3061 | 3242 |
3062 | 3243 |
3063 bool Debug::SetDebugEventListener(DebugEventCallback that, Handle<Value> data) { | 3244 bool Debug::SetDebugEventListener(DebugEventCallback that, Handle<Value> data) { |
| 3245 ENTER_V8; |
3064 EnsureInitialized("v8::Debug::SetDebugEventListener()"); | 3246 EnsureInitialized("v8::Debug::SetDebugEventListener()"); |
3065 ON_BAILOUT("v8::Debug::SetDebugEventListener()", return false); | 3247 ON_BAILOUT("v8::Debug::SetDebugEventListener()", return false); |
3066 HandleScope scope; | 3248 HandleScope scope; |
3067 i::Handle<i::Object> proxy = i::Factory::undefined_value(); | 3249 i::Handle<i::Object> proxy = i::Factory::undefined_value(); |
3068 if (that != NULL) { | 3250 if (that != NULL) { |
3069 proxy = i::Factory::NewProxy(FUNCTION_ADDR(that)); | 3251 proxy = i::Factory::NewProxy(FUNCTION_ADDR(that)); |
3070 } | 3252 } |
3071 i::Debugger::SetEventListener(proxy, Utils::OpenHandle(*data)); | 3253 i::Debugger::SetEventListener(proxy, Utils::OpenHandle(*data)); |
3072 return true; | 3254 return true; |
3073 } | 3255 } |
3074 | 3256 |
3075 | 3257 |
3076 bool Debug::SetDebugEventListener(v8::Handle<v8::Object> that, | 3258 bool Debug::SetDebugEventListener(v8::Handle<v8::Object> that, |
3077 Handle<Value> data) { | 3259 Handle<Value> data) { |
| 3260 ENTER_V8; |
3078 ON_BAILOUT("v8::Debug::SetDebugEventListener()", return false); | 3261 ON_BAILOUT("v8::Debug::SetDebugEventListener()", return false); |
3079 i::Debugger::SetEventListener(Utils::OpenHandle(*that), | 3262 i::Debugger::SetEventListener(Utils::OpenHandle(*that), |
3080 Utils::OpenHandle(*data)); | 3263 Utils::OpenHandle(*data)); |
3081 return true; | 3264 return true; |
3082 } | 3265 } |
3083 | 3266 |
3084 | 3267 |
3085 void Debug::DebugBreak() { | 3268 void Debug::DebugBreak() { |
3086 if (!i::V8::HasBeenSetup()) return; | 3269 if (!i::V8::HasBeenSetup()) return; |
3087 i::StackGuard::DebugBreak(); | 3270 i::StackGuard::DebugBreak(); |
3088 } | 3271 } |
3089 | 3272 |
3090 | 3273 |
3091 void Debug::SetMessageHandler(v8::DebugMessageHandler handler, void* data, | 3274 void Debug::SetMessageHandler(v8::DebugMessageHandler handler, void* data, |
3092 bool message_handler_thread) { | 3275 bool message_handler_thread) { |
| 3276 ENTER_V8; |
3093 EnsureInitialized("v8::Debug::SetMessageHandler"); | 3277 EnsureInitialized("v8::Debug::SetMessageHandler"); |
3094 i::Debugger::SetMessageHandler(handler, data, message_handler_thread); | 3278 i::Debugger::SetMessageHandler(handler, data, message_handler_thread); |
3095 } | 3279 } |
3096 | 3280 |
3097 | 3281 |
3098 void Debug::SendCommand(const uint16_t* command, int length) { | 3282 void Debug::SendCommand(const uint16_t* command, int length) { |
3099 if (!i::V8::HasBeenSetup()) return; | 3283 if (!i::V8::HasBeenSetup()) return; |
3100 i::Debugger::ProcessCommand(i::Vector<const uint16_t>(command, length)); | 3284 i::Debugger::ProcessCommand(i::Vector<const uint16_t>(command, length)); |
3101 } | 3285 } |
3102 | 3286 |
3103 | 3287 |
3104 void Debug::SetHostDispatchHandler(v8::DebugHostDispatchHandler handler, | 3288 void Debug::SetHostDispatchHandler(v8::DebugHostDispatchHandler handler, |
3105 void* data) { | 3289 void* data) { |
| 3290 ENTER_V8; |
3106 EnsureInitialized("v8::Debug::SetHostDispatchHandler"); | 3291 EnsureInitialized("v8::Debug::SetHostDispatchHandler"); |
3107 i::Debugger::SetHostDispatchHandler(handler, data); | 3292 i::Debugger::SetHostDispatchHandler(handler, data); |
3108 } | 3293 } |
3109 | 3294 |
3110 | 3295 |
3111 void Debug::SendHostDispatch(void* dispatch) { | 3296 void Debug::SendHostDispatch(void* dispatch) { |
3112 if (!i::V8::HasBeenSetup()) return; | 3297 if (!i::V8::HasBeenSetup()) return; |
3113 i::Debugger::ProcessHostDispatch(dispatch); | 3298 i::Debugger::ProcessHostDispatch(dispatch); |
3114 } | 3299 } |
3115 | 3300 |
3116 | 3301 |
3117 Handle<Value> Debug::Call(v8::Handle<v8::Function> fun, | 3302 Handle<Value> Debug::Call(v8::Handle<v8::Function> fun, |
3118 v8::Handle<v8::Value> data) { | 3303 v8::Handle<v8::Value> data) { |
| 3304 ENTER_V8; |
3119 if (!i::V8::HasBeenSetup()) return Handle<Value>(); | 3305 if (!i::V8::HasBeenSetup()) return Handle<Value>(); |
3120 ON_BAILOUT("v8::Debug::Call()", return Handle<Value>()); | 3306 ON_BAILOUT("v8::Debug::Call()", return Handle<Value>()); |
3121 i::Handle<i::Object> result; | 3307 i::Handle<i::Object> result; |
3122 EXCEPTION_PREAMBLE(); | 3308 EXCEPTION_PREAMBLE(); |
3123 if (data.IsEmpty()) { | 3309 if (data.IsEmpty()) { |
3124 result = i::Debugger::Call(Utils::OpenHandle(*fun), | 3310 result = i::Debugger::Call(Utils::OpenHandle(*fun), |
3125 i::Factory::undefined_value(), | 3311 i::Factory::undefined_value(), |
3126 &has_pending_exception); | 3312 &has_pending_exception); |
3127 } else { | 3313 } else { |
3128 result = i::Debugger::Call(Utils::OpenHandle(*fun), | 3314 result = i::Debugger::Call(Utils::OpenHandle(*fun), |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3213 reinterpret_cast<HandleScopeImplementer*>(storage); | 3399 reinterpret_cast<HandleScopeImplementer*>(storage); |
3214 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); | 3400 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); |
3215 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = | 3401 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = |
3216 &thread_local->handle_scope_data_; | 3402 &thread_local->handle_scope_data_; |
3217 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); | 3403 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); |
3218 | 3404 |
3219 return storage + ArchiveSpacePerThread(); | 3405 return storage + ArchiveSpacePerThread(); |
3220 } | 3406 } |
3221 | 3407 |
3222 } } // namespace v8::internal | 3408 } } // namespace v8::internal |
OLD | NEW |