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

Side by Side Diff: src/api.cc

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

Powered by Google App Engine
This is Rietveld 408576698