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

Side by Side Diff: src/api.cc

Issue 6730031: Get rid of more TLS fetches in API implementation. (Closed)
Patch Set: Created 9 years, 9 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
« 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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "version.h" 48 #include "version.h"
49 #include "vm-state-inl.h" 49 #include "vm-state-inl.h"
50 50
51 #include "../include/v8-profiler.h" 51 #include "../include/v8-profiler.h"
52 #include "../include/v8-testing.h" 52 #include "../include/v8-testing.h"
53 53
54 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr)) 54 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr))
55 55
56 // TODO(isolates): avoid repeated TLS reads in function prologues. 56 // TODO(isolates): avoid repeated TLS reads in function prologues.
57 #ifdef ENABLE_VMSTATE_TRACKING 57 #ifdef ENABLE_VMSTATE_TRACKING
58 #define ENTER_V8 \ 58 #define ENTER_V8(isolate) \
59 ASSERT(i::Isolate::Current()->IsInitialized()); \ 59 ASSERT((isolate)->IsInitialized()); \
60 i::VMState __state__(i::Isolate::Current(), i::OTHER) 60 i::VMState __state__((isolate), i::OTHER)
61 #define LEAVE_V8 \ 61 #define LEAVE_V8(isolate) \
62 i::VMState __state__(i::Isolate::Current(), i::EXTERNAL) 62 i::VMState __state__((isolate), i::EXTERNAL)
63 #else 63 #else
64 #define ENTER_V8 ((void) 0) 64 #define ENTER_V8(isolate) ((void) 0)
65 #define LEAVE_V8 ((void) 0) 65 #define LEAVE_V8(isolate) ((void) 0)
66 #endif 66 #endif
67 67
68 namespace v8 { 68 namespace v8 {
69 69
70 #define ON_BAILOUT(isolate, location, code) \ 70 #define ON_BAILOUT(isolate, location, code) \
71 if (IsDeadCheck(isolate, location) || \ 71 if (IsDeadCheck(isolate, location) || \
72 v8::V8::IsExecutionTerminating()) { \ 72 v8::V8::IsExecutionTerminating()) { \
73 code; \ 73 code; \
74 UNREACHABLE(); \ 74 UNREACHABLE(); \
75 } 75 }
76 76
77 77
78 #define EXCEPTION_PREAMBLE() \ 78 #define EXCEPTION_PREAMBLE(isolate) \
79 i::Isolate::Current()->handle_scope_implementer()->IncrementCallDepth(); \ 79 (isolate)->handle_scope_implementer()->IncrementCallDepth(); \
80 ASSERT(!i::Isolate::Current()->external_caught_exception()); \ 80 ASSERT(!(isolate)->external_caught_exception()); \
81 bool has_pending_exception = false 81 bool has_pending_exception = false
82 82
83 83
84 #define EXCEPTION_BAILOUT_CHECK(value) \ 84 #define EXCEPTION_BAILOUT_CHECK(isolate, value) \
85 do { \ 85 do { \
86 i::HandleScopeImplementer* handle_scope_implementer = \ 86 i::HandleScopeImplementer* handle_scope_implementer = \
87 isolate->handle_scope_implementer(); \ 87 (isolate)->handle_scope_implementer(); \
88 handle_scope_implementer->DecrementCallDepth(); \ 88 handle_scope_implementer->DecrementCallDepth(); \
89 if (has_pending_exception) { \ 89 if (has_pending_exception) { \
90 if (handle_scope_implementer->CallDepthIsZero() && \ 90 if (handle_scope_implementer->CallDepthIsZero() && \
91 i::Isolate::Current()->is_out_of_memory()) { \ 91 (isolate)->is_out_of_memory()) { \
92 if (!handle_scope_implementer->ignore_out_of_memory()) \ 92 if (!handle_scope_implementer->ignore_out_of_memory()) \
93 i::V8::FatalProcessOutOfMemory(NULL); \ 93 i::V8::FatalProcessOutOfMemory(NULL); \
94 } \ 94 } \
95 bool call_depth_is_zero = handle_scope_implementer->CallDepthIsZero(); \ 95 bool call_depth_is_zero = handle_scope_implementer->CallDepthIsZero(); \
96 i::Isolate::Current()->OptionalRescheduleException(call_depth_is_zero); \ 96 (isolate)->OptionalRescheduleException(call_depth_is_zero); \
97 return value; \ 97 return value; \
98 } \ 98 } \
99 } while (false) 99 } while (false)
100 100
101 // TODO(isolates): Add a parameter to this macro for an isolate. 101 // TODO(isolates): Add a parameter to this macro for an isolate.
102 102
103 #define API_ENTRY_CHECK(msg) \ 103 #define API_ENTRY_CHECK(msg) \
104 do { \ 104 do { \
105 if (v8::Locker::IsActive()) { \ 105 if (v8::Locker::IsActive()) { \
106 ApiCheck(i::Isolate::Current()->thread_manager()-> \ 106 ApiCheck(i::Isolate::Current()->thread_manager()-> \
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 intptr_t memory_allocator_capacity; 184 intptr_t memory_allocator_capacity;
185 heap_stats.memory_allocator_capacity = &memory_allocator_capacity; 185 heap_stats.memory_allocator_capacity = &memory_allocator_capacity;
186 int objects_per_type[LAST_TYPE + 1] = {0}; 186 int objects_per_type[LAST_TYPE + 1] = {0};
187 heap_stats.objects_per_type = objects_per_type; 187 heap_stats.objects_per_type = objects_per_type;
188 int size_per_type[LAST_TYPE + 1] = {0}; 188 int size_per_type[LAST_TYPE + 1] = {0};
189 heap_stats.size_per_type = size_per_type; 189 heap_stats.size_per_type = size_per_type;
190 int os_error; 190 int os_error;
191 heap_stats.os_error = &os_error; 191 heap_stats.os_error = &os_error;
192 int end_marker; 192 int end_marker;
193 heap_stats.end_marker = &end_marker; 193 heap_stats.end_marker = &end_marker;
194 HEAP->RecordStats(&heap_stats, take_snapshot); 194 i::Isolate* isolate = i::Isolate::Current();
195 isolate->heap()->RecordStats(&heap_stats, take_snapshot);
195 i::V8::SetFatalError(); 196 i::V8::SetFatalError();
196 FatalErrorCallback callback = GetFatalErrorHandler(); 197 FatalErrorCallback callback = GetFatalErrorHandler();
197 { 198 {
198 LEAVE_V8; 199 LEAVE_V8(isolate);
199 callback(location, "Allocation failed - process out of memory"); 200 callback(location, "Allocation failed - process out of memory");
200 } 201 }
201 // If the callback returns, we stop execution. 202 // If the callback returns, we stop execution.
202 UNREACHABLE(); 203 UNREACHABLE();
203 } 204 }
204 205
205 206
206 bool Utils::ReportApiFailure(const char* location, const char* message) { 207 bool Utils::ReportApiFailure(const char* location, const char* message) {
207 FatalErrorCallback callback = GetFatalErrorHandler(); 208 FatalErrorCallback callback = GetFatalErrorHandler();
208 callback(location, message); 209 callback(location, message);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 276
276 static inline bool EnsureInitializedForIsolate(i::Isolate* isolate, 277 static inline bool EnsureInitializedForIsolate(i::Isolate* isolate,
277 const char* location) { 278 const char* location) {
278 if (IsDeadCheck(isolate, location)) return false; 279 if (IsDeadCheck(isolate, location)) return false;
279 if (isolate != NULL) { 280 if (isolate != NULL) {
280 if (isolate->IsInitialized()) return true; 281 if (isolate->IsInitialized()) return true;
281 } 282 }
282 return ApiCheck(InitializeHelper(), location, "Error initializing V8"); 283 return ApiCheck(InitializeHelper(), location, "Error initializing V8");
283 } 284 }
284 285
285 static inline bool EnsureInitialized(const char* location) {
286 i::Isolate* isolate = i::Isolate::UncheckedCurrent();
287 return EnsureInitializedForIsolate(isolate, location);
288 }
289
290 // Some initializing API functions are called early and may be 286 // Some initializing API functions are called early and may be
291 // called on a thread different from static initializer thread. 287 // called on a thread different from static initializer thread.
292 // If Isolate API is used, Isolate::Enter() will initialize TLS so 288 // If Isolate API is used, Isolate::Enter() will initialize TLS so
293 // Isolate::Current() works. If it's a legacy case, then the thread 289 // Isolate::Current() works. If it's a legacy case, then the thread
294 // may not have TLS initialized yet. However, in initializing APIs it 290 // may not have TLS initialized yet. However, in initializing APIs it
295 // may be too early to call EnsureInitialized() - some pre-init 291 // may be too early to call EnsureInitialized() - some pre-init
296 // parameters still have to be configured. 292 // parameters still have to be configured.
297 static inline i::Isolate* EnterIsolateIfNeeded() { 293 static inline i::Isolate* EnterIsolateIfNeeded() {
298 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); 294 i::Isolate* isolate = i::Isolate::UncheckedCurrent();
299 if (isolate != NULL) 295 if (isolate != NULL)
(...skipping 13 matching lines...) Expand all
313 309
314 #ifdef DEBUG 310 #ifdef DEBUG
315 void ImplementationUtilities::ZapHandleRange(i::Object** begin, 311 void ImplementationUtilities::ZapHandleRange(i::Object** begin,
316 i::Object** end) { 312 i::Object** end) {
317 i::HandleScope::ZapRange(begin, end); 313 i::HandleScope::ZapRange(begin, end);
318 } 314 }
319 #endif 315 #endif
320 316
321 317
322 v8::Handle<v8::Primitive> ImplementationUtilities::Undefined() { 318 v8::Handle<v8::Primitive> ImplementationUtilities::Undefined() {
323 if (!EnsureInitialized("v8::Undefined()")) return v8::Handle<v8::Primitive>(); 319 i::Isolate* isolate = i::Isolate::Current();
324 return v8::Handle<Primitive>(ToApi<Primitive>(FACTORY->undefined_value())); 320 if (!EnsureInitializedForIsolate(isolate, "v8::Undefined()")) {
321 return v8::Handle<v8::Primitive>();
322 }
323 return v8::Handle<Primitive>(ToApi<Primitive>(
324 isolate->factory()->undefined_value()));
325 } 325 }
326 326
327 327
328 v8::Handle<v8::Primitive> ImplementationUtilities::Null() { 328 v8::Handle<v8::Primitive> ImplementationUtilities::Null() {
329 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); 329 i::Isolate* isolate = i::Isolate::UncheckedCurrent();
330 if (!EnsureInitializedForIsolate(isolate, "v8::Null()")) 330 if (!EnsureInitializedForIsolate(isolate, "v8::Null()"))
331 return v8::Handle<v8::Primitive>(); 331 return v8::Handle<v8::Primitive>();
332 return v8::Handle<Primitive>( 332 return v8::Handle<Primitive>(
333 ToApi<Primitive>(isolate->factory()->null_value())); 333 ToApi<Primitive>(isolate->factory()->null_value()));
334 } 334 }
335 335
336 336
337 v8::Handle<v8::Boolean> ImplementationUtilities::True() { 337 v8::Handle<v8::Boolean> ImplementationUtilities::True() {
338 if (!EnsureInitialized("v8::True()")) return v8::Handle<v8::Boolean>(); 338 i::Isolate* isolate = i::Isolate::Current();
339 return v8::Handle<v8::Boolean>(ToApi<Boolean>(FACTORY->true_value())); 339 if (!EnsureInitializedForIsolate(isolate, "v8::True()")) {
340 return v8::Handle<v8::Boolean>();
341 }
342 return v8::Handle<v8::Boolean>(ToApi<Boolean>(
343 isolate->factory()->true_value()));
340 } 344 }
341 345
342 346
343 v8::Handle<v8::Boolean> ImplementationUtilities::False() { 347 v8::Handle<v8::Boolean> ImplementationUtilities::False() {
344 if (!EnsureInitialized("v8::False()")) return v8::Handle<v8::Boolean>(); 348 i::Isolate* isolate = i::Isolate::Current();
345 return v8::Handle<v8::Boolean>(ToApi<Boolean>(FACTORY->false_value())); 349 if (!EnsureInitializedForIsolate(isolate, "v8::False()")) {
350 return v8::Handle<v8::Boolean>();
351 }
352 return v8::Handle<v8::Boolean>(ToApi<Boolean>(
353 isolate->factory()->false_value()));
346 } 354 }
347 355
348 void V8::SetFlagsFromString(const char* str, int length) { 356 void V8::SetFlagsFromString(const char* str, int length) {
349 i::FlagList::SetFlagsFromString(str, length); 357 i::FlagList::SetFlagsFromString(str, length);
350 } 358 }
351 359
352 360
353 void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) { 361 void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) {
354 i::FlagList::SetFlagsFromCommandLine(argc, argv, remove_flags); 362 i::FlagList::SetFlagsFromCommandLine(argc, argv, remove_flags);
355 } 363 }
356 364
357 365
358 v8::Handle<Value> ThrowException(v8::Handle<v8::Value> value) { 366 v8::Handle<Value> ThrowException(v8::Handle<v8::Value> value) {
359 i::Isolate* isolate = i::Isolate::Current(); 367 i::Isolate* isolate = i::Isolate::Current();
360 if (IsDeadCheck(isolate, "v8::ThrowException()")) { 368 if (IsDeadCheck(isolate, "v8::ThrowException()")) {
361 return v8::Handle<Value>(); 369 return v8::Handle<Value>();
362 } 370 }
363 ENTER_V8; 371 ENTER_V8(isolate);
364 // If we're passed an empty handle, we throw an undefined exception 372 // If we're passed an empty handle, we throw an undefined exception
365 // to deal more gracefully with out of memory situations. 373 // to deal more gracefully with out of memory situations.
366 if (value.IsEmpty()) { 374 if (value.IsEmpty()) {
367 isolate->ScheduleThrow(HEAP->undefined_value()); 375 isolate->ScheduleThrow(HEAP->undefined_value());
368 } else { 376 } else {
369 isolate->ScheduleThrow(*Utils::OpenHandle(*value)); 377 isolate->ScheduleThrow(*Utils::OpenHandle(*value));
370 } 378 }
371 return v8::Undefined(); 379 return v8::Undefined();
372 } 380 }
373 381
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 i::HandleScope::DeleteExtensions(isolate_); 551 i::HandleScope::DeleteExtensions(isolate_);
544 } 552 }
545 553
546 #ifdef DEBUG 554 #ifdef DEBUG
547 i::HandleScope::ZapRange(prev_next_, prev_limit_); 555 i::HandleScope::ZapRange(prev_next_, prev_limit_);
548 #endif 556 #endif
549 } 557 }
550 558
551 559
552 int HandleScope::NumberOfHandles() { 560 int HandleScope::NumberOfHandles() {
553 EnsureInitialized("HandleScope::NumberOfHandles"); 561 EnsureInitializedForIsolate(
562 i::Isolate::Current(), "HandleScope::NumberOfHandles");
554 return i::HandleScope::NumberOfHandles(); 563 return i::HandleScope::NumberOfHandles();
555 } 564 }
556 565
557 566
558 i::Object** HandleScope::CreateHandle(i::Object* value) { 567 i::Object** HandleScope::CreateHandle(i::Object* value) {
559 return i::HandleScope::CreateHandle(value, i::Isolate::Current()); 568 return i::HandleScope::CreateHandle(value, i::Isolate::Current());
560 } 569 }
561 570
562 571
563 i::Object** HandleScope::CreateHandle(i::HeapObject* value) { 572 i::Object** HandleScope::CreateHandle(i::HeapObject* value) {
564 ASSERT(value->IsHeapObject()); 573 ASSERT(value->IsHeapObject());
565 return reinterpret_cast<i::Object**>( 574 return reinterpret_cast<i::Object**>(
566 i::HandleScope::CreateHandle(value, value->GetIsolate())); 575 i::HandleScope::CreateHandle(value, value->GetIsolate()));
567 } 576 }
568 577
569 578
570 void Context::Enter() { 579 void Context::Enter() {
571 // TODO(isolates): Context should have a pointer to isolate. 580 // TODO(isolates): Context should have a pointer to isolate.
572 i::Isolate* isolate = i::Isolate::Current(); 581 i::Isolate* isolate = i::Isolate::Current();
573 if (IsDeadCheck(isolate, "v8::Context::Enter()")) return; 582 if (IsDeadCheck(isolate, "v8::Context::Enter()")) return;
574 ENTER_V8; 583 ENTER_V8(isolate);
584
575 i::Handle<i::Context> env = Utils::OpenHandle(this); 585 i::Handle<i::Context> env = Utils::OpenHandle(this);
576 isolate->handle_scope_implementer()->EnterContext(env); 586 isolate->handle_scope_implementer()->EnterContext(env);
577 587
578 isolate->handle_scope_implementer()->SaveContext(isolate->context()); 588 isolate->handle_scope_implementer()->SaveContext(isolate->context());
579 isolate->set_context(*env); 589 isolate->set_context(*env);
580 } 590 }
581 591
582 592
583 void Context::Exit() { 593 void Context::Exit() {
584 // TODO(isolates): Context should have a pointer to isolate. 594 // TODO(isolates): Context should have a pointer to isolate.
(...skipping 10 matching lines...) Expand all
595 i::Context* last_context = 605 i::Context* last_context =
596 isolate->handle_scope_implementer()->RestoreContext(); 606 isolate->handle_scope_implementer()->RestoreContext();
597 isolate->set_context(last_context); 607 isolate->set_context(last_context);
598 } 608 }
599 609
600 610
601 void Context::SetData(v8::Handle<String> data) { 611 void Context::SetData(v8::Handle<String> data) {
602 // TODO(isolates): Context should have a pointer to isolate. 612 // TODO(isolates): Context should have a pointer to isolate.
603 i::Isolate* isolate = i::Isolate::Current(); 613 i::Isolate* isolate = i::Isolate::Current();
604 if (IsDeadCheck(isolate, "v8::Context::SetData()")) return; 614 if (IsDeadCheck(isolate, "v8::Context::SetData()")) return;
605 ENTER_V8; 615 ENTER_V8(isolate);
606 { 616 {
607 i::HandleScope scope(isolate); 617 i::HandleScope scope(isolate);
608 i::Handle<i::Context> env = Utils::OpenHandle(this); 618 i::Handle<i::Context> env = Utils::OpenHandle(this);
609 i::Handle<i::Object> raw_data = Utils::OpenHandle(*data); 619 i::Handle<i::Object> raw_data = Utils::OpenHandle(*data);
610 ASSERT(env->IsGlobalContext()); 620 ASSERT(env->IsGlobalContext());
611 if (env->IsGlobalContext()) { 621 if (env->IsGlobalContext()) {
612 env->set_data(*raw_data); 622 env->set_data(*raw_data);
613 } 623 }
614 } 624 }
615 } 625 }
616 626
617 627
618 v8::Local<v8::Value> Context::GetData() { 628 v8::Local<v8::Value> Context::GetData() {
619 // TODO(isolates): Context should have a pointer to isolate. 629 // TODO(isolates): Context should have a pointer to isolate.
620 i::Isolate* isolate = i::Isolate::Current(); 630 i::Isolate* isolate = i::Isolate::Current();
621 if (IsDeadCheck(isolate, "v8::Context::GetData()")) { 631 if (IsDeadCheck(isolate, "v8::Context::GetData()")) {
622 return v8::Local<Value>(); 632 return v8::Local<Value>();
623 } 633 }
624 ENTER_V8; 634 ENTER_V8(isolate);
625 i::Object* raw_result = NULL; 635 i::Object* raw_result = NULL;
626 { 636 {
627 i::HandleScope scope(isolate); 637 i::HandleScope scope(isolate);
628 i::Handle<i::Context> env = Utils::OpenHandle(this); 638 i::Handle<i::Context> env = Utils::OpenHandle(this);
629 ASSERT(env->IsGlobalContext()); 639 ASSERT(env->IsGlobalContext());
630 if (env->IsGlobalContext()) { 640 if (env->IsGlobalContext()) {
631 raw_result = env->data(); 641 raw_result = env->data();
632 } else { 642 } else {
633 return Local<Value>(); 643 return Local<Value>();
634 } 644 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 676
667 // --- N e a n d e r --- 677 // --- N e a n d e r ---
668 678
669 679
670 // A constructor cannot easily return an error value, therefore it is necessary 680 // A constructor cannot easily return an error value, therefore it is necessary
671 // to check for a dead VM with ON_BAILOUT before constructing any Neander 681 // to check for a dead VM with ON_BAILOUT before constructing any Neander
672 // objects. To remind you about this there is no HandleScope in the 682 // objects. To remind you about this there is no HandleScope in the
673 // NeanderObject constructor. When you add one to the site calling the 683 // NeanderObject constructor. When you add one to the site calling the
674 // constructor you should check that you ensured the VM was not dead first. 684 // constructor you should check that you ensured the VM was not dead first.
675 NeanderObject::NeanderObject(int size) { 685 NeanderObject::NeanderObject(int size) {
676 EnsureInitialized("v8::Nowhere"); 686 i::Isolate* isolate = i::Isolate::Current();
677 ENTER_V8; 687 EnsureInitializedForIsolate(isolate, "v8::Nowhere");
678 value_ = FACTORY->NewNeanderObject(); 688 ENTER_V8(isolate);
679 i::Handle<i::FixedArray> elements = FACTORY->NewFixedArray(size); 689 value_ = isolate->factory()->NewNeanderObject();
690 i::Handle<i::FixedArray> elements = isolate->factory()->NewFixedArray(size);
680 value_->set_elements(*elements); 691 value_->set_elements(*elements);
681 } 692 }
682 693
683 694
684 int NeanderObject::size() { 695 int NeanderObject::size() {
685 return i::FixedArray::cast(value_->elements())->length(); 696 return i::FixedArray::cast(value_->elements())->length();
686 } 697 }
687 698
688 699
689 NeanderArray::NeanderArray() : obj_(2) { 700 NeanderArray::NeanderArray() : obj_(2) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 744
734 static void InitializeTemplate(i::Handle<i::TemplateInfo> that, int type) { 745 static void InitializeTemplate(i::Handle<i::TemplateInfo> that, int type) {
735 that->set_tag(i::Smi::FromInt(type)); 746 that->set_tag(i::Smi::FromInt(type));
736 } 747 }
737 748
738 749
739 void Template::Set(v8::Handle<String> name, v8::Handle<Data> value, 750 void Template::Set(v8::Handle<String> name, v8::Handle<Data> value,
740 v8::PropertyAttribute attribute) { 751 v8::PropertyAttribute attribute) {
741 i::Isolate* isolate = i::Isolate::Current(); 752 i::Isolate* isolate = i::Isolate::Current();
742 if (IsDeadCheck(isolate, "v8::Template::Set()")) return; 753 if (IsDeadCheck(isolate, "v8::Template::Set()")) return;
743 ENTER_V8; 754 ENTER_V8(isolate);
744 i::HandleScope scope(isolate); 755 i::HandleScope scope(isolate);
745 i::Handle<i::Object> list(Utils::OpenHandle(this)->property_list()); 756 i::Handle<i::Object> list(Utils::OpenHandle(this)->property_list());
746 if (list->IsUndefined()) { 757 if (list->IsUndefined()) {
747 list = NeanderArray().value(); 758 list = NeanderArray().value();
748 Utils::OpenHandle(this)->set_property_list(*list); 759 Utils::OpenHandle(this)->set_property_list(*list);
749 } 760 }
750 NeanderArray array(list); 761 NeanderArray array(list);
751 array.add(Utils::OpenHandle(*name)); 762 array.add(Utils::OpenHandle(*name));
752 array.add(Utils::OpenHandle(*value)); 763 array.add(Utils::OpenHandle(*value));
753 array.add(Utils::OpenHandle(*v8::Integer::New(attribute))); 764 array.add(Utils::OpenHandle(*v8::Integer::New(attribute)));
754 } 765 }
755 766
756 767
757 // --- F u n c t i o n T e m p l a t e --- 768 // --- F u n c t i o n T e m p l a t e ---
758 static void InitializeFunctionTemplate( 769 static void InitializeFunctionTemplate(
759 i::Handle<i::FunctionTemplateInfo> info) { 770 i::Handle<i::FunctionTemplateInfo> info) {
760 info->set_tag(i::Smi::FromInt(Consts::FUNCTION_TEMPLATE)); 771 info->set_tag(i::Smi::FromInt(Consts::FUNCTION_TEMPLATE));
761 info->set_flag(0); 772 info->set_flag(0);
762 } 773 }
763 774
764 775
765 Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() { 776 Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() {
766 i::Isolate* isolate = i::Isolate::Current(); 777 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
767 if (IsDeadCheck(isolate, "v8::FunctionTemplate::PrototypeTemplate()")) { 778 if (IsDeadCheck(isolate, "v8::FunctionTemplate::PrototypeTemplate()")) {
768 return Local<ObjectTemplate>(); 779 return Local<ObjectTemplate>();
769 } 780 }
770 ENTER_V8; 781 ENTER_V8(isolate);
771 i::Handle<i::Object> result(Utils::OpenHandle(this)->prototype_template()); 782 i::Handle<i::Object> result(Utils::OpenHandle(this)->prototype_template());
772 if (result->IsUndefined()) { 783 if (result->IsUndefined()) {
773 result = Utils::OpenHandle(*ObjectTemplate::New()); 784 result = Utils::OpenHandle(*ObjectTemplate::New());
774 Utils::OpenHandle(this)->set_prototype_template(*result); 785 Utils::OpenHandle(this)->set_prototype_template(*result);
775 } 786 }
776 return Local<ObjectTemplate>(ToApi<ObjectTemplate>(result)); 787 return Local<ObjectTemplate>(ToApi<ObjectTemplate>(result));
777 } 788 }
778 789
779 790
780 void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) { 791 void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) {
781 i::Isolate* isolate = i::Isolate::Current(); 792 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
782 if (IsDeadCheck(isolate, "v8::FunctionTemplate::Inherit()")) return; 793 if (IsDeadCheck(isolate, "v8::FunctionTemplate::Inherit()")) return;
783 ENTER_V8; 794 ENTER_V8(isolate);
784 Utils::OpenHandle(this)->set_parent_template(*Utils::OpenHandle(*value)); 795 Utils::OpenHandle(this)->set_parent_template(*Utils::OpenHandle(*value));
785 } 796 }
786 797
787 798
788 Local<FunctionTemplate> FunctionTemplate::New(InvocationCallback callback, 799 Local<FunctionTemplate> FunctionTemplate::New(InvocationCallback callback,
789 v8::Handle<Value> data, v8::Handle<Signature> signature) { 800 v8::Handle<Value> data, v8::Handle<Signature> signature) {
790 i::Isolate* isolate = i::Isolate::Current(); 801 i::Isolate* isolate = i::Isolate::Current();
791 EnsureInitializedForIsolate(isolate, "v8::FunctionTemplate::New()"); 802 EnsureInitializedForIsolate(isolate, "v8::FunctionTemplate::New()");
792 LOG_API(isolate, "FunctionTemplate::New"); 803 LOG_API(isolate, "FunctionTemplate::New");
793 ENTER_V8; 804 ENTER_V8(isolate);
794 i::Handle<i::Struct> struct_obj = 805 i::Handle<i::Struct> struct_obj =
795 isolate->factory()->NewStruct(i::FUNCTION_TEMPLATE_INFO_TYPE); 806 isolate->factory()->NewStruct(i::FUNCTION_TEMPLATE_INFO_TYPE);
796 i::Handle<i::FunctionTemplateInfo> obj = 807 i::Handle<i::FunctionTemplateInfo> obj =
797 i::Handle<i::FunctionTemplateInfo>::cast(struct_obj); 808 i::Handle<i::FunctionTemplateInfo>::cast(struct_obj);
798 InitializeFunctionTemplate(obj); 809 InitializeFunctionTemplate(obj);
799 int next_serial_number = isolate->next_serial_number(); 810 int next_serial_number = isolate->next_serial_number();
800 isolate->set_next_serial_number(next_serial_number + 1); 811 isolate->set_next_serial_number(next_serial_number + 1);
801 obj->set_serial_number(i::Smi::FromInt(next_serial_number)); 812 obj->set_serial_number(i::Smi::FromInt(next_serial_number));
802 if (callback != 0) { 813 if (callback != 0) {
803 if (data.IsEmpty()) data = v8::Undefined(); 814 if (data.IsEmpty()) data = v8::Undefined();
804 Utils::ToLocal(obj)->SetCallHandler(callback, data); 815 Utils::ToLocal(obj)->SetCallHandler(callback, data);
805 } 816 }
806 obj->set_undetectable(false); 817 obj->set_undetectable(false);
807 obj->set_needs_access_check(false); 818 obj->set_needs_access_check(false);
808 819
809 if (!signature.IsEmpty()) 820 if (!signature.IsEmpty())
810 obj->set_signature(*Utils::OpenHandle(*signature)); 821 obj->set_signature(*Utils::OpenHandle(*signature));
811 return Utils::ToLocal(obj); 822 return Utils::ToLocal(obj);
812 } 823 }
813 824
814 825
815 Local<Signature> Signature::New(Handle<FunctionTemplate> receiver, 826 Local<Signature> Signature::New(Handle<FunctionTemplate> receiver,
816 int argc, Handle<FunctionTemplate> argv[]) { 827 int argc, Handle<FunctionTemplate> argv[]) {
817 i::Isolate* isolate = i::Isolate::Current(); 828 i::Isolate* isolate = i::Isolate::Current();
818 EnsureInitializedForIsolate(isolate, "v8::Signature::New()"); 829 EnsureInitializedForIsolate(isolate, "v8::Signature::New()");
819 LOG_API(isolate, "Signature::New"); 830 LOG_API(isolate, "Signature::New");
820 ENTER_V8; 831 ENTER_V8(isolate);
821 i::Handle<i::Struct> struct_obj = 832 i::Handle<i::Struct> struct_obj =
822 isolate->factory()->NewStruct(i::SIGNATURE_INFO_TYPE); 833 isolate->factory()->NewStruct(i::SIGNATURE_INFO_TYPE);
823 i::Handle<i::SignatureInfo> obj = 834 i::Handle<i::SignatureInfo> obj =
824 i::Handle<i::SignatureInfo>::cast(struct_obj); 835 i::Handle<i::SignatureInfo>::cast(struct_obj);
825 if (!receiver.IsEmpty()) obj->set_receiver(*Utils::OpenHandle(*receiver)); 836 if (!receiver.IsEmpty()) obj->set_receiver(*Utils::OpenHandle(*receiver));
826 if (argc > 0) { 837 if (argc > 0) {
827 i::Handle<i::FixedArray> args = isolate->factory()->NewFixedArray(argc); 838 i::Handle<i::FixedArray> args = isolate->factory()->NewFixedArray(argc);
828 for (int i = 0; i < argc; i++) { 839 for (int i = 0; i < argc; i++) {
829 if (!argv[i].IsEmpty()) 840 if (!argv[i].IsEmpty())
830 args->set(i, *Utils::OpenHandle(*argv[i])); 841 args->set(i, *Utils::OpenHandle(*argv[i]));
831 } 842 }
832 obj->set_args(*args); 843 obj->set_args(*args);
833 } 844 }
834 return Utils::ToLocal(obj); 845 return Utils::ToLocal(obj);
835 } 846 }
836 847
837 848
838 Local<TypeSwitch> TypeSwitch::New(Handle<FunctionTemplate> type) { 849 Local<TypeSwitch> TypeSwitch::New(Handle<FunctionTemplate> type) {
839 Handle<FunctionTemplate> types[1] = { type }; 850 Handle<FunctionTemplate> types[1] = { type };
840 return TypeSwitch::New(1, types); 851 return TypeSwitch::New(1, types);
841 } 852 }
842 853
843 854
844 Local<TypeSwitch> TypeSwitch::New(int argc, Handle<FunctionTemplate> types[]) { 855 Local<TypeSwitch> TypeSwitch::New(int argc, Handle<FunctionTemplate> types[]) {
845 i::Isolate* isolate = i::Isolate::Current(); 856 i::Isolate* isolate = i::Isolate::Current();
846 EnsureInitializedForIsolate(isolate, "v8::TypeSwitch::New()"); 857 EnsureInitializedForIsolate(isolate, "v8::TypeSwitch::New()");
847 LOG_API(isolate, "TypeSwitch::New"); 858 LOG_API(isolate, "TypeSwitch::New");
848 ENTER_V8; 859 ENTER_V8(isolate);
849 i::Handle<i::FixedArray> vector = isolate->factory()->NewFixedArray(argc); 860 i::Handle<i::FixedArray> vector = isolate->factory()->NewFixedArray(argc);
850 for (int i = 0; i < argc; i++) 861 for (int i = 0; i < argc; i++)
851 vector->set(i, *Utils::OpenHandle(*types[i])); 862 vector->set(i, *Utils::OpenHandle(*types[i]));
852 i::Handle<i::Struct> struct_obj = 863 i::Handle<i::Struct> struct_obj =
853 isolate->factory()->NewStruct(i::TYPE_SWITCH_INFO_TYPE); 864 isolate->factory()->NewStruct(i::TYPE_SWITCH_INFO_TYPE);
854 i::Handle<i::TypeSwitchInfo> obj = 865 i::Handle<i::TypeSwitchInfo> obj =
855 i::Handle<i::TypeSwitchInfo>::cast(struct_obj); 866 i::Handle<i::TypeSwitchInfo>::cast(struct_obj);
856 obj->set_types(*vector); 867 obj->set_types(*vector);
857 return Utils::ToLocal(obj); 868 return Utils::ToLocal(obj);
858 } 869 }
(...skipping 14 matching lines...) Expand all
873 884
874 885
875 #define SET_FIELD_WRAPPED(obj, setter, cdata) do { \ 886 #define SET_FIELD_WRAPPED(obj, setter, cdata) do { \
876 i::Handle<i::Object> proxy = FromCData(cdata); \ 887 i::Handle<i::Object> proxy = FromCData(cdata); \
877 (obj)->setter(*proxy); \ 888 (obj)->setter(*proxy); \
878 } while (false) 889 } while (false)
879 890
880 891
881 void FunctionTemplate::SetCallHandler(InvocationCallback callback, 892 void FunctionTemplate::SetCallHandler(InvocationCallback callback,
882 v8::Handle<Value> data) { 893 v8::Handle<Value> data) {
883 i::Isolate* isolate = i::Isolate::Current(); 894 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
884 if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetCallHandler()")) return; 895 if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetCallHandler()")) return;
885 ENTER_V8; 896 ENTER_V8(isolate);
886 i::HandleScope scope(isolate); 897 i::HandleScope scope(isolate);
887 i::Handle<i::Struct> struct_obj = 898 i::Handle<i::Struct> struct_obj =
888 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); 899 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE);
889 i::Handle<i::CallHandlerInfo> obj = 900 i::Handle<i::CallHandlerInfo> obj =
890 i::Handle<i::CallHandlerInfo>::cast(struct_obj); 901 i::Handle<i::CallHandlerInfo>::cast(struct_obj);
891 SET_FIELD_WRAPPED(obj, set_callback, callback); 902 SET_FIELD_WRAPPED(obj, set_callback, callback);
892 if (data.IsEmpty()) data = v8::Undefined(); 903 if (data.IsEmpty()) data = v8::Undefined();
893 obj->set_data(*Utils::OpenHandle(*data)); 904 obj->set_data(*Utils::OpenHandle(*data));
894 Utils::OpenHandle(this)->set_call_code(*obj); 905 Utils::OpenHandle(this)->set_call_code(*obj);
895 } 906 }
(...skipping 21 matching lines...) Expand all
917 } 928 }
918 929
919 930
920 void FunctionTemplate::AddInstancePropertyAccessor( 931 void FunctionTemplate::AddInstancePropertyAccessor(
921 v8::Handle<String> name, 932 v8::Handle<String> name,
922 AccessorGetter getter, 933 AccessorGetter getter,
923 AccessorSetter setter, 934 AccessorSetter setter,
924 v8::Handle<Value> data, 935 v8::Handle<Value> data,
925 v8::AccessControl settings, 936 v8::AccessControl settings,
926 v8::PropertyAttribute attributes) { 937 v8::PropertyAttribute attributes) {
927 i::Isolate* isolate = i::Isolate::Current(); 938 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
928 if (IsDeadCheck(isolate, 939 if (IsDeadCheck(isolate,
929 "v8::FunctionTemplate::AddInstancePropertyAccessor()")) { 940 "v8::FunctionTemplate::AddInstancePropertyAccessor()")) {
930 return; 941 return;
931 } 942 }
932 ENTER_V8; 943 ENTER_V8(isolate);
933 i::HandleScope scope(isolate); 944 i::HandleScope scope(isolate);
934 945
935 i::Handle<i::AccessorInfo> obj = MakeAccessorInfo(name, 946 i::Handle<i::AccessorInfo> obj = MakeAccessorInfo(name,
936 getter, setter, data, 947 getter, setter, data,
937 settings, attributes); 948 settings, attributes);
938 i::Handle<i::Object> list(Utils::OpenHandle(this)->property_accessors()); 949 i::Handle<i::Object> list(Utils::OpenHandle(this)->property_accessors());
939 if (list->IsUndefined()) { 950 if (list->IsUndefined()) {
940 list = NeanderArray().value(); 951 list = NeanderArray().value();
941 Utils::OpenHandle(this)->set_property_accessors(*list); 952 Utils::OpenHandle(this)->set_property_accessors(*list);
942 } 953 }
943 NeanderArray array(list); 954 NeanderArray array(list);
944 array.add(obj); 955 array.add(obj);
945 } 956 }
946 957
947 958
948 Local<ObjectTemplate> FunctionTemplate::InstanceTemplate() { 959 Local<ObjectTemplate> FunctionTemplate::InstanceTemplate() {
949 i::Isolate* isolate = i::Isolate::Current(); 960 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
950 if (IsDeadCheck(isolate, "v8::FunctionTemplate::InstanceTemplate()") 961 if (IsDeadCheck(isolate, "v8::FunctionTemplate::InstanceTemplate()")
951 || EmptyCheck("v8::FunctionTemplate::InstanceTemplate()", this)) 962 || EmptyCheck("v8::FunctionTemplate::InstanceTemplate()", this))
952 return Local<ObjectTemplate>(); 963 return Local<ObjectTemplate>();
953 ENTER_V8; 964 ENTER_V8(isolate);
954 if (Utils::OpenHandle(this)->instance_template()->IsUndefined()) { 965 if (Utils::OpenHandle(this)->instance_template()->IsUndefined()) {
955 Local<ObjectTemplate> templ = 966 Local<ObjectTemplate> templ =
956 ObjectTemplate::New(v8::Handle<FunctionTemplate>(this)); 967 ObjectTemplate::New(v8::Handle<FunctionTemplate>(this));
957 Utils::OpenHandle(this)->set_instance_template(*Utils::OpenHandle(*templ)); 968 Utils::OpenHandle(this)->set_instance_template(*Utils::OpenHandle(*templ));
958 } 969 }
959 i::Handle<i::ObjectTemplateInfo> result(i::ObjectTemplateInfo::cast( 970 i::Handle<i::ObjectTemplateInfo> result(i::ObjectTemplateInfo::cast(
960 Utils::OpenHandle(this)->instance_template())); 971 Utils::OpenHandle(this)->instance_template()));
961 return Utils::ToLocal(result); 972 return Utils::ToLocal(result);
962 } 973 }
963 974
964 975
965 void FunctionTemplate::SetClassName(Handle<String> name) { 976 void FunctionTemplate::SetClassName(Handle<String> name) {
966 i::Isolate* isolate = i::Isolate::Current(); 977 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
967 if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetClassName()")) return; 978 if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetClassName()")) return;
968 ENTER_V8; 979 ENTER_V8(isolate);
969 Utils::OpenHandle(this)->set_class_name(*Utils::OpenHandle(*name)); 980 Utils::OpenHandle(this)->set_class_name(*Utils::OpenHandle(*name));
970 } 981 }
971 982
972 983
973 void FunctionTemplate::SetHiddenPrototype(bool value) { 984 void FunctionTemplate::SetHiddenPrototype(bool value) {
974 i::Isolate* isolate = i::Isolate::Current(); 985 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
975 if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetHiddenPrototype()")) { 986 if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetHiddenPrototype()")) {
976 return; 987 return;
977 } 988 }
978 ENTER_V8; 989 ENTER_V8(isolate);
979 Utils::OpenHandle(this)->set_hidden_prototype(value); 990 Utils::OpenHandle(this)->set_hidden_prototype(value);
980 } 991 }
981 992
982 993
983 void FunctionTemplate::SetNamedInstancePropertyHandler( 994 void FunctionTemplate::SetNamedInstancePropertyHandler(
984 NamedPropertyGetter getter, 995 NamedPropertyGetter getter,
985 NamedPropertySetter setter, 996 NamedPropertySetter setter,
986 NamedPropertyQuery query, 997 NamedPropertyQuery query,
987 NamedPropertyDeleter remover, 998 NamedPropertyDeleter remover,
988 NamedPropertyEnumerator enumerator, 999 NamedPropertyEnumerator enumerator,
989 Handle<Value> data) { 1000 Handle<Value> data) {
990 i::Isolate* isolate = i::Isolate::Current(); 1001 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
991 if (IsDeadCheck(isolate, 1002 if (IsDeadCheck(isolate,
992 "v8::FunctionTemplate::SetNamedInstancePropertyHandler()")) { 1003 "v8::FunctionTemplate::SetNamedInstancePropertyHandler()")) {
993 return; 1004 return;
994 } 1005 }
995 ENTER_V8; 1006 ENTER_V8(isolate);
996 i::HandleScope scope(isolate); 1007 i::HandleScope scope(isolate);
997 i::Handle<i::Struct> struct_obj = 1008 i::Handle<i::Struct> struct_obj =
998 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); 1009 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE);
999 i::Handle<i::InterceptorInfo> obj = 1010 i::Handle<i::InterceptorInfo> obj =
1000 i::Handle<i::InterceptorInfo>::cast(struct_obj); 1011 i::Handle<i::InterceptorInfo>::cast(struct_obj);
1001 1012
1002 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter); 1013 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter);
1003 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter); 1014 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter);
1004 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query); 1015 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query);
1005 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover); 1016 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover);
1006 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator); 1017 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator);
1007 1018
1008 if (data.IsEmpty()) data = v8::Undefined(); 1019 if (data.IsEmpty()) data = v8::Undefined();
1009 obj->set_data(*Utils::OpenHandle(*data)); 1020 obj->set_data(*Utils::OpenHandle(*data));
1010 Utils::OpenHandle(this)->set_named_property_handler(*obj); 1021 Utils::OpenHandle(this)->set_named_property_handler(*obj);
1011 } 1022 }
1012 1023
1013 1024
1014 void FunctionTemplate::SetIndexedInstancePropertyHandler( 1025 void FunctionTemplate::SetIndexedInstancePropertyHandler(
1015 IndexedPropertyGetter getter, 1026 IndexedPropertyGetter getter,
1016 IndexedPropertySetter setter, 1027 IndexedPropertySetter setter,
1017 IndexedPropertyQuery query, 1028 IndexedPropertyQuery query,
1018 IndexedPropertyDeleter remover, 1029 IndexedPropertyDeleter remover,
1019 IndexedPropertyEnumerator enumerator, 1030 IndexedPropertyEnumerator enumerator,
1020 Handle<Value> data) { 1031 Handle<Value> data) {
1021 i::Isolate* isolate = i::Isolate::Current(); 1032 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1022 if (IsDeadCheck(isolate, 1033 if (IsDeadCheck(isolate,
1023 "v8::FunctionTemplate::SetIndexedInstancePropertyHandler()")) { 1034 "v8::FunctionTemplate::SetIndexedInstancePropertyHandler()")) {
1024 return; 1035 return;
1025 } 1036 }
1026 ENTER_V8; 1037 ENTER_V8(isolate);
1027 i::HandleScope scope(isolate); 1038 i::HandleScope scope(isolate);
1028 i::Handle<i::Struct> struct_obj = 1039 i::Handle<i::Struct> struct_obj =
1029 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); 1040 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE);
1030 i::Handle<i::InterceptorInfo> obj = 1041 i::Handle<i::InterceptorInfo> obj =
1031 i::Handle<i::InterceptorInfo>::cast(struct_obj); 1042 i::Handle<i::InterceptorInfo>::cast(struct_obj);
1032 1043
1033 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter); 1044 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter);
1034 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter); 1045 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter);
1035 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query); 1046 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query);
1036 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover); 1047 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover);
1037 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator); 1048 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator);
1038 1049
1039 if (data.IsEmpty()) data = v8::Undefined(); 1050 if (data.IsEmpty()) data = v8::Undefined();
1040 obj->set_data(*Utils::OpenHandle(*data)); 1051 obj->set_data(*Utils::OpenHandle(*data));
1041 Utils::OpenHandle(this)->set_indexed_property_handler(*obj); 1052 Utils::OpenHandle(this)->set_indexed_property_handler(*obj);
1042 } 1053 }
1043 1054
1044 1055
1045 void FunctionTemplate::SetInstanceCallAsFunctionHandler( 1056 void FunctionTemplate::SetInstanceCallAsFunctionHandler(
1046 InvocationCallback callback, 1057 InvocationCallback callback,
1047 Handle<Value> data) { 1058 Handle<Value> data) {
1048 i::Isolate* isolate = i::Isolate::Current(); 1059 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1049 if (IsDeadCheck(isolate, 1060 if (IsDeadCheck(isolate,
1050 "v8::FunctionTemplate::SetInstanceCallAsFunctionHandler()")) { 1061 "v8::FunctionTemplate::SetInstanceCallAsFunctionHandler()")) {
1051 return; 1062 return;
1052 } 1063 }
1053 ENTER_V8; 1064 ENTER_V8(isolate);
1054 i::HandleScope scope(isolate); 1065 i::HandleScope scope(isolate);
1055 i::Handle<i::Struct> struct_obj = 1066 i::Handle<i::Struct> struct_obj =
1056 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); 1067 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE);
1057 i::Handle<i::CallHandlerInfo> obj = 1068 i::Handle<i::CallHandlerInfo> obj =
1058 i::Handle<i::CallHandlerInfo>::cast(struct_obj); 1069 i::Handle<i::CallHandlerInfo>::cast(struct_obj);
1059 SET_FIELD_WRAPPED(obj, set_callback, callback); 1070 SET_FIELD_WRAPPED(obj, set_callback, callback);
1060 if (data.IsEmpty()) data = v8::Undefined(); 1071 if (data.IsEmpty()) data = v8::Undefined();
1061 obj->set_data(*Utils::OpenHandle(*data)); 1072 obj->set_data(*Utils::OpenHandle(*data));
1062 Utils::OpenHandle(this)->set_instance_call_handler(*obj); 1073 Utils::OpenHandle(this)->set_instance_call_handler(*obj);
1063 } 1074 }
1064 1075
1065 1076
1066 // --- O b j e c t T e m p l a t e --- 1077 // --- O b j e c t T e m p l a t e ---
1067 1078
1068 1079
1069 Local<ObjectTemplate> ObjectTemplate::New() { 1080 Local<ObjectTemplate> ObjectTemplate::New() {
1070 return New(Local<FunctionTemplate>()); 1081 return New(Local<FunctionTemplate>());
1071 } 1082 }
1072 1083
1073 1084
1074 Local<ObjectTemplate> ObjectTemplate::New( 1085 Local<ObjectTemplate> ObjectTemplate::New(
1075 v8::Handle<FunctionTemplate> constructor) { 1086 v8::Handle<FunctionTemplate> constructor) {
1076 i::Isolate* isolate = i::Isolate::Current(); 1087 i::Isolate* isolate = i::Isolate::Current();
1077 if (IsDeadCheck(isolate, "v8::ObjectTemplate::New()")) { 1088 if (IsDeadCheck(isolate, "v8::ObjectTemplate::New()")) {
1078 return Local<ObjectTemplate>(); 1089 return Local<ObjectTemplate>();
1079 } 1090 }
1080 EnsureInitializedForIsolate(isolate, "v8::ObjectTemplate::New()"); 1091 EnsureInitializedForIsolate(isolate, "v8::ObjectTemplate::New()");
1081 LOG_API(isolate, "ObjectTemplate::New"); 1092 LOG_API(isolate, "ObjectTemplate::New");
1082 ENTER_V8; 1093 ENTER_V8(isolate);
1083 i::Handle<i::Struct> struct_obj = 1094 i::Handle<i::Struct> struct_obj =
1084 isolate->factory()->NewStruct(i::OBJECT_TEMPLATE_INFO_TYPE); 1095 isolate->factory()->NewStruct(i::OBJECT_TEMPLATE_INFO_TYPE);
1085 i::Handle<i::ObjectTemplateInfo> obj = 1096 i::Handle<i::ObjectTemplateInfo> obj =
1086 i::Handle<i::ObjectTemplateInfo>::cast(struct_obj); 1097 i::Handle<i::ObjectTemplateInfo>::cast(struct_obj);
1087 InitializeTemplate(obj, Consts::OBJECT_TEMPLATE); 1098 InitializeTemplate(obj, Consts::OBJECT_TEMPLATE);
1088 if (!constructor.IsEmpty()) 1099 if (!constructor.IsEmpty())
1089 obj->set_constructor(*Utils::OpenHandle(*constructor)); 1100 obj->set_constructor(*Utils::OpenHandle(*constructor));
1090 obj->set_internal_field_count(i::Smi::FromInt(0)); 1101 obj->set_internal_field_count(i::Smi::FromInt(0));
1091 return Utils::ToLocal(obj); 1102 return Utils::ToLocal(obj);
1092 } 1103 }
1093 1104
1094 1105
1095 // Ensure that the object template has a constructor. If no 1106 // Ensure that the object template has a constructor. If no
1096 // constructor is available we create one. 1107 // constructor is available we create one.
1097 static void EnsureConstructor(ObjectTemplate* object_template) { 1108 static void EnsureConstructor(ObjectTemplate* object_template) {
1098 if (Utils::OpenHandle(object_template)->constructor()->IsUndefined()) { 1109 if (Utils::OpenHandle(object_template)->constructor()->IsUndefined()) {
1099 Local<FunctionTemplate> templ = FunctionTemplate::New(); 1110 Local<FunctionTemplate> templ = FunctionTemplate::New();
1100 i::Handle<i::FunctionTemplateInfo> constructor = Utils::OpenHandle(*templ); 1111 i::Handle<i::FunctionTemplateInfo> constructor = Utils::OpenHandle(*templ);
1101 constructor->set_instance_template(*Utils::OpenHandle(object_template)); 1112 constructor->set_instance_template(*Utils::OpenHandle(object_template));
1102 Utils::OpenHandle(object_template)->set_constructor(*constructor); 1113 Utils::OpenHandle(object_template)->set_constructor(*constructor);
1103 } 1114 }
1104 } 1115 }
1105 1116
1106 1117
1107 void ObjectTemplate::SetAccessor(v8::Handle<String> name, 1118 void ObjectTemplate::SetAccessor(v8::Handle<String> name,
1108 AccessorGetter getter, 1119 AccessorGetter getter,
1109 AccessorSetter setter, 1120 AccessorSetter setter,
1110 v8::Handle<Value> data, 1121 v8::Handle<Value> data,
1111 AccessControl settings, 1122 AccessControl settings,
1112 PropertyAttribute attribute) { 1123 PropertyAttribute attribute) {
1113 i::Isolate* isolate = i::Isolate::Current(); 1124 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1114 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetAccessor()")) return; 1125 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetAccessor()")) return;
1115 ENTER_V8; 1126 ENTER_V8(isolate);
1116 i::HandleScope scope(isolate); 1127 i::HandleScope scope(isolate);
1117 EnsureConstructor(this); 1128 EnsureConstructor(this);
1118 i::FunctionTemplateInfo* constructor = 1129 i::FunctionTemplateInfo* constructor =
1119 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); 1130 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor());
1120 i::Handle<i::FunctionTemplateInfo> cons(constructor); 1131 i::Handle<i::FunctionTemplateInfo> cons(constructor);
1121 Utils::ToLocal(cons)->AddInstancePropertyAccessor(name, 1132 Utils::ToLocal(cons)->AddInstancePropertyAccessor(name,
1122 getter, 1133 getter,
1123 setter, 1134 setter,
1124 data, 1135 data,
1125 settings, 1136 settings,
1126 attribute); 1137 attribute);
1127 } 1138 }
1128 1139
1129 1140
1130 void ObjectTemplate::SetNamedPropertyHandler(NamedPropertyGetter getter, 1141 void ObjectTemplate::SetNamedPropertyHandler(NamedPropertyGetter getter,
1131 NamedPropertySetter setter, 1142 NamedPropertySetter setter,
1132 NamedPropertyQuery query, 1143 NamedPropertyQuery query,
1133 NamedPropertyDeleter remover, 1144 NamedPropertyDeleter remover,
1134 NamedPropertyEnumerator enumerator, 1145 NamedPropertyEnumerator enumerator,
1135 Handle<Value> data) { 1146 Handle<Value> data) {
1136 i::Isolate* isolate = i::Isolate::Current(); 1147 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1137 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetNamedPropertyHandler()")) { 1148 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetNamedPropertyHandler()")) {
1138 return; 1149 return;
1139 } 1150 }
1140 ENTER_V8; 1151 ENTER_V8(isolate);
1141 HandleScope scope; 1152 i::HandleScope scope(isolate);
1142 EnsureConstructor(this); 1153 EnsureConstructor(this);
1143 i::FunctionTemplateInfo* constructor = 1154 i::FunctionTemplateInfo* constructor =
1144 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); 1155 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor());
1145 i::Handle<i::FunctionTemplateInfo> cons(constructor); 1156 i::Handle<i::FunctionTemplateInfo> cons(constructor);
1146 Utils::ToLocal(cons)->SetNamedInstancePropertyHandler(getter, 1157 Utils::ToLocal(cons)->SetNamedInstancePropertyHandler(getter,
1147 setter, 1158 setter,
1148 query, 1159 query,
1149 remover, 1160 remover,
1150 enumerator, 1161 enumerator,
1151 data); 1162 data);
1152 } 1163 }
1153 1164
1154 1165
1155 void ObjectTemplate::MarkAsUndetectable() { 1166 void ObjectTemplate::MarkAsUndetectable() {
1156 i::Isolate* isolate = i::Isolate::Current(); 1167 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1157 if (IsDeadCheck(isolate, "v8::ObjectTemplate::MarkAsUndetectable()")) return; 1168 if (IsDeadCheck(isolate, "v8::ObjectTemplate::MarkAsUndetectable()")) return;
1158 ENTER_V8; 1169 ENTER_V8(isolate);
1159 i::HandleScope scope(isolate); 1170 i::HandleScope scope(isolate);
1160 EnsureConstructor(this); 1171 EnsureConstructor(this);
1161 i::FunctionTemplateInfo* constructor = 1172 i::FunctionTemplateInfo* constructor =
1162 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); 1173 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor());
1163 i::Handle<i::FunctionTemplateInfo> cons(constructor); 1174 i::Handle<i::FunctionTemplateInfo> cons(constructor);
1164 cons->set_undetectable(true); 1175 cons->set_undetectable(true);
1165 } 1176 }
1166 1177
1167 1178
1168 void ObjectTemplate::SetAccessCheckCallbacks( 1179 void ObjectTemplate::SetAccessCheckCallbacks(
1169 NamedSecurityCallback named_callback, 1180 NamedSecurityCallback named_callback,
1170 IndexedSecurityCallback indexed_callback, 1181 IndexedSecurityCallback indexed_callback,
1171 Handle<Value> data, 1182 Handle<Value> data,
1172 bool turned_on_by_default) { 1183 bool turned_on_by_default) {
1173 i::Isolate* isolate = i::Isolate::Current(); 1184 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1174 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetAccessCheckCallbacks()")) { 1185 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetAccessCheckCallbacks()")) {
1175 return; 1186 return;
1176 } 1187 }
1177 ENTER_V8; 1188 ENTER_V8(isolate);
1178 i::HandleScope scope(isolate); 1189 i::HandleScope scope(isolate);
1179 EnsureConstructor(this); 1190 EnsureConstructor(this);
1180 1191
1181 i::Handle<i::Struct> struct_info = 1192 i::Handle<i::Struct> struct_info =
1182 isolate->factory()->NewStruct(i::ACCESS_CHECK_INFO_TYPE); 1193 isolate->factory()->NewStruct(i::ACCESS_CHECK_INFO_TYPE);
1183 i::Handle<i::AccessCheckInfo> info = 1194 i::Handle<i::AccessCheckInfo> info =
1184 i::Handle<i::AccessCheckInfo>::cast(struct_info); 1195 i::Handle<i::AccessCheckInfo>::cast(struct_info);
1185 1196
1186 SET_FIELD_WRAPPED(info, set_named_callback, named_callback); 1197 SET_FIELD_WRAPPED(info, set_named_callback, named_callback);
1187 SET_FIELD_WRAPPED(info, set_indexed_callback, indexed_callback); 1198 SET_FIELD_WRAPPED(info, set_indexed_callback, indexed_callback);
1188 1199
1189 if (data.IsEmpty()) data = v8::Undefined(); 1200 if (data.IsEmpty()) data = v8::Undefined();
1190 info->set_data(*Utils::OpenHandle(*data)); 1201 info->set_data(*Utils::OpenHandle(*data));
1191 1202
1192 i::FunctionTemplateInfo* constructor = 1203 i::FunctionTemplateInfo* constructor =
1193 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); 1204 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor());
1194 i::Handle<i::FunctionTemplateInfo> cons(constructor); 1205 i::Handle<i::FunctionTemplateInfo> cons(constructor);
1195 cons->set_access_check_info(*info); 1206 cons->set_access_check_info(*info);
1196 cons->set_needs_access_check(turned_on_by_default); 1207 cons->set_needs_access_check(turned_on_by_default);
1197 } 1208 }
1198 1209
1199 1210
1200 void ObjectTemplate::SetIndexedPropertyHandler( 1211 void ObjectTemplate::SetIndexedPropertyHandler(
1201 IndexedPropertyGetter getter, 1212 IndexedPropertyGetter getter,
1202 IndexedPropertySetter setter, 1213 IndexedPropertySetter setter,
1203 IndexedPropertyQuery query, 1214 IndexedPropertyQuery query,
1204 IndexedPropertyDeleter remover, 1215 IndexedPropertyDeleter remover,
1205 IndexedPropertyEnumerator enumerator, 1216 IndexedPropertyEnumerator enumerator,
1206 Handle<Value> data) { 1217 Handle<Value> data) {
1207 i::Isolate* isolate = i::Isolate::Current(); 1218 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1208 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetIndexedPropertyHandler()")) { 1219 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetIndexedPropertyHandler()")) {
1209 return; 1220 return;
1210 } 1221 }
1211 ENTER_V8; 1222 ENTER_V8(isolate);
1212 i::HandleScope scope(isolate); 1223 i::HandleScope scope(isolate);
1213 EnsureConstructor(this); 1224 EnsureConstructor(this);
1214 i::FunctionTemplateInfo* constructor = 1225 i::FunctionTemplateInfo* constructor =
1215 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); 1226 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor());
1216 i::Handle<i::FunctionTemplateInfo> cons(constructor); 1227 i::Handle<i::FunctionTemplateInfo> cons(constructor);
1217 Utils::ToLocal(cons)->SetIndexedInstancePropertyHandler(getter, 1228 Utils::ToLocal(cons)->SetIndexedInstancePropertyHandler(getter,
1218 setter, 1229 setter,
1219 query, 1230 query,
1220 remover, 1231 remover,
1221 enumerator, 1232 enumerator,
1222 data); 1233 data);
1223 } 1234 }
1224 1235
1225 1236
1226 void ObjectTemplate::SetCallAsFunctionHandler(InvocationCallback callback, 1237 void ObjectTemplate::SetCallAsFunctionHandler(InvocationCallback callback,
1227 Handle<Value> data) { 1238 Handle<Value> data) {
1228 i::Isolate* isolate = i::Isolate::Current(); 1239 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1229 if (IsDeadCheck(isolate, 1240 if (IsDeadCheck(isolate,
1230 "v8::ObjectTemplate::SetCallAsFunctionHandler()")) { 1241 "v8::ObjectTemplate::SetCallAsFunctionHandler()")) {
1231 return; 1242 return;
1232 } 1243 }
1233 ENTER_V8; 1244 ENTER_V8(isolate);
1234 i::HandleScope scope(isolate); 1245 i::HandleScope scope(isolate);
1235 EnsureConstructor(this); 1246 EnsureConstructor(this);
1236 i::FunctionTemplateInfo* constructor = 1247 i::FunctionTemplateInfo* constructor =
1237 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); 1248 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor());
1238 i::Handle<i::FunctionTemplateInfo> cons(constructor); 1249 i::Handle<i::FunctionTemplateInfo> cons(constructor);
1239 Utils::ToLocal(cons)->SetInstanceCallAsFunctionHandler(callback, data); 1250 Utils::ToLocal(cons)->SetInstanceCallAsFunctionHandler(callback, data);
1240 } 1251 }
1241 1252
1242 1253
1243 int ObjectTemplate::InternalFieldCount() { 1254 int ObjectTemplate::InternalFieldCount() {
1244 if (IsDeadCheck(i::Isolate::Current(), 1255 if (IsDeadCheck(Utils::OpenHandle(this)->GetIsolate(),
1245 "v8::ObjectTemplate::InternalFieldCount()")) { 1256 "v8::ObjectTemplate::InternalFieldCount()")) {
1246 return 0; 1257 return 0;
1247 } 1258 }
1248 return i::Smi::cast(Utils::OpenHandle(this)->internal_field_count())->value(); 1259 return i::Smi::cast(Utils::OpenHandle(this)->internal_field_count())->value();
1249 } 1260 }
1250 1261
1251 1262
1252 void ObjectTemplate::SetInternalFieldCount(int value) { 1263 void ObjectTemplate::SetInternalFieldCount(int value) {
1253 i::Isolate* isolate = i::Isolate::Current(); 1264 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1254 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetInternalFieldCount()")) { 1265 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetInternalFieldCount()")) {
1255 return; 1266 return;
1256 } 1267 }
1257 if (!ApiCheck(i::Smi::IsValid(value), 1268 if (!ApiCheck(i::Smi::IsValid(value),
1258 "v8::ObjectTemplate::SetInternalFieldCount()", 1269 "v8::ObjectTemplate::SetInternalFieldCount()",
1259 "Invalid internal field count")) { 1270 "Invalid internal field count")) {
1260 return; 1271 return;
1261 } 1272 }
1262 ENTER_V8; 1273 ENTER_V8(isolate);
1263 if (value > 0) { 1274 if (value > 0) {
1264 // The internal field count is set by the constructor function's 1275 // The internal field count is set by the constructor function's
1265 // construct code, so we ensure that there is a constructor 1276 // construct code, so we ensure that there is a constructor
1266 // function to do the setting. 1277 // function to do the setting.
1267 EnsureConstructor(this); 1278 EnsureConstructor(this);
1268 } 1279 }
1269 Utils::OpenHandle(this)->set_internal_field_count(i::Smi::FromInt(value)); 1280 Utils::OpenHandle(this)->set_internal_field_count(i::Smi::FromInt(value));
1270 } 1281 }
1271 1282
1272 1283
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1317 // --- S c r i p t --- 1328 // --- S c r i p t ---
1318 1329
1319 1330
1320 Local<Script> Script::New(v8::Handle<String> source, 1331 Local<Script> Script::New(v8::Handle<String> source,
1321 v8::ScriptOrigin* origin, 1332 v8::ScriptOrigin* origin,
1322 v8::ScriptData* pre_data, 1333 v8::ScriptData* pre_data,
1323 v8::Handle<String> script_data) { 1334 v8::Handle<String> script_data) {
1324 i::Isolate* isolate = i::Isolate::Current(); 1335 i::Isolate* isolate = i::Isolate::Current();
1325 ON_BAILOUT(isolate, "v8::Script::New()", return Local<Script>()); 1336 ON_BAILOUT(isolate, "v8::Script::New()", return Local<Script>());
1326 LOG_API(isolate, "Script::New"); 1337 LOG_API(isolate, "Script::New");
1327 ENTER_V8; 1338 ENTER_V8(isolate);
1328 i::Handle<i::String> str = Utils::OpenHandle(*source); 1339 i::Handle<i::String> str = Utils::OpenHandle(*source);
1329 i::Handle<i::Object> name_obj; 1340 i::Handle<i::Object> name_obj;
1330 int line_offset = 0; 1341 int line_offset = 0;
1331 int column_offset = 0; 1342 int column_offset = 0;
1332 if (origin != NULL) { 1343 if (origin != NULL) {
1333 if (!origin->ResourceName().IsEmpty()) { 1344 if (!origin->ResourceName().IsEmpty()) {
1334 name_obj = Utils::OpenHandle(*origin->ResourceName()); 1345 name_obj = Utils::OpenHandle(*origin->ResourceName());
1335 } 1346 }
1336 if (!origin->ResourceLineOffset().IsEmpty()) { 1347 if (!origin->ResourceLineOffset().IsEmpty()) {
1337 line_offset = static_cast<int>(origin->ResourceLineOffset()->Value()); 1348 line_offset = static_cast<int>(origin->ResourceLineOffset()->Value());
1338 } 1349 }
1339 if (!origin->ResourceColumnOffset().IsEmpty()) { 1350 if (!origin->ResourceColumnOffset().IsEmpty()) {
1340 column_offset = static_cast<int>(origin->ResourceColumnOffset()->Value()); 1351 column_offset = static_cast<int>(origin->ResourceColumnOffset()->Value());
1341 } 1352 }
1342 } 1353 }
1343 EXCEPTION_PREAMBLE(); 1354 EXCEPTION_PREAMBLE(isolate);
1344 i::ScriptDataImpl* pre_data_impl = static_cast<i::ScriptDataImpl*>(pre_data); 1355 i::ScriptDataImpl* pre_data_impl = static_cast<i::ScriptDataImpl*>(pre_data);
1345 // We assert that the pre-data is sane, even though we can actually 1356 // We assert that the pre-data is sane, even though we can actually
1346 // handle it if it turns out not to be in release mode. 1357 // handle it if it turns out not to be in release mode.
1347 ASSERT(pre_data_impl == NULL || pre_data_impl->SanityCheck()); 1358 ASSERT(pre_data_impl == NULL || pre_data_impl->SanityCheck());
1348 // If the pre-data isn't sane we simply ignore it 1359 // If the pre-data isn't sane we simply ignore it
1349 if (pre_data_impl != NULL && !pre_data_impl->SanityCheck()) { 1360 if (pre_data_impl != NULL && !pre_data_impl->SanityCheck()) {
1350 pre_data_impl = NULL; 1361 pre_data_impl = NULL;
1351 } 1362 }
1352 i::Handle<i::SharedFunctionInfo> result = 1363 i::Handle<i::SharedFunctionInfo> result =
1353 i::Compiler::Compile(str, 1364 i::Compiler::Compile(str,
1354 name_obj, 1365 name_obj,
1355 line_offset, 1366 line_offset,
1356 column_offset, 1367 column_offset,
1357 NULL, 1368 NULL,
1358 pre_data_impl, 1369 pre_data_impl,
1359 Utils::OpenHandle(*script_data), 1370 Utils::OpenHandle(*script_data),
1360 i::NOT_NATIVES_CODE); 1371 i::NOT_NATIVES_CODE);
1361 has_pending_exception = result.is_null(); 1372 has_pending_exception = result.is_null();
1362 EXCEPTION_BAILOUT_CHECK(Local<Script>()); 1373 EXCEPTION_BAILOUT_CHECK(isolate, Local<Script>());
1363 return Local<Script>(ToApi<Script>(result)); 1374 return Local<Script>(ToApi<Script>(result));
1364 } 1375 }
1365 1376
1366 1377
1367 Local<Script> Script::New(v8::Handle<String> source, 1378 Local<Script> Script::New(v8::Handle<String> source,
1368 v8::Handle<Value> file_name) { 1379 v8::Handle<Value> file_name) {
1369 ScriptOrigin origin(file_name); 1380 ScriptOrigin origin(file_name);
1370 return New(source, &origin); 1381 return New(source, &origin);
1371 } 1382 }
1372 1383
1373 1384
1374 Local<Script> Script::Compile(v8::Handle<String> source, 1385 Local<Script> Script::Compile(v8::Handle<String> source,
1375 v8::ScriptOrigin* origin, 1386 v8::ScriptOrigin* origin,
1376 v8::ScriptData* pre_data, 1387 v8::ScriptData* pre_data,
1377 v8::Handle<String> script_data) { 1388 v8::Handle<String> script_data) {
1378 i::Isolate* isolate = i::Isolate::Current(); 1389 i::Isolate* isolate = i::Isolate::Current();
1379 ON_BAILOUT(isolate, "v8::Script::Compile()", return Local<Script>()); 1390 ON_BAILOUT(isolate, "v8::Script::Compile()", return Local<Script>());
1380 LOG_API(isolate, "Script::Compile"); 1391 LOG_API(isolate, "Script::Compile");
1381 ENTER_V8; 1392 ENTER_V8(isolate);
1382 Local<Script> generic = New(source, origin, pre_data, script_data); 1393 Local<Script> generic = New(source, origin, pre_data, script_data);
1383 if (generic.IsEmpty()) 1394 if (generic.IsEmpty())
1384 return generic; 1395 return generic;
1385 i::Handle<i::Object> obj = Utils::OpenHandle(*generic); 1396 i::Handle<i::Object> obj = Utils::OpenHandle(*generic);
1386 i::Handle<i::SharedFunctionInfo> function = 1397 i::Handle<i::SharedFunctionInfo> function =
1387 i::Handle<i::SharedFunctionInfo>(i::SharedFunctionInfo::cast(*obj)); 1398 i::Handle<i::SharedFunctionInfo>(i::SharedFunctionInfo::cast(*obj));
1388 i::Handle<i::JSFunction> result = 1399 i::Handle<i::JSFunction> result =
1389 isolate->factory()->NewFunctionFromSharedFunctionInfo( 1400 isolate->factory()->NewFunctionFromSharedFunctionInfo(
1390 function, 1401 function,
1391 isolate->global_context()); 1402 isolate->global_context());
1392 return Local<Script>(ToApi<Script>(result)); 1403 return Local<Script>(ToApi<Script>(result));
1393 } 1404 }
1394 1405
1395 1406
1396 Local<Script> Script::Compile(v8::Handle<String> source, 1407 Local<Script> Script::Compile(v8::Handle<String> source,
1397 v8::Handle<Value> file_name, 1408 v8::Handle<Value> file_name,
1398 v8::Handle<String> script_data) { 1409 v8::Handle<String> script_data) {
1399 ScriptOrigin origin(file_name); 1410 ScriptOrigin origin(file_name);
1400 return Compile(source, &origin, 0, script_data); 1411 return Compile(source, &origin, 0, script_data);
1401 } 1412 }
1402 1413
1403 1414
1404 Local<Value> Script::Run() { 1415 Local<Value> Script::Run() {
1405 i::Isolate* isolate = i::Isolate::Current(); 1416 i::Isolate* isolate = i::Isolate::Current();
1406 ON_BAILOUT(isolate, "v8::Script::Run()", return Local<Value>()); 1417 ON_BAILOUT(isolate, "v8::Script::Run()", return Local<Value>());
1407 LOG_API(isolate, "Script::Run"); 1418 LOG_API(isolate, "Script::Run");
1408 ENTER_V8; 1419 ENTER_V8(isolate);
1409 i::Object* raw_result = NULL; 1420 i::Object* raw_result = NULL;
1410 { 1421 {
1411 HandleScope scope; 1422 i::HandleScope scope(isolate);
1412 i::Handle<i::Object> obj = Utils::OpenHandle(this); 1423 i::Handle<i::Object> obj = Utils::OpenHandle(this);
1413 i::Handle<i::JSFunction> fun; 1424 i::Handle<i::JSFunction> fun;
1414 if (obj->IsSharedFunctionInfo()) { 1425 if (obj->IsSharedFunctionInfo()) {
1415 i::Handle<i::SharedFunctionInfo> 1426 i::Handle<i::SharedFunctionInfo>
1416 function_info(i::SharedFunctionInfo::cast(*obj)); 1427 function_info(i::SharedFunctionInfo::cast(*obj), isolate);
1417 fun = isolate->factory()->NewFunctionFromSharedFunctionInfo( 1428 fun = isolate->factory()->NewFunctionFromSharedFunctionInfo(
1418 function_info, isolate->global_context()); 1429 function_info, isolate->global_context());
1419 } else { 1430 } else {
1420 fun = i::Handle<i::JSFunction>(i::JSFunction::cast(*obj)); 1431 fun = i::Handle<i::JSFunction>(i::JSFunction::cast(*obj), isolate);
1421 } 1432 }
1422 EXCEPTION_PREAMBLE(); 1433 EXCEPTION_PREAMBLE(isolate);
1423 i::Handle<i::Object> receiver( 1434 i::Handle<i::Object> receiver(
1424 isolate->context()->global_proxy()); 1435 isolate->context()->global_proxy(), isolate);
1425 i::Handle<i::Object> result = 1436 i::Handle<i::Object> result =
1426 i::Execution::Call(fun, receiver, 0, NULL, &has_pending_exception); 1437 i::Execution::Call(fun, receiver, 0, NULL, &has_pending_exception);
1427 EXCEPTION_BAILOUT_CHECK(Local<Value>()); 1438 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
1428 raw_result = *result; 1439 raw_result = *result;
1429 } 1440 }
1430 i::Handle<i::Object> result(raw_result); 1441 i::Handle<i::Object> result(raw_result, isolate);
1431 return Utils::ToLocal(result); 1442 return Utils::ToLocal(result);
1432 } 1443 }
1433 1444
1434 1445
1435 static i::Handle<i::SharedFunctionInfo> OpenScript(Script* script) { 1446 static i::Handle<i::SharedFunctionInfo> OpenScript(Script* script) {
1436 i::Handle<i::Object> obj = Utils::OpenHandle(script); 1447 i::Handle<i::Object> obj = Utils::OpenHandle(script);
1437 i::Handle<i::SharedFunctionInfo> result; 1448 i::Handle<i::SharedFunctionInfo> result;
1438 if (obj->IsSharedFunctionInfo()) { 1449 if (obj->IsSharedFunctionInfo()) {
1439 result = 1450 result =
1440 i::Handle<i::SharedFunctionInfo>(i::SharedFunctionInfo::cast(*obj)); 1451 i::Handle<i::SharedFunctionInfo>(i::SharedFunctionInfo::cast(*obj));
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1572 1583
1573 void v8::TryCatch::SetCaptureMessage(bool value) { 1584 void v8::TryCatch::SetCaptureMessage(bool value) {
1574 capture_message_ = value; 1585 capture_message_ = value;
1575 } 1586 }
1576 1587
1577 1588
1578 // --- M e s s a g e --- 1589 // --- M e s s a g e ---
1579 1590
1580 1591
1581 Local<String> Message::Get() const { 1592 Local<String> Message::Get() const {
1582 i::Isolate* isolate = i::Isolate::Current(); 1593 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1583 ON_BAILOUT(isolate, "v8::Message::Get()", return Local<String>()); 1594 ON_BAILOUT(isolate, "v8::Message::Get()", return Local<String>());
1584 ENTER_V8; 1595 ENTER_V8(isolate);
1585 HandleScope scope; 1596 HandleScope scope;
1586 i::Handle<i::Object> obj = Utils::OpenHandle(this); 1597 i::Handle<i::Object> obj = Utils::OpenHandle(this);
1587 i::Handle<i::String> raw_result = i::MessageHandler::GetMessage(obj); 1598 i::Handle<i::String> raw_result = i::MessageHandler::GetMessage(obj);
1588 Local<String> result = Utils::ToLocal(raw_result); 1599 Local<String> result = Utils::ToLocal(raw_result);
1589 return scope.Close(result); 1600 return scope.Close(result);
1590 } 1601 }
1591 1602
1592 1603
1593 v8::Handle<Value> Message::GetScriptResourceName() const { 1604 v8::Handle<Value> Message::GetScriptResourceName() const {
1594 i::Isolate* isolate = i::Isolate::Current(); 1605 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1595 if (IsDeadCheck(isolate, "v8::Message::GetScriptResourceName()")) { 1606 if (IsDeadCheck(isolate, "v8::Message::GetScriptResourceName()")) {
1596 return Local<String>(); 1607 return Local<String>();
1597 } 1608 }
1598 ENTER_V8; 1609 ENTER_V8(isolate);
1599 HandleScope scope; 1610 HandleScope scope;
1600 i::Handle<i::JSMessageObject> message = 1611 i::Handle<i::JSMessageObject> message =
1601 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); 1612 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
1602 // Return this.script.name. 1613 // Return this.script.name.
1603 i::Handle<i::JSValue> script = 1614 i::Handle<i::JSValue> script =
1604 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script())); 1615 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script()));
1605 i::Handle<i::Object> resource_name(i::Script::cast(script->value())->name()); 1616 i::Handle<i::Object> resource_name(i::Script::cast(script->value())->name());
1606 return scope.Close(Utils::ToLocal(resource_name)); 1617 return scope.Close(Utils::ToLocal(resource_name));
1607 } 1618 }
1608 1619
1609 1620
1610 v8::Handle<Value> Message::GetScriptData() const { 1621 v8::Handle<Value> Message::GetScriptData() const {
1611 i::Isolate* isolate = i::Isolate::Current(); 1622 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1612 if (IsDeadCheck(isolate, "v8::Message::GetScriptResourceData()")) { 1623 if (IsDeadCheck(isolate, "v8::Message::GetScriptResourceData()")) {
1613 return Local<Value>(); 1624 return Local<Value>();
1614 } 1625 }
1615 ENTER_V8; 1626 ENTER_V8(isolate);
1616 HandleScope scope; 1627 HandleScope scope;
1617 i::Handle<i::JSMessageObject> message = 1628 i::Handle<i::JSMessageObject> message =
1618 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); 1629 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
1619 // Return this.script.data. 1630 // Return this.script.data.
1620 i::Handle<i::JSValue> script = 1631 i::Handle<i::JSValue> script =
1621 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script())); 1632 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script()));
1622 i::Handle<i::Object> data(i::Script::cast(script->value())->data()); 1633 i::Handle<i::Object> data(i::Script::cast(script->value())->data());
1623 return scope.Close(Utils::ToLocal(data)); 1634 return scope.Close(Utils::ToLocal(data));
1624 } 1635 }
1625 1636
1626 1637
1627 v8::Handle<v8::StackTrace> Message::GetStackTrace() const { 1638 v8::Handle<v8::StackTrace> Message::GetStackTrace() const {
1628 i::Isolate* isolate = i::Isolate::Current(); 1639 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1629 if (IsDeadCheck(isolate, "v8::Message::GetStackTrace()")) { 1640 if (IsDeadCheck(isolate, "v8::Message::GetStackTrace()")) {
1630 return Local<v8::StackTrace>(); 1641 return Local<v8::StackTrace>();
1631 } 1642 }
1632 ENTER_V8; 1643 ENTER_V8(isolate);
1633 HandleScope scope; 1644 HandleScope scope;
1634 i::Handle<i::JSMessageObject> message = 1645 i::Handle<i::JSMessageObject> message =
1635 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); 1646 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
1636 i::Handle<i::Object> stackFramesObj(message->stack_frames()); 1647 i::Handle<i::Object> stackFramesObj(message->stack_frames());
1637 if (!stackFramesObj->IsJSArray()) return v8::Handle<v8::StackTrace>(); 1648 if (!stackFramesObj->IsJSArray()) return v8::Handle<v8::StackTrace>();
1638 i::Handle<i::JSArray> stackTrace = 1649 i::Handle<i::JSArray> stackTrace =
1639 i::Handle<i::JSArray>::cast(stackFramesObj); 1650 i::Handle<i::JSArray>::cast(stackFramesObj);
1640 return scope.Close(Utils::StackTraceToLocal(stackTrace)); 1651 return scope.Close(Utils::StackTraceToLocal(stackTrace));
1641 } 1652 }
1642 1653
(...skipping 21 matching lines...) Expand all
1664 i::Object** argv[1] = { data.location() }; 1675 i::Object** argv[1] = { data.location() };
1665 return CallV8HeapFunction(name, 1676 return CallV8HeapFunction(name,
1666 i::Isolate::Current()->js_builtins_object(), 1677 i::Isolate::Current()->js_builtins_object(),
1667 1, 1678 1,
1668 argv, 1679 argv,
1669 has_pending_exception); 1680 has_pending_exception);
1670 } 1681 }
1671 1682
1672 1683
1673 int Message::GetLineNumber() const { 1684 int Message::GetLineNumber() const {
1674 i::Isolate* isolate = i::Isolate::Current(); 1685 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1675 ON_BAILOUT(isolate, "v8::Message::GetLineNumber()", return kNoLineNumberInfo); 1686 ON_BAILOUT(isolate, "v8::Message::GetLineNumber()", return kNoLineNumberInfo);
1676 ENTER_V8; 1687 ENTER_V8(isolate);
1677 i::HandleScope scope(isolate); 1688 i::HandleScope scope(isolate);
1678 1689
1679 EXCEPTION_PREAMBLE(); 1690 EXCEPTION_PREAMBLE(isolate);
1680 i::Handle<i::Object> result = CallV8HeapFunction("GetLineNumber", 1691 i::Handle<i::Object> result = CallV8HeapFunction("GetLineNumber",
1681 Utils::OpenHandle(this), 1692 Utils::OpenHandle(this),
1682 &has_pending_exception); 1693 &has_pending_exception);
1683 EXCEPTION_BAILOUT_CHECK(0); 1694 EXCEPTION_BAILOUT_CHECK(isolate, 0);
1684 return static_cast<int>(result->Number()); 1695 return static_cast<int>(result->Number());
1685 } 1696 }
1686 1697
1687 1698
1688 int Message::GetStartPosition() const { 1699 int Message::GetStartPosition() const {
1689 i::Isolate* isolate = i::Isolate::Current(); 1700 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1690 if (IsDeadCheck(isolate, "v8::Message::GetStartPosition()")) return 0; 1701 if (IsDeadCheck(isolate, "v8::Message::GetStartPosition()")) return 0;
1691 ENTER_V8; 1702 ENTER_V8(isolate);
1692 i::HandleScope scope(isolate); 1703 i::HandleScope scope(isolate);
1693 i::Handle<i::JSMessageObject> message = 1704 i::Handle<i::JSMessageObject> message =
1694 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); 1705 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
1695 return message->start_position(); 1706 return message->start_position();
1696 } 1707 }
1697 1708
1698 1709
1699 int Message::GetEndPosition() const { 1710 int Message::GetEndPosition() const {
1700 i::Isolate* isolate = i::Isolate::Current(); 1711 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1701 if (IsDeadCheck(isolate, "v8::Message::GetEndPosition()")) return 0; 1712 if (IsDeadCheck(isolate, "v8::Message::GetEndPosition()")) return 0;
1702 ENTER_V8; 1713 ENTER_V8(isolate);
1703 i::HandleScope scope(isolate); 1714 i::HandleScope scope(isolate);
1704 i::Handle<i::JSMessageObject> message = 1715 i::Handle<i::JSMessageObject> message =
1705 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); 1716 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
1706 return message->end_position(); 1717 return message->end_position();
1707 } 1718 }
1708 1719
1709 1720
1710 int Message::GetStartColumn() const { 1721 int Message::GetStartColumn() const {
1711 i::Isolate* isolate = i::Isolate::Current(); 1722 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1712 if (IsDeadCheck(isolate, "v8::Message::GetStartColumn()")) { 1723 if (IsDeadCheck(isolate, "v8::Message::GetStartColumn()")) {
1713 return kNoColumnInfo; 1724 return kNoColumnInfo;
1714 } 1725 }
1715 ENTER_V8; 1726 ENTER_V8(isolate);
1716 i::HandleScope scope(isolate); 1727 i::HandleScope scope(isolate);
1717 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); 1728 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this);
1718 EXCEPTION_PREAMBLE(); 1729 EXCEPTION_PREAMBLE(isolate);
1719 i::Handle<i::Object> start_col_obj = CallV8HeapFunction( 1730 i::Handle<i::Object> start_col_obj = CallV8HeapFunction(
1720 "GetPositionInLine", 1731 "GetPositionInLine",
1721 data_obj, 1732 data_obj,
1722 &has_pending_exception); 1733 &has_pending_exception);
1723 EXCEPTION_BAILOUT_CHECK(0); 1734 EXCEPTION_BAILOUT_CHECK(isolate, 0);
1724 return static_cast<int>(start_col_obj->Number()); 1735 return static_cast<int>(start_col_obj->Number());
1725 } 1736 }
1726 1737
1727 1738
1728 int Message::GetEndColumn() const { 1739 int Message::GetEndColumn() const {
1729 i::Isolate* isolate = i::Isolate::Current(); 1740 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1730 if (IsDeadCheck(isolate, "v8::Message::GetEndColumn()")) return kNoColumnInfo; 1741 if (IsDeadCheck(isolate, "v8::Message::GetEndColumn()")) return kNoColumnInfo;
1731 ENTER_V8; 1742 ENTER_V8(isolate);
1732 i::HandleScope scope(isolate); 1743 i::HandleScope scope(isolate);
1733 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); 1744 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this);
1734 EXCEPTION_PREAMBLE(); 1745 EXCEPTION_PREAMBLE(isolate);
1735 i::Handle<i::Object> start_col_obj = CallV8HeapFunction( 1746 i::Handle<i::Object> start_col_obj = CallV8HeapFunction(
1736 "GetPositionInLine", 1747 "GetPositionInLine",
1737 data_obj, 1748 data_obj,
1738 &has_pending_exception); 1749 &has_pending_exception);
1739 EXCEPTION_BAILOUT_CHECK(0); 1750 EXCEPTION_BAILOUT_CHECK(isolate, 0);
1740 i::Handle<i::JSMessageObject> message = 1751 i::Handle<i::JSMessageObject> message =
1741 i::Handle<i::JSMessageObject>::cast(data_obj); 1752 i::Handle<i::JSMessageObject>::cast(data_obj);
1742 int start = message->start_position(); 1753 int start = message->start_position();
1743 int end = message->end_position(); 1754 int end = message->end_position();
1744 return static_cast<int>(start_col_obj->Number()) + (end - start); 1755 return static_cast<int>(start_col_obj->Number()) + (end - start);
1745 } 1756 }
1746 1757
1747 1758
1748 Local<String> Message::GetSourceLine() const { 1759 Local<String> Message::GetSourceLine() const {
1749 i::Isolate* isolate = i::Isolate::Current(); 1760 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1750 ON_BAILOUT(isolate, "v8::Message::GetSourceLine()", return Local<String>()); 1761 ON_BAILOUT(isolate, "v8::Message::GetSourceLine()", return Local<String>());
1751 ENTER_V8; 1762 ENTER_V8(isolate);
1752 HandleScope scope; 1763 HandleScope scope;
1753 EXCEPTION_PREAMBLE(); 1764 EXCEPTION_PREAMBLE(isolate);
1754 i::Handle<i::Object> result = CallV8HeapFunction("GetSourceLine", 1765 i::Handle<i::Object> result = CallV8HeapFunction("GetSourceLine",
1755 Utils::OpenHandle(this), 1766 Utils::OpenHandle(this),
1756 &has_pending_exception); 1767 &has_pending_exception);
1757 EXCEPTION_BAILOUT_CHECK(Local<v8::String>()); 1768 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::String>());
1758 if (result->IsString()) { 1769 if (result->IsString()) {
1759 return scope.Close(Utils::ToLocal(i::Handle<i::String>::cast(result))); 1770 return scope.Close(Utils::ToLocal(i::Handle<i::String>::cast(result)));
1760 } else { 1771 } else {
1761 return Local<String>(); 1772 return Local<String>();
1762 } 1773 }
1763 } 1774 }
1764 1775
1765 1776
1766 void Message::PrintCurrentStackTrace(FILE* out) { 1777 void Message::PrintCurrentStackTrace(FILE* out) {
1767 i::Isolate* isolate = i::Isolate::Current(); 1778 i::Isolate* isolate = i::Isolate::Current();
1768 if (IsDeadCheck(isolate, "v8::Message::PrintCurrentStackTrace()")) return; 1779 if (IsDeadCheck(isolate, "v8::Message::PrintCurrentStackTrace()")) return;
1769 ENTER_V8; 1780 ENTER_V8(isolate);
1770 isolate->PrintCurrentStackTrace(out); 1781 isolate->PrintCurrentStackTrace(out);
1771 } 1782 }
1772 1783
1773 1784
1774 // --- S t a c k T r a c e --- 1785 // --- S t a c k T r a c e ---
1775 1786
1776 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const { 1787 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const {
1777 i::Isolate* isolate = i::Isolate::Current(); 1788 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1778 if (IsDeadCheck(isolate, "v8::StackTrace::GetFrame()")) { 1789 if (IsDeadCheck(isolate, "v8::StackTrace::GetFrame()")) {
1779 return Local<StackFrame>(); 1790 return Local<StackFrame>();
1780 } 1791 }
1781 ENTER_V8; 1792 ENTER_V8(isolate);
1782 HandleScope scope; 1793 HandleScope scope;
1783 i::Handle<i::JSArray> self = Utils::OpenHandle(this); 1794 i::Handle<i::JSArray> self = Utils::OpenHandle(this);
1784 i::Object* raw_object = self->GetElementNoExceptionThrown(index); 1795 i::Object* raw_object = self->GetElementNoExceptionThrown(index);
1785 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_object)); 1796 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_object));
1786 return scope.Close(Utils::StackFrameToLocal(obj)); 1797 return scope.Close(Utils::StackFrameToLocal(obj));
1787 } 1798 }
1788 1799
1789 1800
1790 int StackTrace::GetFrameCount() const { 1801 int StackTrace::GetFrameCount() const {
1791 i::Isolate* isolate = i::Isolate::Current(); 1802 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1792 if (IsDeadCheck(isolate, "v8::StackTrace::GetFrameCount()")) return -1; 1803 if (IsDeadCheck(isolate, "v8::StackTrace::GetFrameCount()")) return -1;
1793 ENTER_V8; 1804 ENTER_V8(isolate);
1794 return i::Smi::cast(Utils::OpenHandle(this)->length())->value(); 1805 return i::Smi::cast(Utils::OpenHandle(this)->length())->value();
1795 } 1806 }
1796 1807
1797 1808
1798 Local<Array> StackTrace::AsArray() { 1809 Local<Array> StackTrace::AsArray() {
1799 i::Isolate* isolate = i::Isolate::Current(); 1810 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1800 if (IsDeadCheck(isolate, "v8::StackTrace::AsArray()")) Local<Array>(); 1811 if (IsDeadCheck(isolate, "v8::StackTrace::AsArray()")) Local<Array>();
1801 ENTER_V8; 1812 ENTER_V8(isolate);
1802 return Utils::ToLocal(Utils::OpenHandle(this)); 1813 return Utils::ToLocal(Utils::OpenHandle(this));
1803 } 1814 }
1804 1815
1805 1816
1806 Local<StackTrace> StackTrace::CurrentStackTrace(int frame_limit, 1817 Local<StackTrace> StackTrace::CurrentStackTrace(int frame_limit,
1807 StackTraceOptions options) { 1818 StackTraceOptions options) {
1808 i::Isolate* isolate = i::Isolate::Current(); 1819 i::Isolate* isolate = i::Isolate::Current();
1809 if (IsDeadCheck(isolate, "v8::StackTrace::CurrentStackTrace()")) { 1820 if (IsDeadCheck(isolate, "v8::StackTrace::CurrentStackTrace()")) {
1810 Local<StackTrace>(); 1821 Local<StackTrace>();
1811 } 1822 }
1812 ENTER_V8; 1823 ENTER_V8(isolate);
1813 i::Handle<i::JSArray> stackTrace = 1824 i::Handle<i::JSArray> stackTrace =
1814 isolate->CaptureCurrentStackTrace(frame_limit, options); 1825 isolate->CaptureCurrentStackTrace(frame_limit, options);
1815 return Utils::StackTraceToLocal(stackTrace); 1826 return Utils::StackTraceToLocal(stackTrace);
1816 } 1827 }
1817 1828
1818 1829
1819 // --- S t a c k F r a m e --- 1830 // --- S t a c k F r a m e ---
1820 1831
1821 int StackFrame::GetLineNumber() const { 1832 int StackFrame::GetLineNumber() const {
1822 i::Isolate* isolate = i::Isolate::Current(); 1833 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1823 if (IsDeadCheck(isolate, "v8::StackFrame::GetLineNumber()")) { 1834 if (IsDeadCheck(isolate, "v8::StackFrame::GetLineNumber()")) {
1824 return Message::kNoLineNumberInfo; 1835 return Message::kNoLineNumberInfo;
1825 } 1836 }
1826 ENTER_V8; 1837 ENTER_V8(isolate);
1827 i::HandleScope scope(isolate); 1838 i::HandleScope scope(isolate);
1828 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 1839 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
1829 i::Handle<i::Object> line = GetProperty(self, "lineNumber"); 1840 i::Handle<i::Object> line = GetProperty(self, "lineNumber");
1830 if (!line->IsSmi()) { 1841 if (!line->IsSmi()) {
1831 return Message::kNoLineNumberInfo; 1842 return Message::kNoLineNumberInfo;
1832 } 1843 }
1833 return i::Smi::cast(*line)->value(); 1844 return i::Smi::cast(*line)->value();
1834 } 1845 }
1835 1846
1836 1847
1837 int StackFrame::GetColumn() const { 1848 int StackFrame::GetColumn() const {
1838 i::Isolate* isolate = i::Isolate::Current(); 1849 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1839 if (IsDeadCheck(isolate, "v8::StackFrame::GetColumn()")) { 1850 if (IsDeadCheck(isolate, "v8::StackFrame::GetColumn()")) {
1840 return Message::kNoColumnInfo; 1851 return Message::kNoColumnInfo;
1841 } 1852 }
1842 ENTER_V8; 1853 ENTER_V8(isolate);
1843 i::HandleScope scope(isolate); 1854 i::HandleScope scope(isolate);
1844 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 1855 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
1845 i::Handle<i::Object> column = GetProperty(self, "column"); 1856 i::Handle<i::Object> column = GetProperty(self, "column");
1846 if (!column->IsSmi()) { 1857 if (!column->IsSmi()) {
1847 return Message::kNoColumnInfo; 1858 return Message::kNoColumnInfo;
1848 } 1859 }
1849 return i::Smi::cast(*column)->value(); 1860 return i::Smi::cast(*column)->value();
1850 } 1861 }
1851 1862
1852 1863
1853 Local<String> StackFrame::GetScriptName() const { 1864 Local<String> StackFrame::GetScriptName() const {
1854 i::Isolate* isolate = i::Isolate::Current(); 1865 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1855 if (IsDeadCheck(isolate, "v8::StackFrame::GetScriptName()")) { 1866 if (IsDeadCheck(isolate, "v8::StackFrame::GetScriptName()")) {
1856 return Local<String>(); 1867 return Local<String>();
1857 } 1868 }
1858 ENTER_V8; 1869 ENTER_V8(isolate);
1859 HandleScope scope; 1870 HandleScope scope;
1860 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 1871 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
1861 i::Handle<i::Object> name = GetProperty(self, "scriptName"); 1872 i::Handle<i::Object> name = GetProperty(self, "scriptName");
1862 if (!name->IsString()) { 1873 if (!name->IsString()) {
1863 return Local<String>(); 1874 return Local<String>();
1864 } 1875 }
1865 return scope.Close(Local<String>::Cast(Utils::ToLocal(name))); 1876 return scope.Close(Local<String>::Cast(Utils::ToLocal(name)));
1866 } 1877 }
1867 1878
1868 1879
1869 Local<String> StackFrame::GetScriptNameOrSourceURL() const { 1880 Local<String> StackFrame::GetScriptNameOrSourceURL() const {
1870 i::Isolate* isolate = i::Isolate::Current(); 1881 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1871 if (IsDeadCheck(isolate, "v8::StackFrame::GetScriptNameOrSourceURL()")) { 1882 if (IsDeadCheck(isolate, "v8::StackFrame::GetScriptNameOrSourceURL()")) {
1872 return Local<String>(); 1883 return Local<String>();
1873 } 1884 }
1874 ENTER_V8; 1885 ENTER_V8(isolate);
1875 HandleScope scope; 1886 HandleScope scope;
1876 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 1887 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
1877 i::Handle<i::Object> name = GetProperty(self, "scriptNameOrSourceURL"); 1888 i::Handle<i::Object> name = GetProperty(self, "scriptNameOrSourceURL");
1878 if (!name->IsString()) { 1889 if (!name->IsString()) {
1879 return Local<String>(); 1890 return Local<String>();
1880 } 1891 }
1881 return scope.Close(Local<String>::Cast(Utils::ToLocal(name))); 1892 return scope.Close(Local<String>::Cast(Utils::ToLocal(name)));
1882 } 1893 }
1883 1894
1884 1895
1885 Local<String> StackFrame::GetFunctionName() const { 1896 Local<String> StackFrame::GetFunctionName() const {
1886 i::Isolate* isolate = i::Isolate::Current(); 1897 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1887 if (IsDeadCheck(isolate, "v8::StackFrame::GetFunctionName()")) { 1898 if (IsDeadCheck(isolate, "v8::StackFrame::GetFunctionName()")) {
1888 return Local<String>(); 1899 return Local<String>();
1889 } 1900 }
1890 ENTER_V8; 1901 ENTER_V8(isolate);
1891 HandleScope scope; 1902 HandleScope scope;
1892 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 1903 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
1893 i::Handle<i::Object> name = GetProperty(self, "functionName"); 1904 i::Handle<i::Object> name = GetProperty(self, "functionName");
1894 if (!name->IsString()) { 1905 if (!name->IsString()) {
1895 return Local<String>(); 1906 return Local<String>();
1896 } 1907 }
1897 return scope.Close(Local<String>::Cast(Utils::ToLocal(name))); 1908 return scope.Close(Local<String>::Cast(Utils::ToLocal(name)));
1898 } 1909 }
1899 1910
1900 1911
1901 bool StackFrame::IsEval() const { 1912 bool StackFrame::IsEval() const {
1902 i::Isolate* isolate = i::Isolate::Current(); 1913 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1903 if (IsDeadCheck(isolate, "v8::StackFrame::IsEval()")) return false; 1914 if (IsDeadCheck(isolate, "v8::StackFrame::IsEval()")) return false;
1904 ENTER_V8; 1915 ENTER_V8(isolate);
1905 i::HandleScope scope(isolate); 1916 i::HandleScope scope(isolate);
1906 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 1917 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
1907 i::Handle<i::Object> is_eval = GetProperty(self, "isEval"); 1918 i::Handle<i::Object> is_eval = GetProperty(self, "isEval");
1908 return is_eval->IsTrue(); 1919 return is_eval->IsTrue();
1909 } 1920 }
1910 1921
1911 1922
1912 bool StackFrame::IsConstructor() const { 1923 bool StackFrame::IsConstructor() const {
1913 i::Isolate* isolate = i::Isolate::Current(); 1924 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1914 if (IsDeadCheck(isolate, "v8::StackFrame::IsConstructor()")) return false; 1925 if (IsDeadCheck(isolate, "v8::StackFrame::IsConstructor()")) return false;
1915 ENTER_V8; 1926 ENTER_V8(isolate);
1916 i::HandleScope scope(isolate); 1927 i::HandleScope scope(isolate);
1917 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 1928 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
1918 i::Handle<i::Object> is_constructor = GetProperty(self, "isConstructor"); 1929 i::Handle<i::Object> is_constructor = GetProperty(self, "isConstructor");
1919 return is_constructor->IsTrue(); 1930 return is_constructor->IsTrue();
1920 } 1931 }
1921 1932
1922 1933
1923 // --- D a t a --- 1934 // --- D a t a ---
1924 1935
1925 bool Value::IsUndefined() const { 1936 bool Value::IsUndefined() const {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
2030 2041
2031 2042
2032 bool Value::IsRegExp() const { 2043 bool Value::IsRegExp() const {
2033 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsRegExp()")) return false; 2044 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsRegExp()")) return false;
2034 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2045 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2035 return obj->IsJSRegExp(); 2046 return obj->IsJSRegExp();
2036 } 2047 }
2037 2048
2038 2049
2039 Local<String> Value::ToString() const { 2050 Local<String> Value::ToString() const {
2040 i::Isolate* isolate = i::Isolate::Current();
2041 if (IsDeadCheck(isolate, "v8::Value::ToString()")) {
2042 return Local<String>();
2043 }
2044 LOG_API(isolate, "ToString");
2045 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2051 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2046 i::Handle<i::Object> str; 2052 i::Handle<i::Object> str;
2047 if (obj->IsString()) { 2053 if (obj->IsString()) {
2048 str = obj; 2054 str = obj;
2049 } else { 2055 } else {
2050 ENTER_V8; 2056 i::Isolate* isolate = i::Isolate::Current();
2051 EXCEPTION_PREAMBLE(); 2057 if (IsDeadCheck(isolate, "v8::Value::ToString()")) {
2058 return Local<String>();
2059 }
2060 LOG_API(isolate, "ToString");
2061 ENTER_V8(isolate);
2062 EXCEPTION_PREAMBLE(isolate);
2052 str = i::Execution::ToString(obj, &has_pending_exception); 2063 str = i::Execution::ToString(obj, &has_pending_exception);
2053 EXCEPTION_BAILOUT_CHECK(Local<String>()); 2064 EXCEPTION_BAILOUT_CHECK(isolate, Local<String>());
2054 } 2065 }
2055 return Local<String>(ToApi<String>(str)); 2066 return Local<String>(ToApi<String>(str));
2056 } 2067 }
2057 2068
2058 2069
2059 Local<String> Value::ToDetailString() const { 2070 Local<String> Value::ToDetailString() const {
2060 i::Isolate* isolate = i::Isolate::Current();
2061 if (IsDeadCheck(isolate, "v8::Value::ToDetailString()")) {
2062 return Local<String>();
2063 }
2064 LOG_API(isolate, "ToDetailString");
2065 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2071 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2066 i::Handle<i::Object> str; 2072 i::Handle<i::Object> str;
2067 if (obj->IsString()) { 2073 if (obj->IsString()) {
2068 str = obj; 2074 str = obj;
2069 } else { 2075 } else {
2070 ENTER_V8; 2076 i::Isolate* isolate = i::Isolate::Current();
2071 EXCEPTION_PREAMBLE(); 2077 if (IsDeadCheck(isolate, "v8::Value::ToDetailString()")) {
2078 return Local<String>();
2079 }
2080 LOG_API(isolate, "ToDetailString");
2081 ENTER_V8(isolate);
2082 EXCEPTION_PREAMBLE(isolate);
2072 str = i::Execution::ToDetailString(obj, &has_pending_exception); 2083 str = i::Execution::ToDetailString(obj, &has_pending_exception);
2073 EXCEPTION_BAILOUT_CHECK(Local<String>()); 2084 EXCEPTION_BAILOUT_CHECK(isolate, Local<String>());
2074 } 2085 }
2075 return Local<String>(ToApi<String>(str)); 2086 return Local<String>(ToApi<String>(str));
2076 } 2087 }
2077 2088
2078 2089
2079 Local<v8::Object> Value::ToObject() const { 2090 Local<v8::Object> Value::ToObject() const {
2080 i::Isolate* isolate = i::Isolate::Current();
2081 if (IsDeadCheck(isolate, "v8::Value::ToObject()")) return Local<v8::Object>();
2082 LOG_API(isolate, "ToObject");
2083 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2091 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2084 i::Handle<i::Object> val; 2092 i::Handle<i::Object> val;
2085 if (obj->IsJSObject()) { 2093 if (obj->IsJSObject()) {
2086 val = obj; 2094 val = obj;
2087 } else { 2095 } else {
2088 ENTER_V8; 2096 i::Isolate* isolate = i::Isolate::Current();
2089 EXCEPTION_PREAMBLE(); 2097 if (IsDeadCheck(isolate, "v8::Value::ToObject()")) {
2098 return Local<v8::Object>();
2099 }
2100 LOG_API(isolate, "ToObject");
2101 ENTER_V8(isolate);
2102 EXCEPTION_PREAMBLE(isolate);
2090 val = i::Execution::ToObject(obj, &has_pending_exception); 2103 val = i::Execution::ToObject(obj, &has_pending_exception);
2091 EXCEPTION_BAILOUT_CHECK(Local<v8::Object>()); 2104 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>());
2092 } 2105 }
2093 return Local<v8::Object>(ToApi<Object>(val)); 2106 return Local<v8::Object>(ToApi<Object>(val));
2094 } 2107 }
2095 2108
2096 2109
2097 Local<Boolean> Value::ToBoolean() const { 2110 Local<Boolean> Value::ToBoolean() const {
2098 i::Isolate* isolate = i::Isolate::Current();
2099 if (IsDeadCheck(isolate, "v8::Value::ToBoolean()")) {
2100 return Local<Boolean>();
2101 }
2102 LOG_API(isolate, "ToBoolean");
2103 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2111 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2104 if (obj->IsBoolean()) { 2112 if (obj->IsBoolean()) {
2105 return Local<Boolean>(ToApi<Boolean>(obj)); 2113 return Local<Boolean>(ToApi<Boolean>(obj));
2106 } else { 2114 } else {
2107 ENTER_V8; 2115 i::Isolate* isolate = i::Isolate::Current();
2116 if (IsDeadCheck(isolate, "v8::Value::ToBoolean()")) {
2117 return Local<Boolean>();
2118 }
2119 LOG_API(isolate, "ToBoolean");
2120 ENTER_V8(isolate);
2108 i::Handle<i::Object> val = i::Execution::ToBoolean(obj); 2121 i::Handle<i::Object> val = i::Execution::ToBoolean(obj);
2109 return Local<Boolean>(ToApi<Boolean>(val)); 2122 return Local<Boolean>(ToApi<Boolean>(val));
2110 } 2123 }
2111 } 2124 }
2112 2125
2113 2126
2114 Local<Number> Value::ToNumber() const { 2127 Local<Number> Value::ToNumber() const {
2115 i::Isolate* isolate = i::Isolate::Current();
2116 if (IsDeadCheck(isolate, "v8::Value::ToNumber()")) return Local<Number>();
2117 LOG_API(isolate, "ToNumber");
2118 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2128 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2119 i::Handle<i::Object> num; 2129 i::Handle<i::Object> num;
2120 if (obj->IsNumber()) { 2130 if (obj->IsNumber()) {
2121 num = obj; 2131 num = obj;
2122 } else { 2132 } else {
2123 ENTER_V8; 2133 i::Isolate* isolate = i::Isolate::Current();
2124 EXCEPTION_PREAMBLE(); 2134 if (IsDeadCheck(isolate, "v8::Value::ToNumber()")) {
2135 return Local<Number>();
2136 }
2137 LOG_API(isolate, "ToNumber");
2138 ENTER_V8(isolate);
2139 EXCEPTION_PREAMBLE(isolate);
2125 num = i::Execution::ToNumber(obj, &has_pending_exception); 2140 num = i::Execution::ToNumber(obj, &has_pending_exception);
2126 EXCEPTION_BAILOUT_CHECK(Local<Number>()); 2141 EXCEPTION_BAILOUT_CHECK(isolate, Local<Number>());
2127 } 2142 }
2128 return Local<Number>(ToApi<Number>(num)); 2143 return Local<Number>(ToApi<Number>(num));
2129 } 2144 }
2130 2145
2131 2146
2132 Local<Integer> Value::ToInteger() const { 2147 Local<Integer> Value::ToInteger() const {
2133 i::Isolate* isolate = i::Isolate::Current();
2134 if (IsDeadCheck(isolate, "v8::Value::ToInteger()")) return Local<Integer>();
2135 LOG_API(isolate, "ToInteger");
2136 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2148 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2137 i::Handle<i::Object> num; 2149 i::Handle<i::Object> num;
2138 if (obj->IsSmi()) { 2150 if (obj->IsSmi()) {
2139 num = obj; 2151 num = obj;
2140 } else { 2152 } else {
2141 ENTER_V8; 2153 i::Isolate* isolate = i::Isolate::Current();
2142 EXCEPTION_PREAMBLE(); 2154 if (IsDeadCheck(isolate, "v8::Value::ToInteger()")) return Local<Integer>();
2155 LOG_API(isolate, "ToInteger");
2156 ENTER_V8(isolate);
2157 EXCEPTION_PREAMBLE(isolate);
2143 num = i::Execution::ToInteger(obj, &has_pending_exception); 2158 num = i::Execution::ToInteger(obj, &has_pending_exception);
2144 EXCEPTION_BAILOUT_CHECK(Local<Integer>()); 2159 EXCEPTION_BAILOUT_CHECK(isolate, Local<Integer>());
2145 } 2160 }
2146 return Local<Integer>(ToApi<Integer>(num)); 2161 return Local<Integer>(ToApi<Integer>(num));
2147 } 2162 }
2148 2163
2149 2164
2150 void External::CheckCast(v8::Value* that) { 2165 void External::CheckCast(v8::Value* that) {
2151 if (IsDeadCheck(i::Isolate::Current(), "v8::External::Cast()")) return; 2166 if (IsDeadCheck(i::Isolate::Current(), "v8::External::Cast()")) return;
2152 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2167 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2153 ApiCheck(obj->IsProxy(), 2168 ApiCheck(obj->IsProxy(),
2154 "v8::External::Cast()", 2169 "v8::External::Cast()",
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
2222 void v8::RegExp::CheckCast(v8::Value* that) { 2237 void v8::RegExp::CheckCast(v8::Value* that) {
2223 if (IsDeadCheck(i::Isolate::Current(), "v8::RegExp::Cast()")) return; 2238 if (IsDeadCheck(i::Isolate::Current(), "v8::RegExp::Cast()")) return;
2224 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2239 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2225 ApiCheck(obj->IsJSRegExp(), 2240 ApiCheck(obj->IsJSRegExp(),
2226 "v8::RegExp::Cast()", 2241 "v8::RegExp::Cast()",
2227 "Could not convert to regular expression"); 2242 "Could not convert to regular expression");
2228 } 2243 }
2229 2244
2230 2245
2231 bool Value::BooleanValue() const { 2246 bool Value::BooleanValue() const {
2232 i::Isolate* isolate = i::Isolate::Current();
2233 if (IsDeadCheck(isolate, "v8::Value::BooleanValue()")) return false;
2234 LOG_API(isolate, "BooleanValue");
2235 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2247 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2236 if (obj->IsBoolean()) { 2248 if (obj->IsBoolean()) {
2237 return obj->IsTrue(); 2249 return obj->IsTrue();
2238 } else { 2250 } else {
2239 ENTER_V8; 2251 i::Isolate* isolate = i::Isolate::Current();
2252 if (IsDeadCheck(isolate, "v8::Value::BooleanValue()")) return false;
2253 LOG_API(isolate, "BooleanValue");
2254 ENTER_V8(isolate);
2240 i::Handle<i::Object> value = i::Execution::ToBoolean(obj); 2255 i::Handle<i::Object> value = i::Execution::ToBoolean(obj);
2241 return value->IsTrue(); 2256 return value->IsTrue();
2242 } 2257 }
2243 } 2258 }
2244 2259
2245 2260
2246 double Value::NumberValue() const { 2261 double Value::NumberValue() const {
2247 i::Isolate* isolate = i::Isolate::Current();
2248 if (IsDeadCheck(isolate, "v8::Value::NumberValue()")) {
2249 return i::OS::nan_value();
2250 }
2251 LOG_API(isolate, "NumberValue");
2252 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2262 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2253 i::Handle<i::Object> num; 2263 i::Handle<i::Object> num;
2254 if (obj->IsNumber()) { 2264 if (obj->IsNumber()) {
2255 num = obj; 2265 num = obj;
2256 } else { 2266 } else {
2257 ENTER_V8; 2267 i::Isolate* isolate = i::Isolate::Current();
2258 EXCEPTION_PREAMBLE(); 2268 if (IsDeadCheck(isolate, "v8::Value::NumberValue()")) {
2269 return i::OS::nan_value();
2270 }
2271 LOG_API(isolate, "NumberValue");
2272 ENTER_V8(isolate);
2273 EXCEPTION_PREAMBLE(isolate);
2259 num = i::Execution::ToNumber(obj, &has_pending_exception); 2274 num = i::Execution::ToNumber(obj, &has_pending_exception);
2260 EXCEPTION_BAILOUT_CHECK(i::OS::nan_value()); 2275 EXCEPTION_BAILOUT_CHECK(isolate, i::OS::nan_value());
2261 } 2276 }
2262 return num->Number(); 2277 return num->Number();
2263 } 2278 }
2264 2279
2265 2280
2266 int64_t Value::IntegerValue() const { 2281 int64_t Value::IntegerValue() const {
2267 i::Isolate* isolate = i::Isolate::Current();
2268 if (IsDeadCheck(isolate, "v8::Value::IntegerValue()")) return 0;
2269 LOG_API(isolate, "IntegerValue");
2270 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2282 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2271 i::Handle<i::Object> num; 2283 i::Handle<i::Object> num;
2272 if (obj->IsNumber()) { 2284 if (obj->IsNumber()) {
2273 num = obj; 2285 num = obj;
2274 } else { 2286 } else {
2275 ENTER_V8; 2287 i::Isolate* isolate = i::Isolate::Current();
2276 EXCEPTION_PREAMBLE(); 2288 if (IsDeadCheck(isolate, "v8::Value::IntegerValue()")) return 0;
2289 LOG_API(isolate, "IntegerValue");
2290 ENTER_V8(isolate);
2291 EXCEPTION_PREAMBLE(isolate);
2277 num = i::Execution::ToInteger(obj, &has_pending_exception); 2292 num = i::Execution::ToInteger(obj, &has_pending_exception);
2278 EXCEPTION_BAILOUT_CHECK(0); 2293 EXCEPTION_BAILOUT_CHECK(isolate, 0);
2279 } 2294 }
2280 if (num->IsSmi()) { 2295 if (num->IsSmi()) {
2281 return i::Smi::cast(*num)->value(); 2296 return i::Smi::cast(*num)->value();
2282 } else { 2297 } else {
2283 return static_cast<int64_t>(num->Number()); 2298 return static_cast<int64_t>(num->Number());
2284 } 2299 }
2285 } 2300 }
2286 2301
2287 2302
2288 Local<Int32> Value::ToInt32() const { 2303 Local<Int32> Value::ToInt32() const {
2289 i::Isolate* isolate = i::Isolate::Current();
2290 if (IsDeadCheck(isolate, "v8::Value::ToInt32()")) return Local<Int32>();
2291 LOG_API(isolate, "ToInt32");
2292 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2304 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2293 i::Handle<i::Object> num; 2305 i::Handle<i::Object> num;
2294 if (obj->IsSmi()) { 2306 if (obj->IsSmi()) {
2295 num = obj; 2307 num = obj;
2296 } else { 2308 } else {
2297 ENTER_V8; 2309 i::Isolate* isolate = i::Isolate::Current();
2298 EXCEPTION_PREAMBLE(); 2310 if (IsDeadCheck(isolate, "v8::Value::ToInt32()")) return Local<Int32>();
2311 LOG_API(isolate, "ToInt32");
2312 ENTER_V8(isolate);
2313 EXCEPTION_PREAMBLE(isolate);
2299 num = i::Execution::ToInt32(obj, &has_pending_exception); 2314 num = i::Execution::ToInt32(obj, &has_pending_exception);
2300 EXCEPTION_BAILOUT_CHECK(Local<Int32>()); 2315 EXCEPTION_BAILOUT_CHECK(isolate, Local<Int32>());
2301 } 2316 }
2302 return Local<Int32>(ToApi<Int32>(num)); 2317 return Local<Int32>(ToApi<Int32>(num));
2303 } 2318 }
2304 2319
2305 2320
2306 Local<Uint32> Value::ToUint32() const { 2321 Local<Uint32> Value::ToUint32() const {
2307 i::Isolate* isolate = i::Isolate::Current();
2308 if (IsDeadCheck(isolate, "v8::Value::ToUint32()")) return Local<Uint32>();
2309 LOG_API(isolate, "ToUInt32");
2310 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2322 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2311 i::Handle<i::Object> num; 2323 i::Handle<i::Object> num;
2312 if (obj->IsSmi()) { 2324 if (obj->IsSmi()) {
2313 num = obj; 2325 num = obj;
2314 } else { 2326 } else {
2315 ENTER_V8; 2327 i::Isolate* isolate = i::Isolate::Current();
2316 EXCEPTION_PREAMBLE(); 2328 if (IsDeadCheck(isolate, "v8::Value::ToUint32()")) return Local<Uint32>();
2329 LOG_API(isolate, "ToUInt32");
2330 ENTER_V8(isolate);
2331 EXCEPTION_PREAMBLE(isolate);
2317 num = i::Execution::ToUint32(obj, &has_pending_exception); 2332 num = i::Execution::ToUint32(obj, &has_pending_exception);
2318 EXCEPTION_BAILOUT_CHECK(Local<Uint32>()); 2333 EXCEPTION_BAILOUT_CHECK(isolate, Local<Uint32>());
2319 } 2334 }
2320 return Local<Uint32>(ToApi<Uint32>(num)); 2335 return Local<Uint32>(ToApi<Uint32>(num));
2321 } 2336 }
2322 2337
2323 2338
2324 Local<Uint32> Value::ToArrayIndex() const { 2339 Local<Uint32> Value::ToArrayIndex() const {
2325 i::Isolate* isolate = i::Isolate::Current();
2326 if (IsDeadCheck(isolate, "v8::Value::ToArrayIndex()")) return Local<Uint32>();
2327 LOG_API(isolate, "ToArrayIndex");
2328 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2340 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2329 if (obj->IsSmi()) { 2341 if (obj->IsSmi()) {
2330 if (i::Smi::cast(*obj)->value() >= 0) return Utils::Uint32ToLocal(obj); 2342 if (i::Smi::cast(*obj)->value() >= 0) return Utils::Uint32ToLocal(obj);
2331 return Local<Uint32>(); 2343 return Local<Uint32>();
2332 } 2344 }
2333 ENTER_V8; 2345 i::Isolate* isolate = i::Isolate::Current();
2334 EXCEPTION_PREAMBLE(); 2346 if (IsDeadCheck(isolate, "v8::Value::ToArrayIndex()")) return Local<Uint32>();
2347 LOG_API(isolate, "ToArrayIndex");
2348 ENTER_V8(isolate);
2349 EXCEPTION_PREAMBLE(isolate);
2335 i::Handle<i::Object> string_obj = 2350 i::Handle<i::Object> string_obj =
2336 i::Execution::ToString(obj, &has_pending_exception); 2351 i::Execution::ToString(obj, &has_pending_exception);
2337 EXCEPTION_BAILOUT_CHECK(Local<Uint32>()); 2352 EXCEPTION_BAILOUT_CHECK(isolate, Local<Uint32>());
2338 i::Handle<i::String> str = i::Handle<i::String>::cast(string_obj); 2353 i::Handle<i::String> str = i::Handle<i::String>::cast(string_obj);
2339 uint32_t index; 2354 uint32_t index;
2340 if (str->AsArrayIndex(&index)) { 2355 if (str->AsArrayIndex(&index)) {
2341 i::Handle<i::Object> value; 2356 i::Handle<i::Object> value;
2342 if (index <= static_cast<uint32_t>(i::Smi::kMaxValue)) { 2357 if (index <= static_cast<uint32_t>(i::Smi::kMaxValue)) {
2343 value = i::Handle<i::Object>(i::Smi::FromInt(index)); 2358 value = i::Handle<i::Object>(i::Smi::FromInt(index));
2344 } else { 2359 } else {
2345 value = isolate->factory()->NewNumber(index); 2360 value = isolate->factory()->NewNumber(index);
2346 } 2361 }
2347 return Utils::Uint32ToLocal(value); 2362 return Utils::Uint32ToLocal(value);
2348 } 2363 }
2349 return Local<Uint32>(); 2364 return Local<Uint32>();
2350 } 2365 }
2351 2366
2352 2367
2353 int32_t Value::Int32Value() const { 2368 int32_t Value::Int32Value() const {
2354 i::Isolate* isolate = i::Isolate::Current();
2355 if (IsDeadCheck(isolate, "v8::Value::Int32Value()")) return 0;
2356 LOG_API(isolate, "Int32Value");
2357 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2369 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2358 if (obj->IsSmi()) { 2370 if (obj->IsSmi()) {
2359 return i::Smi::cast(*obj)->value(); 2371 return i::Smi::cast(*obj)->value();
2360 } else { 2372 } else {
2373 i::Isolate* isolate = i::Isolate::Current();
2374 if (IsDeadCheck(isolate, "v8::Value::Int32Value()")) return 0;
2361 LOG_API(isolate, "Int32Value (slow)"); 2375 LOG_API(isolate, "Int32Value (slow)");
2362 ENTER_V8; 2376 ENTER_V8(isolate);
2363 EXCEPTION_PREAMBLE(); 2377 EXCEPTION_PREAMBLE(isolate);
2364 i::Handle<i::Object> num = 2378 i::Handle<i::Object> num =
2365 i::Execution::ToInt32(obj, &has_pending_exception); 2379 i::Execution::ToInt32(obj, &has_pending_exception);
2366 EXCEPTION_BAILOUT_CHECK(0); 2380 EXCEPTION_BAILOUT_CHECK(isolate, 0);
2367 if (num->IsSmi()) { 2381 if (num->IsSmi()) {
2368 return i::Smi::cast(*num)->value(); 2382 return i::Smi::cast(*num)->value();
2369 } else { 2383 } else {
2370 return static_cast<int32_t>(num->Number()); 2384 return static_cast<int32_t>(num->Number());
2371 } 2385 }
2372 } 2386 }
2373 } 2387 }
2374 2388
2375 2389
2376 bool Value::Equals(Handle<Value> that) const { 2390 bool Value::Equals(Handle<Value> that) const {
2377 i::Isolate* isolate = i::Isolate::Current(); 2391 i::Isolate* isolate = i::Isolate::Current();
2378 if (IsDeadCheck(isolate, "v8::Value::Equals()") 2392 if (IsDeadCheck(isolate, "v8::Value::Equals()")
2379 || EmptyCheck("v8::Value::Equals()", this) 2393 || EmptyCheck("v8::Value::Equals()", this)
2380 || EmptyCheck("v8::Value::Equals()", that)) { 2394 || EmptyCheck("v8::Value::Equals()", that)) {
2381 return false; 2395 return false;
2382 } 2396 }
2383 LOG_API(isolate, "Equals"); 2397 LOG_API(isolate, "Equals");
2384 ENTER_V8; 2398 ENTER_V8(isolate);
2385 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2399 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2386 i::Handle<i::Object> other = Utils::OpenHandle(*that); 2400 i::Handle<i::Object> other = Utils::OpenHandle(*that);
2387 // If both obj and other are JSObjects, we'd better compare by identity 2401 // If both obj and other are JSObjects, we'd better compare by identity
2388 // immediately when going into JS builtin. The reason is Invoke 2402 // immediately when going into JS builtin. The reason is Invoke
2389 // would overwrite global object receiver with global proxy. 2403 // would overwrite global object receiver with global proxy.
2390 if (obj->IsJSObject() && other->IsJSObject()) { 2404 if (obj->IsJSObject() && other->IsJSObject()) {
2391 return *obj == *other; 2405 return *obj == *other;
2392 } 2406 }
2393 i::Object** args[1] = { other.location() }; 2407 i::Object** args[1] = { other.location() };
2394 EXCEPTION_PREAMBLE(); 2408 EXCEPTION_PREAMBLE(isolate);
2395 i::Handle<i::Object> result = 2409 i::Handle<i::Object> result =
2396 CallV8HeapFunction("EQUALS", obj, 1, args, &has_pending_exception); 2410 CallV8HeapFunction("EQUALS", obj, 1, args, &has_pending_exception);
2397 EXCEPTION_BAILOUT_CHECK(false); 2411 EXCEPTION_BAILOUT_CHECK(isolate, false);
2398 return *result == i::Smi::FromInt(i::EQUAL); 2412 return *result == i::Smi::FromInt(i::EQUAL);
2399 } 2413 }
2400 2414
2401 2415
2402 bool Value::StrictEquals(Handle<Value> that) const { 2416 bool Value::StrictEquals(Handle<Value> that) const {
2403 i::Isolate* isolate = i::Isolate::Current(); 2417 i::Isolate* isolate = i::Isolate::Current();
2404 if (IsDeadCheck(isolate, "v8::Value::StrictEquals()") 2418 if (IsDeadCheck(isolate, "v8::Value::StrictEquals()")
2405 || EmptyCheck("v8::Value::StrictEquals()", this) 2419 || EmptyCheck("v8::Value::StrictEquals()", this)
2406 || EmptyCheck("v8::Value::StrictEquals()", that)) { 2420 || EmptyCheck("v8::Value::StrictEquals()", that)) {
2407 return false; 2421 return false;
(...skipping 17 matching lines...) Expand all
2425 i::String::cast(*obj)->Equals(i::String::cast(*other)); 2439 i::String::cast(*obj)->Equals(i::String::cast(*other));
2426 } else if (obj->IsUndefined() || obj->IsUndetectableObject()) { 2440 } else if (obj->IsUndefined() || obj->IsUndetectableObject()) {
2427 return other->IsUndefined() || other->IsUndetectableObject(); 2441 return other->IsUndefined() || other->IsUndetectableObject();
2428 } else { 2442 } else {
2429 return false; 2443 return false;
2430 } 2444 }
2431 } 2445 }
2432 2446
2433 2447
2434 uint32_t Value::Uint32Value() const { 2448 uint32_t Value::Uint32Value() const {
2435 i::Isolate* isolate = i::Isolate::Current();
2436 if (IsDeadCheck(isolate, "v8::Value::Uint32Value()")) return 0;
2437 LOG_API(isolate, "Uint32Value");
2438 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2449 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2439 if (obj->IsSmi()) { 2450 if (obj->IsSmi()) {
2440 return i::Smi::cast(*obj)->value(); 2451 return i::Smi::cast(*obj)->value();
2441 } else { 2452 } else {
2442 ENTER_V8; 2453 i::Isolate* isolate = i::Isolate::Current();
2443 EXCEPTION_PREAMBLE(); 2454 if (IsDeadCheck(isolate, "v8::Value::Uint32Value()")) return 0;
2455 LOG_API(isolate, "Uint32Value");
2456 ENTER_V8(isolate);
2457 EXCEPTION_PREAMBLE(isolate);
2444 i::Handle<i::Object> num = 2458 i::Handle<i::Object> num =
2445 i::Execution::ToUint32(obj, &has_pending_exception); 2459 i::Execution::ToUint32(obj, &has_pending_exception);
2446 EXCEPTION_BAILOUT_CHECK(0); 2460 EXCEPTION_BAILOUT_CHECK(isolate, 0);
2447 if (num->IsSmi()) { 2461 if (num->IsSmi()) {
2448 return i::Smi::cast(*num)->value(); 2462 return i::Smi::cast(*num)->value();
2449 } else { 2463 } else {
2450 return static_cast<uint32_t>(num->Number()); 2464 return static_cast<uint32_t>(num->Number());
2451 } 2465 }
2452 } 2466 }
2453 } 2467 }
2454 2468
2455 2469
2456 bool v8::Object::Set(v8::Handle<Value> key, v8::Handle<Value> value, 2470 bool v8::Object::Set(v8::Handle<Value> key, v8::Handle<Value> value,
2457 v8::PropertyAttribute attribs) { 2471 v8::PropertyAttribute attribs) {
2458 i::Isolate* isolate = i::Isolate::Current(); 2472 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2459 ON_BAILOUT(isolate, "v8::Object::Set()", return false); 2473 ON_BAILOUT(isolate, "v8::Object::Set()", return false);
2460 ENTER_V8; 2474 ENTER_V8(isolate);
2461 i::HandleScope scope(isolate); 2475 i::HandleScope scope(isolate);
2462 i::Handle<i::Object> self = Utils::OpenHandle(this); 2476 i::Handle<i::Object> self = Utils::OpenHandle(this);
2463 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 2477 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
2464 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); 2478 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
2465 EXCEPTION_PREAMBLE(); 2479 EXCEPTION_PREAMBLE(isolate);
2466 i::Handle<i::Object> obj = i::SetProperty( 2480 i::Handle<i::Object> obj = i::SetProperty(
2467 self, 2481 self,
2468 key_obj, 2482 key_obj,
2469 value_obj, 2483 value_obj,
2470 static_cast<PropertyAttributes>(attribs), 2484 static_cast<PropertyAttributes>(attribs),
2471 i::kNonStrictMode); 2485 i::kNonStrictMode);
2472 has_pending_exception = obj.is_null(); 2486 has_pending_exception = obj.is_null();
2473 EXCEPTION_BAILOUT_CHECK(false); 2487 EXCEPTION_BAILOUT_CHECK(isolate, false);
2474 return true; 2488 return true;
2475 } 2489 }
2476 2490
2477 2491
2478 bool v8::Object::Set(uint32_t index, v8::Handle<Value> value) { 2492 bool v8::Object::Set(uint32_t index, v8::Handle<Value> value) {
2479 i::Isolate* isolate = i::Isolate::Current(); 2493 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2480 ON_BAILOUT(isolate, "v8::Object::Set()", return false); 2494 ON_BAILOUT(isolate, "v8::Object::Set()", return false);
2481 ENTER_V8; 2495 ENTER_V8(isolate);
2482 i::HandleScope scope(isolate); 2496 i::HandleScope scope(isolate);
2483 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2497 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2484 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); 2498 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
2485 EXCEPTION_PREAMBLE(); 2499 EXCEPTION_PREAMBLE(isolate);
2486 i::Handle<i::Object> obj = i::SetElement( 2500 i::Handle<i::Object> obj = i::SetElement(
2487 self, 2501 self,
2488 index, 2502 index,
2489 value_obj, 2503 value_obj,
2490 i::kNonStrictMode); 2504 i::kNonStrictMode);
2491 has_pending_exception = obj.is_null(); 2505 has_pending_exception = obj.is_null();
2492 EXCEPTION_BAILOUT_CHECK(false); 2506 EXCEPTION_BAILOUT_CHECK(isolate, false);
2493 return true; 2507 return true;
2494 } 2508 }
2495 2509
2496 2510
2497 bool v8::Object::ForceSet(v8::Handle<Value> key, 2511 bool v8::Object::ForceSet(v8::Handle<Value> key,
2498 v8::Handle<Value> value, 2512 v8::Handle<Value> value,
2499 v8::PropertyAttribute attribs) { 2513 v8::PropertyAttribute attribs) {
2500 i::Isolate* isolate = i::Isolate::Current(); 2514 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2501 ON_BAILOUT(isolate, "v8::Object::ForceSet()", return false); 2515 ON_BAILOUT(isolate, "v8::Object::ForceSet()", return false);
2502 ENTER_V8; 2516 ENTER_V8(isolate);
2503 i::HandleScope scope(isolate); 2517 i::HandleScope scope(isolate);
2504 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2518 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2505 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 2519 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
2506 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); 2520 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
2507 EXCEPTION_PREAMBLE(); 2521 EXCEPTION_PREAMBLE(isolate);
2508 i::Handle<i::Object> obj = i::ForceSetProperty( 2522 i::Handle<i::Object> obj = i::ForceSetProperty(
2509 self, 2523 self,
2510 key_obj, 2524 key_obj,
2511 value_obj, 2525 value_obj,
2512 static_cast<PropertyAttributes>(attribs)); 2526 static_cast<PropertyAttributes>(attribs));
2513 has_pending_exception = obj.is_null(); 2527 has_pending_exception = obj.is_null();
2514 EXCEPTION_BAILOUT_CHECK(false); 2528 EXCEPTION_BAILOUT_CHECK(isolate, false);
2515 return true; 2529 return true;
2516 } 2530 }
2517 2531
2518 2532
2519 bool v8::Object::ForceDelete(v8::Handle<Value> key) { 2533 bool v8::Object::ForceDelete(v8::Handle<Value> key) {
2520 i::Isolate* isolate = i::Isolate::Current(); 2534 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2521 ON_BAILOUT(isolate, "v8::Object::ForceDelete()", return false); 2535 ON_BAILOUT(isolate, "v8::Object::ForceDelete()", return false);
2522 ENTER_V8; 2536 ENTER_V8(isolate);
2523 i::HandleScope scope(isolate); 2537 i::HandleScope scope(isolate);
2524 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2538 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2525 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 2539 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
2526 2540
2527 // When turning on access checks for a global object deoptimize all functions 2541 // When turning on access checks for a global object deoptimize all functions
2528 // as optimized code does not always handle access checks. 2542 // as optimized code does not always handle access checks.
2529 i::Deoptimizer::DeoptimizeGlobalObject(*self); 2543 i::Deoptimizer::DeoptimizeGlobalObject(*self);
2530 2544
2531 EXCEPTION_PREAMBLE(); 2545 EXCEPTION_PREAMBLE(isolate);
2532 i::Handle<i::Object> obj = i::ForceDeleteProperty(self, key_obj); 2546 i::Handle<i::Object> obj = i::ForceDeleteProperty(self, key_obj);
2533 has_pending_exception = obj.is_null(); 2547 has_pending_exception = obj.is_null();
2534 EXCEPTION_BAILOUT_CHECK(false); 2548 EXCEPTION_BAILOUT_CHECK(isolate, false);
2535 return obj->IsTrue(); 2549 return obj->IsTrue();
2536 } 2550 }
2537 2551
2538 2552
2539 Local<Value> v8::Object::Get(v8::Handle<Value> key) { 2553 Local<Value> v8::Object::Get(v8::Handle<Value> key) {
2540 i::Isolate* isolate = i::Isolate::Current(); 2554 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2541 ON_BAILOUT(isolate, "v8::Object::Get()", return Local<v8::Value>()); 2555 ON_BAILOUT(isolate, "v8::Object::Get()", return Local<v8::Value>());
2542 ENTER_V8; 2556 ENTER_V8(isolate);
2543 i::Handle<i::Object> self = Utils::OpenHandle(this); 2557 i::Handle<i::Object> self = Utils::OpenHandle(this);
2544 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 2558 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
2545 EXCEPTION_PREAMBLE(); 2559 EXCEPTION_PREAMBLE(isolate);
2546 i::Handle<i::Object> result = i::GetProperty(self, key_obj); 2560 i::Handle<i::Object> result = i::GetProperty(self, key_obj);
2547 has_pending_exception = result.is_null(); 2561 has_pending_exception = result.is_null();
2548 EXCEPTION_BAILOUT_CHECK(Local<Value>()); 2562 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
2549 return Utils::ToLocal(result); 2563 return Utils::ToLocal(result);
2550 } 2564 }
2551 2565
2552 2566
2553 Local<Value> v8::Object::Get(uint32_t index) { 2567 Local<Value> v8::Object::Get(uint32_t index) {
2554 i::Isolate* isolate = i::Isolate::Current(); 2568 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2555 ON_BAILOUT(isolate, "v8::Object::Get()", return Local<v8::Value>()); 2569 ON_BAILOUT(isolate, "v8::Object::Get()", return Local<v8::Value>());
2556 ENTER_V8; 2570 ENTER_V8(isolate);
2557 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2571 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2558 EXCEPTION_PREAMBLE(); 2572 EXCEPTION_PREAMBLE(isolate);
2559 i::Handle<i::Object> result = i::GetElement(self, index); 2573 i::Handle<i::Object> result = i::GetElement(self, index);
2560 has_pending_exception = result.is_null(); 2574 has_pending_exception = result.is_null();
2561 EXCEPTION_BAILOUT_CHECK(Local<Value>()); 2575 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
2562 return Utils::ToLocal(result); 2576 return Utils::ToLocal(result);
2563 } 2577 }
2564 2578
2565 2579
2566 Local<Value> v8::Object::GetPrototype() { 2580 Local<Value> v8::Object::GetPrototype() {
2567 ON_BAILOUT(i::Isolate::Current(), "v8::Object::GetPrototype()", 2581 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2582 ON_BAILOUT(isolate, "v8::Object::GetPrototype()",
2568 return Local<v8::Value>()); 2583 return Local<v8::Value>());
2569 ENTER_V8; 2584 ENTER_V8(isolate);
2570 i::Handle<i::Object> self = Utils::OpenHandle(this); 2585 i::Handle<i::Object> self = Utils::OpenHandle(this);
2571 i::Handle<i::Object> result = i::GetPrototype(self); 2586 i::Handle<i::Object> result = i::GetPrototype(self);
2572 return Utils::ToLocal(result); 2587 return Utils::ToLocal(result);
2573 } 2588 }
2574 2589
2575 2590
2576 bool v8::Object::SetPrototype(Handle<Value> value) { 2591 bool v8::Object::SetPrototype(Handle<Value> value) {
2577 i::Isolate* isolate = i::Isolate::Current(); 2592 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2578 ON_BAILOUT(isolate, "v8::Object::SetPrototype()", return false); 2593 ON_BAILOUT(isolate, "v8::Object::SetPrototype()", return false);
2579 ENTER_V8; 2594 ENTER_V8(isolate);
2580 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2595 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2581 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); 2596 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
2582 EXCEPTION_PREAMBLE(); 2597 EXCEPTION_PREAMBLE(isolate);
2583 i::Handle<i::Object> result = i::SetPrototype(self, value_obj); 2598 i::Handle<i::Object> result = i::SetPrototype(self, value_obj);
2584 has_pending_exception = result.is_null(); 2599 has_pending_exception = result.is_null();
2585 EXCEPTION_BAILOUT_CHECK(false); 2600 EXCEPTION_BAILOUT_CHECK(isolate, false);
2586 return true; 2601 return true;
2587 } 2602 }
2588 2603
2589 2604
2590 Local<Object> v8::Object::FindInstanceInPrototypeChain( 2605 Local<Object> v8::Object::FindInstanceInPrototypeChain(
2591 v8::Handle<FunctionTemplate> tmpl) { 2606 v8::Handle<FunctionTemplate> tmpl) {
2592 ON_BAILOUT(i::Isolate::Current(), 2607 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2608 ON_BAILOUT(isolate,
2593 "v8::Object::FindInstanceInPrototypeChain()", 2609 "v8::Object::FindInstanceInPrototypeChain()",
2594 return Local<v8::Object>()); 2610 return Local<v8::Object>());
2595 ENTER_V8; 2611 ENTER_V8(isolate);
2596 i::JSObject* object = *Utils::OpenHandle(this); 2612 i::JSObject* object = *Utils::OpenHandle(this);
2597 i::FunctionTemplateInfo* tmpl_info = *Utils::OpenHandle(*tmpl); 2613 i::FunctionTemplateInfo* tmpl_info = *Utils::OpenHandle(*tmpl);
2598 while (!object->IsInstanceOf(tmpl_info)) { 2614 while (!object->IsInstanceOf(tmpl_info)) {
2599 i::Object* prototype = object->GetPrototype(); 2615 i::Object* prototype = object->GetPrototype();
2600 if (!prototype->IsJSObject()) return Local<Object>(); 2616 if (!prototype->IsJSObject()) return Local<Object>();
2601 object = i::JSObject::cast(prototype); 2617 object = i::JSObject::cast(prototype);
2602 } 2618 }
2603 return Utils::ToLocal(i::Handle<i::JSObject>(object)); 2619 return Utils::ToLocal(i::Handle<i::JSObject>(object));
2604 } 2620 }
2605 2621
2606 2622
2607 Local<Array> v8::Object::GetPropertyNames() { 2623 Local<Array> v8::Object::GetPropertyNames() {
2608 i::Isolate* isolate = i::Isolate::Current(); 2624 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2609 ON_BAILOUT(isolate, "v8::Object::GetPropertyNames()", 2625 ON_BAILOUT(isolate, "v8::Object::GetPropertyNames()",
2610 return Local<v8::Array>()); 2626 return Local<v8::Array>());
2611 ENTER_V8; 2627 ENTER_V8(isolate);
2612 v8::HandleScope scope; 2628 i::HandleScope scope(isolate);
2613 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2629 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2614 i::Handle<i::FixedArray> value = 2630 i::Handle<i::FixedArray> value =
2615 i::GetKeysInFixedArrayFor(self, i::INCLUDE_PROTOS); 2631 i::GetKeysInFixedArrayFor(self, i::INCLUDE_PROTOS);
2616 // Because we use caching to speed up enumeration it is important 2632 // Because we use caching to speed up enumeration it is important
2617 // to never change the result of the basic enumeration function so 2633 // to never change the result of the basic enumeration function so
2618 // we clone the result. 2634 // we clone the result.
2619 i::Handle<i::FixedArray> elms = isolate->factory()->CopyFixedArray(value); 2635 i::Handle<i::FixedArray> elms = isolate->factory()->CopyFixedArray(value);
2620 i::Handle<i::JSArray> result = 2636 i::Handle<i::JSArray> result =
2621 isolate->factory()->NewJSArrayWithElements(elms); 2637 isolate->factory()->NewJSArrayWithElements(elms);
2622 return scope.Close(Utils::ToLocal(result)); 2638 return Utils::ToLocal(scope.CloseAndEscape(result));
2623 } 2639 }
2624 2640
2625 2641
2626 Local<String> v8::Object::ObjectProtoToString() { 2642 Local<String> v8::Object::ObjectProtoToString() {
2627 ON_BAILOUT(i::Isolate::Current(), "v8::Object::ObjectProtoToString()", 2643 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2644 ON_BAILOUT(isolate, "v8::Object::ObjectProtoToString()",
2628 return Local<v8::String>()); 2645 return Local<v8::String>());
2629 ENTER_V8; 2646 ENTER_V8(isolate);
2630 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2647 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2631 2648
2632 i::Handle<i::Object> name(self->class_name()); 2649 i::Handle<i::Object> name(self->class_name());
2633 2650
2634 // Native implementation of Object.prototype.toString (v8natives.js): 2651 // Native implementation of Object.prototype.toString (v8natives.js):
2635 // var c = %ClassOf(this); 2652 // var c = %ClassOf(this);
2636 // if (c === 'Arguments') c = 'Object'; 2653 // if (c === 'Arguments') c = 'Object';
2637 // return "[object " + c + "]"; 2654 // return "[object " + c + "]";
2638 2655
2639 if (!name->IsString()) { 2656 if (!name->IsString()) {
(...skipping 30 matching lines...) Expand all
2670 2687
2671 // Copy the buffer into a heap-allocated string and return it. 2688 // Copy the buffer into a heap-allocated string and return it.
2672 Local<String> result = v8::String::New(buf.start(), buf_len); 2689 Local<String> result = v8::String::New(buf.start(), buf_len);
2673 return result; 2690 return result;
2674 } 2691 }
2675 } 2692 }
2676 } 2693 }
2677 2694
2678 2695
2679 Local<String> v8::Object::GetConstructorName() { 2696 Local<String> v8::Object::GetConstructorName() {
2680 i::Isolate* isolate = i::Isolate::Current(); 2697 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2681 ON_BAILOUT(isolate, "v8::Object::GetConstructorName()", 2698 ON_BAILOUT(isolate, "v8::Object::GetConstructorName()",
2682 return Local<v8::String>()); 2699 return Local<v8::String>());
2683 ENTER_V8; 2700 ENTER_V8(isolate);
2684 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2701 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2685 i::Handle<i::String> name(self->constructor_name()); 2702 i::Handle<i::String> name(self->constructor_name());
2686 return Utils::ToLocal(name); 2703 return Utils::ToLocal(name);
2687 } 2704 }
2688 2705
2689 2706
2690 bool v8::Object::Delete(v8::Handle<String> key) { 2707 bool v8::Object::Delete(v8::Handle<String> key) {
2691 i::Isolate* isolate = i::Isolate::Current(); 2708 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2692 ON_BAILOUT(isolate, "v8::Object::Delete()", return false); 2709 ON_BAILOUT(isolate, "v8::Object::Delete()", return false);
2693 ENTER_V8; 2710 ENTER_V8(isolate);
2694 i::HandleScope scope(isolate); 2711 i::HandleScope scope(isolate);
2695 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2712 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2696 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 2713 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
2697 return i::DeleteProperty(self, key_obj)->IsTrue(); 2714 return i::DeleteProperty(self, key_obj)->IsTrue();
2698 } 2715 }
2699 2716
2700 2717
2701 bool v8::Object::Has(v8::Handle<String> key) { 2718 bool v8::Object::Has(v8::Handle<String> key) {
2702 ON_BAILOUT(i::Isolate::Current(), "v8::Object::Has()", return false); 2719 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2703 ENTER_V8; 2720 ON_BAILOUT(isolate, "v8::Object::Has()", return false);
2721 ENTER_V8(isolate);
2704 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2722 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2705 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 2723 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
2706 return self->HasProperty(*key_obj); 2724 return self->HasProperty(*key_obj);
2707 } 2725 }
2708 2726
2709 2727
2710 bool v8::Object::Delete(uint32_t index) { 2728 bool v8::Object::Delete(uint32_t index) {
2711 ON_BAILOUT(i::Isolate::Current(), "v8::Object::DeleteProperty()", 2729 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2730 ON_BAILOUT(isolate, "v8::Object::DeleteProperty()",
2712 return false); 2731 return false);
2713 ENTER_V8; 2732 ENTER_V8(isolate);
2714 HandleScope scope; 2733 HandleScope scope;
2715 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2734 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2716 return i::DeleteElement(self, index)->IsTrue(); 2735 return i::DeleteElement(self, index)->IsTrue();
2717 } 2736 }
2718 2737
2719 2738
2720 bool v8::Object::Has(uint32_t index) { 2739 bool v8::Object::Has(uint32_t index) {
2721 ON_BAILOUT(i::Isolate::Current(), "v8::Object::HasProperty()", return false); 2740 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2741 ON_BAILOUT(isolate, "v8::Object::HasProperty()", return false);
2722 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2742 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2723 return self->HasElement(index); 2743 return self->HasElement(index);
2724 } 2744 }
2725 2745
2726 2746
2727 bool Object::SetAccessor(Handle<String> name, 2747 bool Object::SetAccessor(Handle<String> name,
2728 AccessorGetter getter, 2748 AccessorGetter getter,
2729 AccessorSetter setter, 2749 AccessorSetter setter,
2730 v8::Handle<Value> data, 2750 v8::Handle<Value> data,
2731 AccessControl settings, 2751 AccessControl settings,
2732 PropertyAttribute attributes) { 2752 PropertyAttribute attributes) {
2733 i::Isolate* isolate = i::Isolate::Current(); 2753 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2734 ON_BAILOUT(isolate, "v8::Object::SetAccessor()", return false); 2754 ON_BAILOUT(isolate, "v8::Object::SetAccessor()", return false);
2735 ENTER_V8; 2755 ENTER_V8(isolate);
2736 i::HandleScope scope(isolate); 2756 i::HandleScope scope(isolate);
2737 i::Handle<i::AccessorInfo> info = MakeAccessorInfo(name, 2757 i::Handle<i::AccessorInfo> info = MakeAccessorInfo(name,
2738 getter, setter, data, 2758 getter, setter, data,
2739 settings, attributes); 2759 settings, attributes);
2740 i::Handle<i::Object> result = i::SetAccessor(Utils::OpenHandle(this), info); 2760 i::Handle<i::Object> result = i::SetAccessor(Utils::OpenHandle(this), info);
2741 return !result.is_null() && !result->IsUndefined(); 2761 return !result.is_null() && !result->IsUndefined();
2742 } 2762 }
2743 2763
2744 2764
2745 bool v8::Object::HasRealNamedProperty(Handle<String> key) { 2765 bool v8::Object::HasRealNamedProperty(Handle<String> key) {
2746 ON_BAILOUT(i::Isolate::Current(), "v8::Object::HasRealNamedProperty()", 2766 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2767 ON_BAILOUT(isolate, "v8::Object::HasRealNamedProperty()",
2747 return false); 2768 return false);
2748 return Utils::OpenHandle(this)->HasRealNamedProperty( 2769 return Utils::OpenHandle(this)->HasRealNamedProperty(
2749 *Utils::OpenHandle(*key)); 2770 *Utils::OpenHandle(*key));
2750 } 2771 }
2751 2772
2752 2773
2753 bool v8::Object::HasRealIndexedProperty(uint32_t index) { 2774 bool v8::Object::HasRealIndexedProperty(uint32_t index) {
2754 ON_BAILOUT(i::Isolate::Current(), "v8::Object::HasRealIndexedProperty()", 2775 ON_BAILOUT(Utils::OpenHandle(this)->GetIsolate(),
2776 "v8::Object::HasRealIndexedProperty()",
2755 return false); 2777 return false);
2756 return Utils::OpenHandle(this)->HasRealElementProperty(index); 2778 return Utils::OpenHandle(this)->HasRealElementProperty(index);
2757 } 2779 }
2758 2780
2759 2781
2760 bool v8::Object::HasRealNamedCallbackProperty(Handle<String> key) { 2782 bool v8::Object::HasRealNamedCallbackProperty(Handle<String> key) {
2761 ON_BAILOUT(i::Isolate::Current(), 2783 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2784 ON_BAILOUT(isolate,
2762 "v8::Object::HasRealNamedCallbackProperty()", 2785 "v8::Object::HasRealNamedCallbackProperty()",
2763 return false); 2786 return false);
2764 ENTER_V8; 2787 ENTER_V8(isolate);
2765 return Utils::OpenHandle(this)->HasRealNamedCallbackProperty( 2788 return Utils::OpenHandle(this)->HasRealNamedCallbackProperty(
2766 *Utils::OpenHandle(*key)); 2789 *Utils::OpenHandle(*key));
2767 } 2790 }
2768 2791
2769 2792
2770 bool v8::Object::HasNamedLookupInterceptor() { 2793 bool v8::Object::HasNamedLookupInterceptor() {
2771 ON_BAILOUT(i::Isolate::Current(), "v8::Object::HasNamedLookupInterceptor()", 2794 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2795 ON_BAILOUT(isolate, "v8::Object::HasNamedLookupInterceptor()",
2772 return false); 2796 return false);
2773 return Utils::OpenHandle(this)->HasNamedInterceptor(); 2797 return Utils::OpenHandle(this)->HasNamedInterceptor();
2774 } 2798 }
2775 2799
2776 2800
2777 bool v8::Object::HasIndexedLookupInterceptor() { 2801 bool v8::Object::HasIndexedLookupInterceptor() {
2778 ON_BAILOUT(i::Isolate::Current(), "v8::Object::HasIndexedLookupInterceptor()", 2802 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2803 ON_BAILOUT(isolate, "v8::Object::HasIndexedLookupInterceptor()",
2779 return false); 2804 return false);
2780 return Utils::OpenHandle(this)->HasIndexedInterceptor(); 2805 return Utils::OpenHandle(this)->HasIndexedInterceptor();
2781 } 2806 }
2782 2807
2783 2808
2784 Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( 2809 Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain(
2785 Handle<String> key) { 2810 Handle<String> key) {
2786 ON_BAILOUT(i::Isolate::Current(), 2811 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2812 ON_BAILOUT(isolate,
2787 "v8::Object::GetRealNamedPropertyInPrototypeChain()", 2813 "v8::Object::GetRealNamedPropertyInPrototypeChain()",
2788 return Local<Value>()); 2814 return Local<Value>());
2789 ENTER_V8; 2815 ENTER_V8(isolate);
2790 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); 2816 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this);
2791 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 2817 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
2792 i::LookupResult lookup; 2818 i::LookupResult lookup;
2793 self_obj->LookupRealNamedPropertyInPrototypes(*key_obj, &lookup); 2819 self_obj->LookupRealNamedPropertyInPrototypes(*key_obj, &lookup);
2794 if (lookup.IsProperty()) { 2820 if (lookup.IsProperty()) {
2795 PropertyAttributes attributes; 2821 PropertyAttributes attributes;
2796 i::Object* property = 2822 i::Object* property =
2797 self_obj->GetProperty(*self_obj, 2823 self_obj->GetProperty(*self_obj,
2798 &lookup, 2824 &lookup,
2799 *key_obj, 2825 *key_obj,
2800 &attributes)->ToObjectUnchecked(); 2826 &attributes)->ToObjectUnchecked();
2801 i::Handle<i::Object> result(property); 2827 i::Handle<i::Object> result(property);
2802 return Utils::ToLocal(result); 2828 return Utils::ToLocal(result);
2803 } 2829 }
2804 return Local<Value>(); // No real property was found in prototype chain. 2830 return Local<Value>(); // No real property was found in prototype chain.
2805 } 2831 }
2806 2832
2807 2833
2808 Local<Value> v8::Object::GetRealNamedProperty(Handle<String> key) { 2834 Local<Value> v8::Object::GetRealNamedProperty(Handle<String> key) {
2809 ON_BAILOUT(i::Isolate::Current(), "v8::Object::GetRealNamedProperty()", 2835 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2836 ON_BAILOUT(isolate, "v8::Object::GetRealNamedProperty()",
2810 return Local<Value>()); 2837 return Local<Value>());
2811 ENTER_V8; 2838 ENTER_V8(isolate);
2812 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); 2839 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this);
2813 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 2840 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
2814 i::LookupResult lookup; 2841 i::LookupResult lookup;
2815 self_obj->LookupRealNamedProperty(*key_obj, &lookup); 2842 self_obj->LookupRealNamedProperty(*key_obj, &lookup);
2816 if (lookup.IsProperty()) { 2843 if (lookup.IsProperty()) {
2817 PropertyAttributes attributes; 2844 PropertyAttributes attributes;
2818 i::Object* property = 2845 i::Object* property =
2819 self_obj->GetProperty(*self_obj, 2846 self_obj->GetProperty(*self_obj,
2820 &lookup, 2847 &lookup,
2821 *key_obj, 2848 *key_obj,
2822 &attributes)->ToObjectUnchecked(); 2849 &attributes)->ToObjectUnchecked();
2823 i::Handle<i::Object> result(property); 2850 i::Handle<i::Object> result(property);
2824 return Utils::ToLocal(result); 2851 return Utils::ToLocal(result);
2825 } 2852 }
2826 return Local<Value>(); // No real property was found in prototype chain. 2853 return Local<Value>(); // No real property was found in prototype chain.
2827 } 2854 }
2828 2855
2829 2856
2830 // Turns on access checks by copying the map and setting the check flag. 2857 // Turns on access checks by copying the map and setting the check flag.
2831 // Because the object gets a new map, existing inline cache caching 2858 // Because the object gets a new map, existing inline cache caching
2832 // the old map of this object will fail. 2859 // the old map of this object will fail.
2833 void v8::Object::TurnOnAccessCheck() { 2860 void v8::Object::TurnOnAccessCheck() {
2834 i::Isolate* isolate = i::Isolate::Current(); 2861 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2835 ON_BAILOUT(isolate, "v8::Object::TurnOnAccessCheck()", return); 2862 ON_BAILOUT(isolate, "v8::Object::TurnOnAccessCheck()", return);
2836 ENTER_V8; 2863 ENTER_V8(isolate);
2837 i::HandleScope scope(isolate); 2864 i::HandleScope scope(isolate);
2838 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); 2865 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
2839 2866
2840 // When turning on access checks for a global object deoptimize all functions 2867 // When turning on access checks for a global object deoptimize all functions
2841 // as optimized code does not always handle access checks. 2868 // as optimized code does not always handle access checks.
2842 i::Deoptimizer::DeoptimizeGlobalObject(*obj); 2869 i::Deoptimizer::DeoptimizeGlobalObject(*obj);
2843 2870
2844 i::Handle<i::Map> new_map = 2871 i::Handle<i::Map> new_map =
2845 isolate->factory()->CopyMapDropTransitions(i::Handle<i::Map>(obj->map())); 2872 isolate->factory()->CopyMapDropTransitions(i::Handle<i::Map>(obj->map()));
2846 new_map->set_is_access_check_needed(true); 2873 new_map->set_is_access_check_needed(true);
2847 obj->set_map(*new_map); 2874 obj->set_map(*new_map);
2848 } 2875 }
2849 2876
2850 2877
2851 bool v8::Object::IsDirty() { 2878 bool v8::Object::IsDirty() {
2852 return Utils::OpenHandle(this)->IsDirty(); 2879 return Utils::OpenHandle(this)->IsDirty();
2853 } 2880 }
2854 2881
2855 2882
2856 Local<v8::Object> v8::Object::Clone() { 2883 Local<v8::Object> v8::Object::Clone() {
2857 i::Isolate* isolate = i::Isolate::Current(); 2884 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2858 ON_BAILOUT(isolate, "v8::Object::Clone()", return Local<Object>()); 2885 ON_BAILOUT(isolate, "v8::Object::Clone()", return Local<Object>());
2859 ENTER_V8; 2886 ENTER_V8(isolate);
2860 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2887 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2861 EXCEPTION_PREAMBLE(); 2888 EXCEPTION_PREAMBLE(isolate);
2862 i::Handle<i::JSObject> result = i::Copy(self); 2889 i::Handle<i::JSObject> result = i::Copy(self);
2863 has_pending_exception = result.is_null(); 2890 has_pending_exception = result.is_null();
2864 EXCEPTION_BAILOUT_CHECK(Local<Object>()); 2891 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>());
2865 return Utils::ToLocal(result); 2892 return Utils::ToLocal(result);
2866 } 2893 }
2867 2894
2868 2895
2869 int v8::Object::GetIdentityHash() { 2896 int v8::Object::GetIdentityHash() {
2870 i::Isolate* isolate = i::Isolate::Current(); 2897 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2871 ON_BAILOUT(isolate, "v8::Object::GetIdentityHash()", return 0); 2898 ON_BAILOUT(isolate, "v8::Object::GetIdentityHash()", return 0);
2872 ENTER_V8; 2899 ENTER_V8(isolate);
2873 i::HandleScope scope(isolate); 2900 i::HandleScope scope(isolate);
2874 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2901 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2875 i::Handle<i::Object> hidden_props_obj(i::GetHiddenProperties(self, true)); 2902 i::Handle<i::Object> hidden_props_obj(i::GetHiddenProperties(self, true));
2876 if (!hidden_props_obj->IsJSObject()) { 2903 if (!hidden_props_obj->IsJSObject()) {
2877 // We failed to create hidden properties. That's a detached 2904 // We failed to create hidden properties. That's a detached
2878 // global proxy. 2905 // global proxy.
2879 ASSERT(hidden_props_obj->IsUndefined()); 2906 ASSERT(hidden_props_obj->IsUndefined());
2880 return 0; 2907 return 0;
2881 } 2908 }
2882 i::Handle<i::JSObject> hidden_props = 2909 i::Handle<i::JSObject> hidden_props =
(...skipping 20 matching lines...) Expand all
2903 hash_symbol, 2930 hash_symbol,
2904 i::Handle<i::Object>(i::Smi::FromInt(hash_value)), 2931 i::Handle<i::Object>(i::Smi::FromInt(hash_value)),
2905 static_cast<PropertyAttributes>(None)).is_null()); 2932 static_cast<PropertyAttributes>(None)).is_null());
2906 2933
2907 return hash_value; 2934 return hash_value;
2908 } 2935 }
2909 2936
2910 2937
2911 bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key, 2938 bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key,
2912 v8::Handle<v8::Value> value) { 2939 v8::Handle<v8::Value> value) {
2913 i::Isolate* isolate = i::Isolate::Current(); 2940 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2914 ON_BAILOUT(isolate, "v8::Object::SetHiddenValue()", return false); 2941 ON_BAILOUT(isolate, "v8::Object::SetHiddenValue()", return false);
2915 ENTER_V8; 2942 ENTER_V8(isolate);
2916 i::HandleScope scope(isolate); 2943 i::HandleScope scope(isolate);
2917 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2944 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2918 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, true)); 2945 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, true));
2919 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 2946 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
2920 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); 2947 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
2921 EXCEPTION_PREAMBLE(); 2948 EXCEPTION_PREAMBLE(isolate);
2922 i::Handle<i::Object> obj = i::SetProperty( 2949 i::Handle<i::Object> obj = i::SetProperty(
2923 hidden_props, 2950 hidden_props,
2924 key_obj, 2951 key_obj,
2925 value_obj, 2952 value_obj,
2926 static_cast<PropertyAttributes>(None), 2953 static_cast<PropertyAttributes>(None),
2927 i::kNonStrictMode); 2954 i::kNonStrictMode);
2928 has_pending_exception = obj.is_null(); 2955 has_pending_exception = obj.is_null();
2929 EXCEPTION_BAILOUT_CHECK(false); 2956 EXCEPTION_BAILOUT_CHECK(isolate, false);
2930 return true; 2957 return true;
2931 } 2958 }
2932 2959
2933 2960
2934 v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Handle<v8::String> key) { 2961 v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Handle<v8::String> key) {
2935 i::Isolate* isolate = i::Isolate::Current(); 2962 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2936 ON_BAILOUT(isolate, "v8::Object::GetHiddenValue()", 2963 ON_BAILOUT(isolate, "v8::Object::GetHiddenValue()",
2937 return Local<v8::Value>()); 2964 return Local<v8::Value>());
2938 ENTER_V8; 2965 ENTER_V8(isolate);
2939 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2966 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2940 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, false)); 2967 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, false));
2941 if (hidden_props->IsUndefined()) { 2968 if (hidden_props->IsUndefined()) {
2942 return v8::Local<v8::Value>(); 2969 return v8::Local<v8::Value>();
2943 } 2970 }
2944 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 2971 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
2945 EXCEPTION_PREAMBLE(); 2972 EXCEPTION_PREAMBLE(isolate);
2946 i::Handle<i::Object> result = i::GetProperty(hidden_props, key_obj); 2973 i::Handle<i::Object> result = i::GetProperty(hidden_props, key_obj);
2947 has_pending_exception = result.is_null(); 2974 has_pending_exception = result.is_null();
2948 EXCEPTION_BAILOUT_CHECK(v8::Local<v8::Value>()); 2975 EXCEPTION_BAILOUT_CHECK(isolate, v8::Local<v8::Value>());
2949 if (result->IsUndefined()) { 2976 if (result->IsUndefined()) {
2950 return v8::Local<v8::Value>(); 2977 return v8::Local<v8::Value>();
2951 } 2978 }
2952 return Utils::ToLocal(result); 2979 return Utils::ToLocal(result);
2953 } 2980 }
2954 2981
2955 2982
2956 bool v8::Object::DeleteHiddenValue(v8::Handle<v8::String> key) { 2983 bool v8::Object::DeleteHiddenValue(v8::Handle<v8::String> key) {
2957 i::Isolate* isolate = i::Isolate::Current(); 2984 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2958 ON_BAILOUT(isolate, "v8::DeleteHiddenValue()", return false); 2985 ON_BAILOUT(isolate, "v8::DeleteHiddenValue()", return false);
2959 ENTER_V8; 2986 ENTER_V8(isolate);
2960 i::HandleScope scope(isolate); 2987 i::HandleScope scope(isolate);
2961 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2988 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2962 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, false)); 2989 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, false));
2963 if (hidden_props->IsUndefined()) { 2990 if (hidden_props->IsUndefined()) {
2964 return true; 2991 return true;
2965 } 2992 }
2966 i::Handle<i::JSObject> js_obj(i::JSObject::cast(*hidden_props)); 2993 i::Handle<i::JSObject> js_obj(i::JSObject::cast(*hidden_props));
2967 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 2994 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
2968 return i::DeleteProperty(js_obj, key_obj)->IsTrue(); 2995 return i::DeleteProperty(js_obj, key_obj)->IsTrue();
2969 } 2996 }
2970 2997
2971 2998
2972 namespace { 2999 namespace {
2973 3000
2974 void PrepareExternalArrayElements(i::Handle<i::JSObject> object, 3001 void PrepareExternalArrayElements(i::Handle<i::JSObject> object,
2975 void* data, 3002 void* data,
2976 ExternalArrayType array_type, 3003 ExternalArrayType array_type,
2977 int length) { 3004 int length) {
3005 i::Isolate* isolate = object->GetIsolate();
2978 i::Handle<i::ExternalArray> array = 3006 i::Handle<i::ExternalArray> array =
2979 FACTORY->NewExternalArray(length, array_type, data); 3007 isolate->factory()->NewExternalArray(length, array_type, data);
2980 3008
2981 // If the object already has external elements, create a new, unique 3009 // If the object already has external elements, create a new, unique
2982 // map if the element type is now changing, because assumptions about 3010 // map if the element type is now changing, because assumptions about
2983 // generated code based on the receiver's map will be invalid. 3011 // generated code based on the receiver's map will be invalid.
2984 i::Handle<i::HeapObject> elements(object->elements()); 3012 i::Handle<i::HeapObject> elements(object->elements());
2985 bool cant_reuse_map = 3013 bool cant_reuse_map =
2986 elements->map()->IsUndefined() || 3014 elements->map()->IsUndefined() ||
2987 !elements->map()->has_external_array_elements() || 3015 !elements->map()->has_external_array_elements() ||
2988 elements->map() != HEAP->MapForExternalArrayType(array_type); 3016 elements->map() != isolate->heap()->MapForExternalArrayType(array_type);
2989 if (cant_reuse_map) { 3017 if (cant_reuse_map) {
2990 i::Handle<i::Map> external_array_map = 3018 i::Handle<i::Map> external_array_map =
2991 FACTORY->GetExternalArrayElementsMap( 3019 isolate->factory()->GetExternalArrayElementsMap(
2992 i::Handle<i::Map>(object->map()), 3020 i::Handle<i::Map>(object->map()),
2993 array_type, 3021 array_type,
2994 object->HasFastProperties()); 3022 object->HasFastProperties());
2995 object->set_map(*external_array_map); 3023 object->set_map(*external_array_map);
2996 } 3024 }
2997 object->set_elements(*array); 3025 object->set_elements(*array);
2998 } 3026 }
2999 3027
3000 } // namespace 3028 } // namespace
3001 3029
3002 3030
3003 void v8::Object::SetIndexedPropertiesToPixelData(uint8_t* data, int length) { 3031 void v8::Object::SetIndexedPropertiesToPixelData(uint8_t* data, int length) {
3004 i::Isolate* isolate = i::Isolate::Current(); 3032 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3005 ON_BAILOUT(isolate, "v8::SetElementsToPixelData()", return); 3033 ON_BAILOUT(isolate, "v8::SetElementsToPixelData()", return);
3006 ENTER_V8; 3034 ENTER_V8(isolate);
3007 i::HandleScope scope(isolate); 3035 i::HandleScope scope(isolate);
3008 if (!ApiCheck(length <= i::ExternalPixelArray::kMaxLength, 3036 if (!ApiCheck(length <= i::ExternalPixelArray::kMaxLength,
3009 "v8::Object::SetIndexedPropertiesToPixelData()", 3037 "v8::Object::SetIndexedPropertiesToPixelData()",
3010 "length exceeds max acceptable value")) { 3038 "length exceeds max acceptable value")) {
3011 return; 3039 return;
3012 } 3040 }
3013 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3041 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3014 if (!ApiCheck(!self->IsJSArray(), 3042 if (!ApiCheck(!self->IsJSArray(),
3015 "v8::Object::SetIndexedPropertiesToPixelData()", 3043 "v8::Object::SetIndexedPropertiesToPixelData()",
3016 "JSArray is not supported")) { 3044 "JSArray is not supported")) {
3017 return; 3045 return;
3018 } 3046 }
3019 PrepareExternalArrayElements(self, data, kExternalPixelArray, length); 3047 PrepareExternalArrayElements(self, data, kExternalPixelArray, length);
3020 } 3048 }
3021 3049
3022 3050
3023 bool v8::Object::HasIndexedPropertiesInPixelData() { 3051 bool v8::Object::HasIndexedPropertiesInPixelData() {
3024 ON_BAILOUT(i::Isolate::Current(), "v8::HasIndexedPropertiesInPixelData()", 3052 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3053 ON_BAILOUT(self->GetIsolate(), "v8::HasIndexedPropertiesInPixelData()",
3025 return false); 3054 return false);
3026 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3027 return self->HasExternalPixelElements(); 3055 return self->HasExternalPixelElements();
3028 } 3056 }
3029 3057
3030 3058
3031 uint8_t* v8::Object::GetIndexedPropertiesPixelData() { 3059 uint8_t* v8::Object::GetIndexedPropertiesPixelData() {
3032 ON_BAILOUT(i::Isolate::Current(), "v8::GetIndexedPropertiesPixelData()", 3060 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3061 ON_BAILOUT(self->GetIsolate(), "v8::GetIndexedPropertiesPixelData()",
3033 return NULL); 3062 return NULL);
3034 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3035 if (self->HasExternalPixelElements()) { 3063 if (self->HasExternalPixelElements()) {
3036 return i::ExternalPixelArray::cast(self->elements())-> 3064 return i::ExternalPixelArray::cast(self->elements())->
3037 external_pixel_pointer(); 3065 external_pixel_pointer();
3038 } else { 3066 } else {
3039 return NULL; 3067 return NULL;
3040 } 3068 }
3041 } 3069 }
3042 3070
3043 3071
3044 int v8::Object::GetIndexedPropertiesPixelDataLength() { 3072 int v8::Object::GetIndexedPropertiesPixelDataLength() {
3045 ON_BAILOUT(i::Isolate::Current(), "v8::GetIndexedPropertiesPixelDataLength()", 3073 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3074 ON_BAILOUT(self->GetIsolate(), "v8::GetIndexedPropertiesPixelDataLength()",
3046 return -1); 3075 return -1);
3047 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3048 if (self->HasExternalPixelElements()) { 3076 if (self->HasExternalPixelElements()) {
3049 return i::ExternalPixelArray::cast(self->elements())->length(); 3077 return i::ExternalPixelArray::cast(self->elements())->length();
3050 } else { 3078 } else {
3051 return -1; 3079 return -1;
3052 } 3080 }
3053 } 3081 }
3054 3082
3055 void v8::Object::SetIndexedPropertiesToExternalArrayData( 3083 void v8::Object::SetIndexedPropertiesToExternalArrayData(
3056 void* data, 3084 void* data,
3057 ExternalArrayType array_type, 3085 ExternalArrayType array_type,
3058 int length) { 3086 int length) {
3059 i::Isolate* isolate = i::Isolate::Current(); 3087 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3060 ON_BAILOUT(isolate, "v8::SetIndexedPropertiesToExternalArrayData()", return); 3088 ON_BAILOUT(isolate, "v8::SetIndexedPropertiesToExternalArrayData()", return);
3061 ENTER_V8; 3089 ENTER_V8(isolate);
3062 i::HandleScope scope(isolate); 3090 i::HandleScope scope(isolate);
3063 if (!ApiCheck(length <= i::ExternalArray::kMaxLength, 3091 if (!ApiCheck(length <= i::ExternalArray::kMaxLength,
3064 "v8::Object::SetIndexedPropertiesToExternalArrayData()", 3092 "v8::Object::SetIndexedPropertiesToExternalArrayData()",
3065 "length exceeds max acceptable value")) { 3093 "length exceeds max acceptable value")) {
3066 return; 3094 return;
3067 } 3095 }
3068 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3096 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3069 if (!ApiCheck(!self->IsJSArray(), 3097 if (!ApiCheck(!self->IsJSArray(),
3070 "v8::Object::SetIndexedPropertiesToExternalArrayData()", 3098 "v8::Object::SetIndexedPropertiesToExternalArrayData()",
3071 "JSArray is not supported")) { 3099 "JSArray is not supported")) {
3072 return; 3100 return;
3073 } 3101 }
3074 PrepareExternalArrayElements(self, data, array_type, length); 3102 PrepareExternalArrayElements(self, data, array_type, length);
3075 } 3103 }
3076 3104
3077 3105
3078 bool v8::Object::HasIndexedPropertiesInExternalArrayData() { 3106 bool v8::Object::HasIndexedPropertiesInExternalArrayData() {
3079 ON_BAILOUT(i::Isolate::Current(), 3107 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3108 ON_BAILOUT(self->GetIsolate(),
3080 "v8::HasIndexedPropertiesInExternalArrayData()", 3109 "v8::HasIndexedPropertiesInExternalArrayData()",
3081 return false); 3110 return false);
3082 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3083 return self->HasExternalArrayElements(); 3111 return self->HasExternalArrayElements();
3084 } 3112 }
3085 3113
3086 3114
3087 void* v8::Object::GetIndexedPropertiesExternalArrayData() { 3115 void* v8::Object::GetIndexedPropertiesExternalArrayData() {
3088 ON_BAILOUT(i::Isolate::Current(), 3116 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3117 ON_BAILOUT(self->GetIsolate(),
3089 "v8::GetIndexedPropertiesExternalArrayData()", 3118 "v8::GetIndexedPropertiesExternalArrayData()",
3090 return NULL); 3119 return NULL);
3091 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3092 if (self->HasExternalArrayElements()) { 3120 if (self->HasExternalArrayElements()) {
3093 return i::ExternalArray::cast(self->elements())->external_pointer(); 3121 return i::ExternalArray::cast(self->elements())->external_pointer();
3094 } else { 3122 } else {
3095 return NULL; 3123 return NULL;
3096 } 3124 }
3097 } 3125 }
3098 3126
3099 3127
3100 ExternalArrayType v8::Object::GetIndexedPropertiesExternalArrayDataType() { 3128 ExternalArrayType v8::Object::GetIndexedPropertiesExternalArrayDataType() {
3101 ON_BAILOUT(i::Isolate::Current(), 3129 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3130 ON_BAILOUT(self->GetIsolate(),
3102 "v8::GetIndexedPropertiesExternalArrayDataType()", 3131 "v8::GetIndexedPropertiesExternalArrayDataType()",
3103 return static_cast<ExternalArrayType>(-1)); 3132 return static_cast<ExternalArrayType>(-1));
3104 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3105 switch (self->elements()->map()->instance_type()) { 3133 switch (self->elements()->map()->instance_type()) {
3106 case i::EXTERNAL_BYTE_ARRAY_TYPE: 3134 case i::EXTERNAL_BYTE_ARRAY_TYPE:
3107 return kExternalByteArray; 3135 return kExternalByteArray;
3108 case i::EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: 3136 case i::EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE:
3109 return kExternalUnsignedByteArray; 3137 return kExternalUnsignedByteArray;
3110 case i::EXTERNAL_SHORT_ARRAY_TYPE: 3138 case i::EXTERNAL_SHORT_ARRAY_TYPE:
3111 return kExternalShortArray; 3139 return kExternalShortArray;
3112 case i::EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: 3140 case i::EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE:
3113 return kExternalUnsignedShortArray; 3141 return kExternalUnsignedShortArray;
3114 case i::EXTERNAL_INT_ARRAY_TYPE: 3142 case i::EXTERNAL_INT_ARRAY_TYPE:
3115 return kExternalIntArray; 3143 return kExternalIntArray;
3116 case i::EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: 3144 case i::EXTERNAL_UNSIGNED_INT_ARRAY_TYPE:
3117 return kExternalUnsignedIntArray; 3145 return kExternalUnsignedIntArray;
3118 case i::EXTERNAL_FLOAT_ARRAY_TYPE: 3146 case i::EXTERNAL_FLOAT_ARRAY_TYPE:
3119 return kExternalFloatArray; 3147 return kExternalFloatArray;
3120 case i::EXTERNAL_PIXEL_ARRAY_TYPE: 3148 case i::EXTERNAL_PIXEL_ARRAY_TYPE:
3121 return kExternalPixelArray; 3149 return kExternalPixelArray;
3122 default: 3150 default:
3123 return static_cast<ExternalArrayType>(-1); 3151 return static_cast<ExternalArrayType>(-1);
3124 } 3152 }
3125 } 3153 }
3126 3154
3127 3155
3128 int v8::Object::GetIndexedPropertiesExternalArrayDataLength() { 3156 int v8::Object::GetIndexedPropertiesExternalArrayDataLength() {
3129 ON_BAILOUT(i::Isolate::Current(), 3157 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3158 ON_BAILOUT(self->GetIsolate(),
3130 "v8::GetIndexedPropertiesExternalArrayDataLength()", 3159 "v8::GetIndexedPropertiesExternalArrayDataLength()",
3131 return 0); 3160 return 0);
3132 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3133 if (self->HasExternalArrayElements()) { 3161 if (self->HasExternalArrayElements()) {
3134 return i::ExternalArray::cast(self->elements())->length(); 3162 return i::ExternalArray::cast(self->elements())->length();
3135 } else { 3163 } else {
3136 return -1; 3164 return -1;
3137 } 3165 }
3138 } 3166 }
3139 3167
3140 3168
3141 Local<v8::Object> Function::NewInstance() const { 3169 Local<v8::Object> Function::NewInstance() const {
3142 return NewInstance(0, NULL); 3170 return NewInstance(0, NULL);
3143 } 3171 }
3144 3172
3145 3173
3146 Local<v8::Object> Function::NewInstance(int argc, 3174 Local<v8::Object> Function::NewInstance(int argc,
3147 v8::Handle<v8::Value> argv[]) const { 3175 v8::Handle<v8::Value> argv[]) const {
3148 i::Isolate* isolate = i::Isolate::Current(); 3176 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3149 ON_BAILOUT(isolate, "v8::Function::NewInstance()", 3177 ON_BAILOUT(isolate, "v8::Function::NewInstance()",
3150 return Local<v8::Object>()); 3178 return Local<v8::Object>());
3151 LOG_API(isolate, "Function::NewInstance"); 3179 LOG_API(isolate, "Function::NewInstance");
3152 ENTER_V8; 3180 ENTER_V8(isolate);
3153 HandleScope scope; 3181 HandleScope scope;
3154 i::Handle<i::JSFunction> function = Utils::OpenHandle(this); 3182 i::Handle<i::JSFunction> function = Utils::OpenHandle(this);
3155 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); 3183 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**));
3156 i::Object*** args = reinterpret_cast<i::Object***>(argv); 3184 i::Object*** args = reinterpret_cast<i::Object***>(argv);
3157 EXCEPTION_PREAMBLE(); 3185 EXCEPTION_PREAMBLE(isolate);
3158 i::Handle<i::Object> returned = 3186 i::Handle<i::Object> returned =
3159 i::Execution::New(function, argc, args, &has_pending_exception); 3187 i::Execution::New(function, argc, args, &has_pending_exception);
3160 EXCEPTION_BAILOUT_CHECK(Local<v8::Object>()); 3188 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>());
3161 return scope.Close(Utils::ToLocal(i::Handle<i::JSObject>::cast(returned))); 3189 return scope.Close(Utils::ToLocal(i::Handle<i::JSObject>::cast(returned)));
3162 } 3190 }
3163 3191
3164 3192
3165 Local<v8::Value> Function::Call(v8::Handle<v8::Object> recv, int argc, 3193 Local<v8::Value> Function::Call(v8::Handle<v8::Object> recv, int argc,
3166 v8::Handle<v8::Value> argv[]) { 3194 v8::Handle<v8::Value> argv[]) {
3167 i::Isolate* isolate = i::Isolate::Current(); 3195 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3168 ON_BAILOUT(isolate, "v8::Function::Call()", return Local<v8::Value>()); 3196 ON_BAILOUT(isolate, "v8::Function::Call()", return Local<v8::Value>());
3169 LOG_API(isolate, "Function::Call"); 3197 LOG_API(isolate, "Function::Call");
3170 ENTER_V8; 3198 ENTER_V8(isolate);
3171 i::Object* raw_result = NULL; 3199 i::Object* raw_result = NULL;
3172 { 3200 {
3173 i::HandleScope scope(isolate); 3201 i::HandleScope scope(isolate);
3174 i::Handle<i::JSFunction> fun = Utils::OpenHandle(this); 3202 i::Handle<i::JSFunction> fun = Utils::OpenHandle(this);
3175 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); 3203 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv);
3176 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); 3204 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**));
3177 i::Object*** args = reinterpret_cast<i::Object***>(argv); 3205 i::Object*** args = reinterpret_cast<i::Object***>(argv);
3178 EXCEPTION_PREAMBLE(); 3206 EXCEPTION_PREAMBLE(isolate);
3179 i::Handle<i::Object> returned = 3207 i::Handle<i::Object> returned =
3180 i::Execution::Call(fun, recv_obj, argc, args, &has_pending_exception); 3208 i::Execution::Call(fun, recv_obj, argc, args, &has_pending_exception);
3181 EXCEPTION_BAILOUT_CHECK(Local<Object>()); 3209 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>());
3182 raw_result = *returned; 3210 raw_result = *returned;
3183 } 3211 }
3184 i::Handle<i::Object> result(raw_result); 3212 i::Handle<i::Object> result(raw_result);
3185 return Utils::ToLocal(result); 3213 return Utils::ToLocal(result);
3186 } 3214 }
3187 3215
3188 3216
3189 void Function::SetName(v8::Handle<v8::String> name) { 3217 void Function::SetName(v8::Handle<v8::String> name) {
3190 ENTER_V8; 3218 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3219 ENTER_V8(isolate);
3191 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); 3220 i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
3192 func->shared()->set_name(*Utils::OpenHandle(*name)); 3221 func->shared()->set_name(*Utils::OpenHandle(*name));
3193 } 3222 }
3194 3223
3195 3224
3196 Handle<Value> Function::GetName() const { 3225 Handle<Value> Function::GetName() const {
3197 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); 3226 i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
3198 return Utils::ToLocal(i::Handle<i::Object>(func->shared()->name())); 3227 return Utils::ToLocal(i::Handle<i::Object>(func->shared()->name()));
3199 } 3228 }
3200 3229
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3235 int String::Utf8Length() const { 3264 int String::Utf8Length() const {
3236 if (IsDeadCheck(i::Isolate::Current(), "v8::String::Utf8Length()")) return 0; 3265 if (IsDeadCheck(i::Isolate::Current(), "v8::String::Utf8Length()")) return 0;
3237 return Utils::OpenHandle(this)->Utf8Length(); 3266 return Utils::OpenHandle(this)->Utf8Length();
3238 } 3267 }
3239 3268
3240 3269
3241 int String::WriteUtf8(char* buffer, 3270 int String::WriteUtf8(char* buffer,
3242 int capacity, 3271 int capacity,
3243 int* nchars_ref, 3272 int* nchars_ref,
3244 WriteHints hints) const { 3273 WriteHints hints) const {
3245 i::Isolate* isolate = i::Isolate::Current(); 3274 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3246 if (IsDeadCheck(isolate, "v8::String::WriteUtf8()")) return 0; 3275 if (IsDeadCheck(isolate, "v8::String::WriteUtf8()")) return 0;
3247 LOG_API(isolate, "String::WriteUtf8"); 3276 LOG_API(isolate, "String::WriteUtf8");
3248 ENTER_V8; 3277 ENTER_V8(isolate);
3249 i::StringInputBuffer& write_input_buffer = *isolate->write_input_buffer(); 3278 i::StringInputBuffer& write_input_buffer = *isolate->write_input_buffer();
3250 i::Handle<i::String> str = Utils::OpenHandle(this); 3279 i::Handle<i::String> str = Utils::OpenHandle(this);
3251 isolate->string_tracker()->RecordWrite(str); 3280 isolate->string_tracker()->RecordWrite(str);
3252 if (hints & HINT_MANY_WRITES_EXPECTED) { 3281 if (hints & HINT_MANY_WRITES_EXPECTED) {
3253 // Flatten the string for efficiency. This applies whether we are 3282 // Flatten the string for efficiency. This applies whether we are
3254 // using StringInputBuffer or Get(i) to access the characters. 3283 // using StringInputBuffer or Get(i) to access the characters.
3255 str->TryFlatten(); 3284 str->TryFlatten();
3256 } 3285 }
3257 write_input_buffer.Reset(0, *str); 3286 write_input_buffer.Reset(0, *str);
3258 int len = str->length(); 3287 int len = str->length();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3292 if (i == len && (capacity == -1 || pos < capacity)) 3321 if (i == len && (capacity == -1 || pos < capacity))
3293 buffer[pos++] = '\0'; 3322 buffer[pos++] = '\0';
3294 return pos; 3323 return pos;
3295 } 3324 }
3296 3325
3297 3326
3298 int String::WriteAscii(char* buffer, 3327 int String::WriteAscii(char* buffer,
3299 int start, 3328 int start,
3300 int length, 3329 int length,
3301 WriteHints hints) const { 3330 WriteHints hints) const {
3302 i::Isolate* isolate = i::Isolate::Current(); 3331 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3303 if (IsDeadCheck(isolate, "v8::String::WriteAscii()")) return 0; 3332 if (IsDeadCheck(isolate, "v8::String::WriteAscii()")) return 0;
3304 LOG_API(isolate, "String::WriteAscii"); 3333 LOG_API(isolate, "String::WriteAscii");
3305 ENTER_V8; 3334 ENTER_V8(isolate);
3306 i::StringInputBuffer& write_input_buffer = *isolate->write_input_buffer(); 3335 i::StringInputBuffer& write_input_buffer = *isolate->write_input_buffer();
3307 ASSERT(start >= 0 && length >= -1); 3336 ASSERT(start >= 0 && length >= -1);
3308 i::Handle<i::String> str = Utils::OpenHandle(this); 3337 i::Handle<i::String> str = Utils::OpenHandle(this);
3309 isolate->string_tracker()->RecordWrite(str); 3338 isolate->string_tracker()->RecordWrite(str);
3310 if (hints & HINT_MANY_WRITES_EXPECTED) { 3339 if (hints & HINT_MANY_WRITES_EXPECTED) {
3311 // Flatten the string for efficiency. This applies whether we are 3340 // Flatten the string for efficiency. This applies whether we are
3312 // using StringInputBuffer or Get(i) to access the characters. 3341 // using StringInputBuffer or Get(i) to access the characters.
3313 str->TryFlatten(); 3342 str->TryFlatten();
3314 } 3343 }
3315 int end = length; 3344 int end = length;
(...skipping 10 matching lines...) Expand all
3326 if (length == -1 || i < length) 3355 if (length == -1 || i < length)
3327 buffer[i] = '\0'; 3356 buffer[i] = '\0';
3328 return i; 3357 return i;
3329 } 3358 }
3330 3359
3331 3360
3332 int String::Write(uint16_t* buffer, 3361 int String::Write(uint16_t* buffer,
3333 int start, 3362 int start,
3334 int length, 3363 int length,
3335 WriteHints hints) const { 3364 WriteHints hints) const {
3336 i::Isolate* isolate = i::Isolate::Current(); 3365 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3337 if (IsDeadCheck(isolate, "v8::String::Write()")) return 0; 3366 if (IsDeadCheck(isolate, "v8::String::Write()")) return 0;
3338 LOG_API(isolate, "String::Write"); 3367 LOG_API(isolate, "String::Write");
3339 ENTER_V8; 3368 ENTER_V8(isolate);
3340 ASSERT(start >= 0 && length >= -1); 3369 ASSERT(start >= 0 && length >= -1);
3341 i::Handle<i::String> str = Utils::OpenHandle(this); 3370 i::Handle<i::String> str = Utils::OpenHandle(this);
3342 isolate->string_tracker()->RecordWrite(str); 3371 isolate->string_tracker()->RecordWrite(str);
3343 if (hints & HINT_MANY_WRITES_EXPECTED) { 3372 if (hints & HINT_MANY_WRITES_EXPECTED) {
3344 // Flatten the string for efficiency. This applies whether we are 3373 // Flatten the string for efficiency. This applies whether we are
3345 // using StringInputBuffer or Get(i) to access the characters. 3374 // using StringInputBuffer or Get(i) to access the characters.
3346 str->TryFlatten(); 3375 str->TryFlatten();
3347 } 3376 }
3348 int end = start + length; 3377 int end = start + length;
3349 if ((length == -1) || (length > str->length() - start) ) 3378 if ((length == -1) || (length > str->length() - start) )
3350 end = str->length(); 3379 end = str->length();
3351 if (end < 0) return 0; 3380 if (end < 0) return 0;
3352 i::String::WriteToFlat(*str, buffer, start, end); 3381 i::String::WriteToFlat(*str, buffer, start, end);
3353 if (length == -1 || end - start < length) { 3382 if (length == -1 || end - start < length) {
3354 buffer[end - start] = '\0'; 3383 buffer[end - start] = '\0';
3355 } 3384 }
3356 return end - start; 3385 return end - start;
3357 } 3386 }
3358 3387
3359 3388
3360 bool v8::String::IsExternal() const { 3389 bool v8::String::IsExternal() const {
3361 EnsureInitialized("v8::String::IsExternal()");
3362 i::Handle<i::String> str = Utils::OpenHandle(this); 3390 i::Handle<i::String> str = Utils::OpenHandle(this);
3391 if (IsDeadCheck(str->GetIsolate(), "v8::String::IsExternal()")) {
3392 return false;
3393 }
3394 EnsureInitializedForIsolate(str->GetIsolate(), "v8::String::IsExternal()");
3363 return i::StringShape(*str).IsExternalTwoByte(); 3395 return i::StringShape(*str).IsExternalTwoByte();
3364 } 3396 }
3365 3397
3366 3398
3367 bool v8::String::IsExternalAscii() const { 3399 bool v8::String::IsExternalAscii() const {
3368 EnsureInitialized("v8::String::IsExternalAscii()");
3369 i::Handle<i::String> str = Utils::OpenHandle(this); 3400 i::Handle<i::String> str = Utils::OpenHandle(this);
3401 if (IsDeadCheck(str->GetIsolate(), "v8::String::IsExternalAscii()")) {
3402 return false;
3403 }
3370 return i::StringShape(*str).IsExternalAscii(); 3404 return i::StringShape(*str).IsExternalAscii();
3371 } 3405 }
3372 3406
3373 3407
3374 void v8::String::VerifyExternalStringResource( 3408 void v8::String::VerifyExternalStringResource(
3375 v8::String::ExternalStringResource* value) const { 3409 v8::String::ExternalStringResource* value) const {
3376 i::Handle<i::String> str = Utils::OpenHandle(this); 3410 i::Handle<i::String> str = Utils::OpenHandle(this);
3377 v8::String::ExternalStringResource* expected; 3411 v8::String::ExternalStringResource* expected;
3378 if (i::StringShape(*str).IsExternalTwoByte()) { 3412 if (i::StringShape(*str).IsExternalTwoByte()) {
3379 void* resource = i::Handle<i::ExternalTwoByteString>::cast(str)->resource(); 3413 void* resource = i::Handle<i::ExternalTwoByteString>::cast(str)->resource();
3380 expected = reinterpret_cast<ExternalStringResource*>(resource); 3414 expected = reinterpret_cast<ExternalStringResource*>(resource);
3381 } else { 3415 } else {
3382 expected = NULL; 3416 expected = NULL;
3383 } 3417 }
3384 CHECK_EQ(expected, value); 3418 CHECK_EQ(expected, value);
3385 } 3419 }
3386 3420
3387 3421
3388 v8::String::ExternalAsciiStringResource* 3422 v8::String::ExternalAsciiStringResource*
3389 v8::String::GetExternalAsciiStringResource() const { 3423 v8::String::GetExternalAsciiStringResource() const {
3390 EnsureInitialized("v8::String::GetExternalAsciiStringResource()");
3391 i::Handle<i::String> str = Utils::OpenHandle(this); 3424 i::Handle<i::String> str = Utils::OpenHandle(this);
3425 if (IsDeadCheck(str->GetIsolate(),
3426 "v8::String::GetExternalAsciiStringResource()")) {
3427 return NULL;
3428 }
3392 if (i::StringShape(*str).IsExternalAscii()) { 3429 if (i::StringShape(*str).IsExternalAscii()) {
3393 void* resource = i::Handle<i::ExternalAsciiString>::cast(str)->resource(); 3430 void* resource = i::Handle<i::ExternalAsciiString>::cast(str)->resource();
3394 return reinterpret_cast<ExternalAsciiStringResource*>(resource); 3431 return reinterpret_cast<ExternalAsciiStringResource*>(resource);
3395 } else { 3432 } else {
3396 return NULL; 3433 return NULL;
3397 } 3434 }
3398 } 3435 }
3399 3436
3400 3437
3401 double Number::Value() const { 3438 double Number::Value() const {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3439 i::Handle<i::Object> obj = Utils::OpenHandle(this); 3476 i::Handle<i::Object> obj = Utils::OpenHandle(this);
3440 if (obj->IsSmi()) { 3477 if (obj->IsSmi()) {
3441 return i::Smi::cast(*obj)->value(); 3478 return i::Smi::cast(*obj)->value();
3442 } else { 3479 } else {
3443 return static_cast<uint32_t>(obj->Number()); 3480 return static_cast<uint32_t>(obj->Number());
3444 } 3481 }
3445 } 3482 }
3446 3483
3447 3484
3448 int v8::Object::InternalFieldCount() { 3485 int v8::Object::InternalFieldCount() {
3449 if (IsDeadCheck(i::Isolate::Current(), "v8::Object::InternalFieldCount()")) { 3486 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
3487 if (IsDeadCheck(obj->GetIsolate(), "v8::Object::InternalFieldCount()")) {
3450 return 0; 3488 return 0;
3451 } 3489 }
3452 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
3453 return obj->GetInternalFieldCount(); 3490 return obj->GetInternalFieldCount();
3454 } 3491 }
3455 3492
3456 3493
3457 Local<Value> v8::Object::CheckedGetInternalField(int index) { 3494 Local<Value> v8::Object::CheckedGetInternalField(int index) {
3458 if (IsDeadCheck(i::Isolate::Current(), "v8::Object::GetInternalField()")) { 3495 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
3496 if (IsDeadCheck(obj->GetIsolate(), "v8::Object::GetInternalField()")) {
3459 return Local<Value>(); 3497 return Local<Value>();
3460 } 3498 }
3461 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
3462 if (!ApiCheck(index < obj->GetInternalFieldCount(), 3499 if (!ApiCheck(index < obj->GetInternalFieldCount(),
3463 "v8::Object::GetInternalField()", 3500 "v8::Object::GetInternalField()",
3464 "Reading internal field out of bounds")) { 3501 "Reading internal field out of bounds")) {
3465 return Local<Value>(); 3502 return Local<Value>();
3466 } 3503 }
3467 i::Handle<i::Object> value(obj->GetInternalField(index)); 3504 i::Handle<i::Object> value(obj->GetInternalField(index));
3468 Local<Value> result = Utils::ToLocal(value); 3505 Local<Value> result = Utils::ToLocal(value);
3469 #ifdef DEBUG 3506 #ifdef DEBUG
3470 Local<Value> unchecked = UncheckedGetInternalField(index); 3507 Local<Value> unchecked = UncheckedGetInternalField(index);
3471 ASSERT(unchecked.IsEmpty() || (unchecked == result)); 3508 ASSERT(unchecked.IsEmpty() || (unchecked == result));
3472 #endif 3509 #endif
3473 return result; 3510 return result;
3474 } 3511 }
3475 3512
3476 3513
3477 void v8::Object::SetInternalField(int index, v8::Handle<Value> value) { 3514 void v8::Object::SetInternalField(int index, v8::Handle<Value> value) {
3478 if (IsDeadCheck(i::Isolate::Current(), "v8::Object::SetInternalField()")) { 3515 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
3516 i::Isolate* isolate = obj->GetIsolate();
3517 if (IsDeadCheck(isolate, "v8::Object::SetInternalField()")) {
3479 return; 3518 return;
3480 } 3519 }
3481 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
3482 if (!ApiCheck(index < obj->GetInternalFieldCount(), 3520 if (!ApiCheck(index < obj->GetInternalFieldCount(),
3483 "v8::Object::SetInternalField()", 3521 "v8::Object::SetInternalField()",
3484 "Writing internal field out of bounds")) { 3522 "Writing internal field out of bounds")) {
3485 return; 3523 return;
3486 } 3524 }
3487 ENTER_V8; 3525 ENTER_V8(isolate);
3488 i::Handle<i::Object> val = Utils::OpenHandle(*value); 3526 i::Handle<i::Object> val = Utils::OpenHandle(*value);
3489 obj->SetInternalField(index, *val); 3527 obj->SetInternalField(index, *val);
3490 } 3528 }
3491 3529
3492 3530
3493 static bool CanBeEncodedAsSmi(void* ptr) { 3531 static bool CanBeEncodedAsSmi(void* ptr) {
3494 const uintptr_t address = reinterpret_cast<uintptr_t>(ptr); 3532 const uintptr_t address = reinterpret_cast<uintptr_t>(ptr);
3495 return ((address & i::kEncodablePointerMask) == 0); 3533 return ((address & i::kEncodablePointerMask) == 0);
3496 } 3534 }
3497 3535
3498 3536
3499 static i::Smi* EncodeAsSmi(void* ptr) { 3537 static i::Smi* EncodeAsSmi(void* ptr) {
3500 ASSERT(CanBeEncodedAsSmi(ptr)); 3538 ASSERT(CanBeEncodedAsSmi(ptr));
3501 const uintptr_t address = reinterpret_cast<uintptr_t>(ptr); 3539 const uintptr_t address = reinterpret_cast<uintptr_t>(ptr);
3502 i::Smi* result = reinterpret_cast<i::Smi*>(address << i::kPointerToSmiShift); 3540 i::Smi* result = reinterpret_cast<i::Smi*>(address << i::kPointerToSmiShift);
3503 ASSERT(i::Internals::HasSmiTag(result)); 3541 ASSERT(i::Internals::HasSmiTag(result));
3504 ASSERT_EQ(result, i::Smi::FromInt(result->value())); 3542 ASSERT_EQ(result, i::Smi::FromInt(result->value()));
3505 ASSERT_EQ(ptr, i::Internals::GetExternalPointerFromSmi(result)); 3543 ASSERT_EQ(ptr, i::Internals::GetExternalPointerFromSmi(result));
3506 return result; 3544 return result;
3507 } 3545 }
3508 3546
3509 3547
3510 void v8::Object::SetPointerInInternalField(int index, void* value) { 3548 void v8::Object::SetPointerInInternalField(int index, void* value) {
3511 ENTER_V8; 3549 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3550 ENTER_V8(isolate);
3512 if (CanBeEncodedAsSmi(value)) { 3551 if (CanBeEncodedAsSmi(value)) {
3513 Utils::OpenHandle(this)->SetInternalField(index, EncodeAsSmi(value)); 3552 Utils::OpenHandle(this)->SetInternalField(index, EncodeAsSmi(value));
3514 } else { 3553 } else {
3515 HandleScope scope; 3554 HandleScope scope;
3516 i::Handle<i::Proxy> proxy = 3555 i::Handle<i::Proxy> proxy =
3517 FACTORY->NewProxy(reinterpret_cast<i::Address>(value), i::TENURED); 3556 isolate->factory()->NewProxy(
3557 reinterpret_cast<i::Address>(value), i::TENURED);
3518 if (!proxy.is_null()) 3558 if (!proxy.is_null())
3519 Utils::OpenHandle(this)->SetInternalField(index, *proxy); 3559 Utils::OpenHandle(this)->SetInternalField(index, *proxy);
3520 } 3560 }
3521 ASSERT_EQ(value, GetPointerFromInternalField(index)); 3561 ASSERT_EQ(value, GetPointerFromInternalField(index));
3522 } 3562 }
3523 3563
3524 3564
3525 // --- E n v i r o n m e n t --- 3565 // --- E n v i r o n m e n t ---
3526 3566
3527 3567
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
3603 v8::Handle<ObjectTemplate> global_template, 3643 v8::Handle<ObjectTemplate> global_template,
3604 v8::Handle<Value> global_object) { 3644 v8::Handle<Value> global_object) {
3605 i::Isolate* isolate = i::Isolate::Current(); 3645 i::Isolate* isolate = i::Isolate::Current();
3606 EnsureInitializedForIsolate(isolate, "v8::Context::New()"); 3646 EnsureInitializedForIsolate(isolate, "v8::Context::New()");
3607 LOG_API(isolate, "Context::New"); 3647 LOG_API(isolate, "Context::New");
3608 ON_BAILOUT(isolate, "v8::Context::New()", return Persistent<Context>()); 3648 ON_BAILOUT(isolate, "v8::Context::New()", return Persistent<Context>());
3609 3649
3610 // Enter V8 via an ENTER_V8 scope. 3650 // Enter V8 via an ENTER_V8 scope.
3611 i::Handle<i::Context> env; 3651 i::Handle<i::Context> env;
3612 { 3652 {
3613 ENTER_V8; 3653 ENTER_V8(isolate);
3614 v8::Handle<ObjectTemplate> proxy_template = global_template; 3654 v8::Handle<ObjectTemplate> proxy_template = global_template;
3615 i::Handle<i::FunctionTemplateInfo> proxy_constructor; 3655 i::Handle<i::FunctionTemplateInfo> proxy_constructor;
3616 i::Handle<i::FunctionTemplateInfo> global_constructor; 3656 i::Handle<i::FunctionTemplateInfo> global_constructor;
3617 3657
3618 if (!global_template.IsEmpty()) { 3658 if (!global_template.IsEmpty()) {
3619 // Make sure that the global_template has a constructor. 3659 // Make sure that the global_template has a constructor.
3620 global_constructor = 3660 global_constructor =
3621 EnsureConstructor(Utils::OpenHandle(*global_template)); 3661 EnsureConstructor(Utils::OpenHandle(*global_template));
3622 3662
3623 // Create a fresh template for the global proxy object. 3663 // Create a fresh template for the global proxy object.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
3662 } 3702 }
3663 // Leave V8. 3703 // Leave V8.
3664 3704
3665 if (env.is_null()) 3705 if (env.is_null())
3666 return Persistent<Context>(); 3706 return Persistent<Context>();
3667 return Persistent<Context>(Utils::ToLocal(env)); 3707 return Persistent<Context>(Utils::ToLocal(env));
3668 } 3708 }
3669 3709
3670 3710
3671 void v8::Context::SetSecurityToken(Handle<Value> token) { 3711 void v8::Context::SetSecurityToken(Handle<Value> token) {
3672 if (IsDeadCheck(i::Isolate::Current(), "v8::Context::SetSecurityToken()")) { 3712 i::Isolate* isolate = i::Isolate::Current();
3713 if (IsDeadCheck(isolate, "v8::Context::SetSecurityToken()")) {
3673 return; 3714 return;
3674 } 3715 }
3675 ENTER_V8; 3716 ENTER_V8(isolate);
3676 i::Handle<i::Context> env = Utils::OpenHandle(this); 3717 i::Handle<i::Context> env = Utils::OpenHandle(this);
3677 i::Handle<i::Object> token_handle = Utils::OpenHandle(*token); 3718 i::Handle<i::Object> token_handle = Utils::OpenHandle(*token);
3678 env->set_security_token(*token_handle); 3719 env->set_security_token(*token_handle);
3679 } 3720 }
3680 3721
3681 3722
3682 void v8::Context::UseDefaultSecurityToken() { 3723 void v8::Context::UseDefaultSecurityToken() {
3683 if (IsDeadCheck(i::Isolate::Current(), 3724 i::Isolate* isolate = i::Isolate::Current();
3725 if (IsDeadCheck(isolate,
3684 "v8::Context::UseDefaultSecurityToken()")) { 3726 "v8::Context::UseDefaultSecurityToken()")) {
3685 return; 3727 return;
3686 } 3728 }
3687 ENTER_V8; 3729 ENTER_V8(isolate);
3688 i::Handle<i::Context> env = Utils::OpenHandle(this); 3730 i::Handle<i::Context> env = Utils::OpenHandle(this);
3689 env->set_security_token(env->global()); 3731 env->set_security_token(env->global());
3690 } 3732 }
3691 3733
3692 3734
3693 Handle<Value> v8::Context::GetSecurityToken() { 3735 Handle<Value> v8::Context::GetSecurityToken() {
3694 if (IsDeadCheck(i::Isolate::Current(), "v8::Context::GetSecurityToken()")) { 3736 i::Isolate* isolate = i::Isolate::Current();
3737 if (IsDeadCheck(isolate, "v8::Context::GetSecurityToken()")) {
3695 return Handle<Value>(); 3738 return Handle<Value>();
3696 } 3739 }
3697 i::Handle<i::Context> env = Utils::OpenHandle(this); 3740 i::Handle<i::Context> env = Utils::OpenHandle(this);
3698 i::Object* security_token = env->security_token(); 3741 i::Object* security_token = env->security_token();
3699 i::Handle<i::Object> token_handle(security_token); 3742 i::Handle<i::Object> token_handle(security_token);
3700 return Utils::ToLocal(token_handle); 3743 return Utils::ToLocal(token_handle);
3701 } 3744 }
3702 3745
3703 3746
3704 bool Context::HasOutOfMemoryException() { 3747 bool Context::HasOutOfMemoryException() {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
3758 i::Handle<i::Context> context = 3801 i::Handle<i::Context> context =
3759 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx)); 3802 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx));
3760 i::Handle<i::Object> global(context->global_proxy()); 3803 i::Handle<i::Object> global(context->global_proxy());
3761 return Utils::ToLocal(i::Handle<i::JSObject>::cast(global)); 3804 return Utils::ToLocal(i::Handle<i::JSObject>::cast(global));
3762 } 3805 }
3763 3806
3764 3807
3765 void Context::DetachGlobal() { 3808 void Context::DetachGlobal() {
3766 i::Isolate* isolate = i::Isolate::Current(); 3809 i::Isolate* isolate = i::Isolate::Current();
3767 if (IsDeadCheck(isolate, "v8::Context::DetachGlobal()")) return; 3810 if (IsDeadCheck(isolate, "v8::Context::DetachGlobal()")) return;
3768 ENTER_V8; 3811 ENTER_V8(isolate);
3769 i::Object** ctx = reinterpret_cast<i::Object**>(this); 3812 i::Object** ctx = reinterpret_cast<i::Object**>(this);
3770 i::Handle<i::Context> context = 3813 i::Handle<i::Context> context =
3771 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx)); 3814 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx));
3772 isolate->bootstrapper()->DetachGlobal(context); 3815 isolate->bootstrapper()->DetachGlobal(context);
3773 } 3816 }
3774 3817
3775 3818
3776 void Context::ReattachGlobal(Handle<Object> global_object) { 3819 void Context::ReattachGlobal(Handle<Object> global_object) {
3777 i::Isolate* isolate = i::Isolate::Current(); 3820 i::Isolate* isolate = i::Isolate::Current();
3778 if (IsDeadCheck(isolate, "v8::Context::ReattachGlobal()")) return; 3821 if (IsDeadCheck(isolate, "v8::Context::ReattachGlobal()")) return;
3779 ENTER_V8; 3822 ENTER_V8(isolate);
3780 i::Object** ctx = reinterpret_cast<i::Object**>(this); 3823 i::Object** ctx = reinterpret_cast<i::Object**>(this);
3781 i::Handle<i::Context> context = 3824 i::Handle<i::Context> context =
3782 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx)); 3825 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx));
3783 isolate->bootstrapper()->ReattachGlobal( 3826 isolate->bootstrapper()->ReattachGlobal(
3784 context, 3827 context,
3785 Utils::OpenHandle(*global_object)); 3828 Utils::OpenHandle(*global_object));
3786 } 3829 }
3787 3830
3788 3831
3789 void V8::SetWrapperClassId(i::Object** global_handle, uint16_t class_id) { 3832 void V8::SetWrapperClassId(i::Object** global_handle, uint16_t class_id) {
3790 i::GlobalHandles::SetWrapperClassId(global_handle, class_id); 3833 i::GlobalHandles::SetWrapperClassId(global_handle, class_id);
3791 } 3834 }
3792 3835
3793 3836
3794 Local<v8::Object> ObjectTemplate::NewInstance() { 3837 Local<v8::Object> ObjectTemplate::NewInstance() {
3795 i::Isolate* isolate = i::Isolate::Current(); 3838 i::Isolate* isolate = i::Isolate::Current();
3796 ON_BAILOUT(isolate, "v8::ObjectTemplate::NewInstance()", 3839 ON_BAILOUT(isolate, "v8::ObjectTemplate::NewInstance()",
3797 return Local<v8::Object>()); 3840 return Local<v8::Object>());
3798 LOG_API(isolate, "ObjectTemplate::NewInstance"); 3841 LOG_API(isolate, "ObjectTemplate::NewInstance");
3799 ENTER_V8; 3842 ENTER_V8(isolate);
3800 EXCEPTION_PREAMBLE(); 3843 EXCEPTION_PREAMBLE(isolate);
3801 i::Handle<i::Object> obj = 3844 i::Handle<i::Object> obj =
3802 i::Execution::InstantiateObject(Utils::OpenHandle(this), 3845 i::Execution::InstantiateObject(Utils::OpenHandle(this),
3803 &has_pending_exception); 3846 &has_pending_exception);
3804 EXCEPTION_BAILOUT_CHECK(Local<v8::Object>()); 3847 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>());
3805 return Utils::ToLocal(i::Handle<i::JSObject>::cast(obj)); 3848 return Utils::ToLocal(i::Handle<i::JSObject>::cast(obj));
3806 } 3849 }
3807 3850
3808 3851
3809 Local<v8::Function> FunctionTemplate::GetFunction() { 3852 Local<v8::Function> FunctionTemplate::GetFunction() {
3810 i::Isolate* isolate = i::Isolate::Current(); 3853 i::Isolate* isolate = i::Isolate::Current();
3811 ON_BAILOUT(isolate, "v8::FunctionTemplate::GetFunction()", 3854 ON_BAILOUT(isolate, "v8::FunctionTemplate::GetFunction()",
3812 return Local<v8::Function>()); 3855 return Local<v8::Function>());
3813 LOG_API(isolate, "FunctionTemplate::GetFunction"); 3856 LOG_API(isolate, "FunctionTemplate::GetFunction");
3814 ENTER_V8; 3857 ENTER_V8(isolate);
3815 EXCEPTION_PREAMBLE(); 3858 EXCEPTION_PREAMBLE(isolate);
3816 i::Handle<i::Object> obj = 3859 i::Handle<i::Object> obj =
3817 i::Execution::InstantiateFunction(Utils::OpenHandle(this), 3860 i::Execution::InstantiateFunction(Utils::OpenHandle(this),
3818 &has_pending_exception); 3861 &has_pending_exception);
3819 EXCEPTION_BAILOUT_CHECK(Local<v8::Function>()); 3862 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Function>());
3820 return Utils::ToLocal(i::Handle<i::JSFunction>::cast(obj)); 3863 return Utils::ToLocal(i::Handle<i::JSFunction>::cast(obj));
3821 } 3864 }
3822 3865
3823 3866
3824 bool FunctionTemplate::HasInstance(v8::Handle<v8::Value> value) { 3867 bool FunctionTemplate::HasInstance(v8::Handle<v8::Value> value) {
3825 ON_BAILOUT(i::Isolate::Current(), "v8::FunctionTemplate::HasInstanceOf()", 3868 ON_BAILOUT(i::Isolate::Current(), "v8::FunctionTemplate::HasInstanceOf()",
3826 return false); 3869 return false);
3827 i::Object* obj = *Utils::OpenHandle(*value); 3870 i::Object* obj = *Utils::OpenHandle(*value);
3828 return obj->IsInstanceOf(*Utils::OpenHandle(this)); 3871 return obj->IsInstanceOf(*Utils::OpenHandle(this));
3829 } 3872 }
3830 3873
3831 3874
3832 static Local<External> ExternalNewImpl(void* data) { 3875 static Local<External> ExternalNewImpl(void* data) {
3833 return Utils::ToLocal(FACTORY->NewProxy(static_cast<i::Address>(data))); 3876 return Utils::ToLocal(FACTORY->NewProxy(static_cast<i::Address>(data)));
3834 } 3877 }
3835 3878
3836 static void* ExternalValueImpl(i::Handle<i::Object> obj) { 3879 static void* ExternalValueImpl(i::Handle<i::Object> obj) {
3837 return reinterpret_cast<void*>(i::Proxy::cast(*obj)->proxy()); 3880 return reinterpret_cast<void*>(i::Proxy::cast(*obj)->proxy());
3838 } 3881 }
3839 3882
3840 3883
3841 Local<Value> v8::External::Wrap(void* data) { 3884 Local<Value> v8::External::Wrap(void* data) {
3842 i::Isolate* isolate = i::Isolate::Current(); 3885 i::Isolate* isolate = i::Isolate::Current();
3843 STATIC_ASSERT(sizeof(data) == sizeof(i::Address)); 3886 STATIC_ASSERT(sizeof(data) == sizeof(i::Address));
3844 LOG_API(isolate, "External::Wrap"); 3887 LOG_API(isolate, "External::Wrap");
3845 EnsureInitializedForIsolate(isolate, "v8::External::Wrap()"); 3888 EnsureInitializedForIsolate(isolate, "v8::External::Wrap()");
3846 ENTER_V8; 3889 ENTER_V8(isolate);
3847 3890
3848 v8::Local<v8::Value> result = CanBeEncodedAsSmi(data) 3891 v8::Local<v8::Value> result = CanBeEncodedAsSmi(data)
3849 ? Utils::ToLocal(i::Handle<i::Object>(EncodeAsSmi(data))) 3892 ? Utils::ToLocal(i::Handle<i::Object>(EncodeAsSmi(data)))
3850 : v8::Local<v8::Value>(ExternalNewImpl(data)); 3893 : v8::Local<v8::Value>(ExternalNewImpl(data));
3851 3894
3852 ASSERT_EQ(data, Unwrap(result)); 3895 ASSERT_EQ(data, Unwrap(result));
3853 return result; 3896 return result;
3854 } 3897 }
3855 3898
3856 3899
(...skipping 24 matching lines...) Expand all
3881 ASSERT_EQ(result, QuickUnwrap(wrapper)); 3924 ASSERT_EQ(result, QuickUnwrap(wrapper));
3882 return result; 3925 return result;
3883 } 3926 }
3884 3927
3885 3928
3886 Local<External> v8::External::New(void* data) { 3929 Local<External> v8::External::New(void* data) {
3887 STATIC_ASSERT(sizeof(data) == sizeof(i::Address)); 3930 STATIC_ASSERT(sizeof(data) == sizeof(i::Address));
3888 i::Isolate* isolate = i::Isolate::Current(); 3931 i::Isolate* isolate = i::Isolate::Current();
3889 LOG_API(isolate, "External::New"); 3932 LOG_API(isolate, "External::New");
3890 EnsureInitializedForIsolate(isolate, "v8::External::New()"); 3933 EnsureInitializedForIsolate(isolate, "v8::External::New()");
3891 ENTER_V8; 3934 ENTER_V8(isolate);
3892 return ExternalNewImpl(data); 3935 return ExternalNewImpl(data);
3893 } 3936 }
3894 3937
3895 3938
3896 void* External::Value() const { 3939 void* External::Value() const {
3897 if (IsDeadCheck(i::Isolate::Current(), "v8::External::Value()")) return 0; 3940 if (IsDeadCheck(i::Isolate::Current(), "v8::External::Value()")) return 0;
3898 i::Handle<i::Object> obj = Utils::OpenHandle(this); 3941 i::Handle<i::Object> obj = Utils::OpenHandle(this);
3899 return ExternalValueImpl(obj); 3942 return ExternalValueImpl(obj);
3900 } 3943 }
3901 3944
3902 3945
3903 Local<String> v8::String::Empty() { 3946 Local<String> v8::String::Empty() {
3904 i::Isolate* isolate = i::Isolate::Current(); 3947 i::Isolate* isolate = i::Isolate::Current();
3905 EnsureInitializedForIsolate(isolate, "v8::String::Empty()"); 3948 EnsureInitializedForIsolate(isolate, "v8::String::Empty()");
3906 LOG_API(isolate, "String::Empty()"); 3949 LOG_API(isolate, "String::Empty()");
3907 return Utils::ToLocal(isolate->factory()->empty_symbol()); 3950 return Utils::ToLocal(isolate->factory()->empty_symbol());
3908 } 3951 }
3909 3952
3910 3953
3911 Local<String> v8::String::New(const char* data, int length) { 3954 Local<String> v8::String::New(const char* data, int length) {
3912 i::Isolate* isolate = i::Isolate::Current(); 3955 i::Isolate* isolate = i::Isolate::Current();
3913 EnsureInitializedForIsolate(isolate, "v8::String::New()"); 3956 EnsureInitializedForIsolate(isolate, "v8::String::New()");
3914 LOG_API(isolate, "String::New(char)"); 3957 LOG_API(isolate, "String::New(char)");
3915 if (length == 0) return Empty(); 3958 if (length == 0) return Empty();
3916 ENTER_V8; 3959 ENTER_V8(isolate);
3917 if (length == -1) length = i::StrLength(data); 3960 if (length == -1) length = i::StrLength(data);
3918 i::Handle<i::String> result = 3961 i::Handle<i::String> result =
3919 isolate->factory()->NewStringFromUtf8( 3962 isolate->factory()->NewStringFromUtf8(
3920 i::Vector<const char>(data, length)); 3963 i::Vector<const char>(data, length));
3921 return Utils::ToLocal(result); 3964 return Utils::ToLocal(result);
3922 } 3965 }
3923 3966
3924 3967
3925 Local<String> v8::String::Concat(Handle<String> left, Handle<String> right) { 3968 Local<String> v8::String::Concat(Handle<String> left, Handle<String> right) {
3926 i::Handle<i::String> left_string = Utils::OpenHandle(*left); 3969 i::Handle<i::String> left_string = Utils::OpenHandle(*left);
3927 i::Isolate* isolate = left_string->GetIsolate(); 3970 i::Isolate* isolate = left_string->GetIsolate();
3928 EnsureInitializedForIsolate(isolate, "v8::String::Concat()"); 3971 EnsureInitializedForIsolate(isolate, "v8::String::New()");
3929 LOG_API(isolate, "String::Concat()"); 3972 LOG_API(isolate, "String::New(char)");
3930 ENTER_V8; 3973 ENTER_V8(isolate);
3931 i::Handle<i::String> right_string = Utils::OpenHandle(*right); 3974 i::Handle<i::String> right_string = Utils::OpenHandle(*right);
3932 i::Handle<i::String> result = isolate->factory()->NewConsString(left_string, 3975 i::Handle<i::String> result = isolate->factory()->NewConsString(left_string,
3933 right_string); 3976 right_string);
3934 return Utils::ToLocal(result); 3977 return Utils::ToLocal(result);
3935 } 3978 }
3936 3979
3937 3980
3938 Local<String> v8::String::NewUndetectable(const char* data, int length) { 3981 Local<String> v8::String::NewUndetectable(const char* data, int length) {
3939 i::Isolate* isolate = i::Isolate::Current(); 3982 i::Isolate* isolate = i::Isolate::Current();
3940 EnsureInitializedForIsolate(isolate, "v8::String::NewUndetectable()"); 3983 EnsureInitializedForIsolate(isolate, "v8::String::NewUndetectable()");
3941 LOG_API(isolate, "String::NewUndetectable(char)"); 3984 LOG_API(isolate, "String::NewUndetectable(char)");
3942 ENTER_V8; 3985 ENTER_V8(isolate);
3943 if (length == -1) length = i::StrLength(data); 3986 if (length == -1) length = i::StrLength(data);
3944 i::Handle<i::String> result = 3987 i::Handle<i::String> result =
3945 isolate->factory()->NewStringFromUtf8( 3988 isolate->factory()->NewStringFromUtf8(
3946 i::Vector<const char>(data, length)); 3989 i::Vector<const char>(data, length));
3947 result->MarkAsUndetectable(); 3990 result->MarkAsUndetectable();
3948 return Utils::ToLocal(result); 3991 return Utils::ToLocal(result);
3949 } 3992 }
3950 3993
3951 3994
3952 static int TwoByteStringLength(const uint16_t* data) { 3995 static int TwoByteStringLength(const uint16_t* data) {
3953 int length = 0; 3996 int length = 0;
3954 while (data[length] != '\0') length++; 3997 while (data[length] != '\0') length++;
3955 return length; 3998 return length;
3956 } 3999 }
3957 4000
3958 4001
3959 Local<String> v8::String::New(const uint16_t* data, int length) { 4002 Local<String> v8::String::New(const uint16_t* data, int length) {
3960 i::Isolate* isolate = i::Isolate::Current(); 4003 i::Isolate* isolate = i::Isolate::Current();
3961 EnsureInitializedForIsolate(isolate, "v8::String::New()"); 4004 EnsureInitializedForIsolate(isolate, "v8::String::New()");
3962 LOG_API(isolate, "String::New(uint16_)"); 4005 LOG_API(isolate, "String::New(uint16_)");
3963 if (length == 0) return Empty(); 4006 if (length == 0) return Empty();
3964 ENTER_V8; 4007 ENTER_V8(isolate);
3965 if (length == -1) length = TwoByteStringLength(data); 4008 if (length == -1) length = TwoByteStringLength(data);
3966 i::Handle<i::String> result = 4009 i::Handle<i::String> result =
3967 isolate->factory()->NewStringFromTwoByte( 4010 isolate->factory()->NewStringFromTwoByte(
3968 i::Vector<const uint16_t>(data, length)); 4011 i::Vector<const uint16_t>(data, length));
3969 return Utils::ToLocal(result); 4012 return Utils::ToLocal(result);
3970 } 4013 }
3971 4014
3972 4015
3973 Local<String> v8::String::NewUndetectable(const uint16_t* data, int length) { 4016 Local<String> v8::String::NewUndetectable(const uint16_t* data, int length) {
3974 i::Isolate* isolate = i::Isolate::Current(); 4017 i::Isolate* isolate = i::Isolate::Current();
3975 EnsureInitializedForIsolate(isolate, "v8::String::NewUndetectable()"); 4018 EnsureInitializedForIsolate(isolate, "v8::String::NewUndetectable()");
3976 LOG_API(isolate, "String::NewUndetectable(uint16_)"); 4019 LOG_API(isolate, "String::NewUndetectable(uint16_)");
3977 ENTER_V8; 4020 ENTER_V8(isolate);
3978 if (length == -1) length = TwoByteStringLength(data); 4021 if (length == -1) length = TwoByteStringLength(data);
3979 i::Handle<i::String> result = 4022 i::Handle<i::String> result =
3980 isolate->factory()->NewStringFromTwoByte( 4023 isolate->factory()->NewStringFromTwoByte(
3981 i::Vector<const uint16_t>(data, length)); 4024 i::Vector<const uint16_t>(data, length));
3982 result->MarkAsUndetectable(); 4025 result->MarkAsUndetectable();
3983 return Utils::ToLocal(result); 4026 return Utils::ToLocal(result);
3984 } 4027 }
3985 4028
3986 4029
3987 i::Handle<i::String> NewExternalStringHandle(i::Isolate* isolate, 4030 i::Handle<i::String> NewExternalStringHandle(i::Isolate* isolate,
(...skipping 10 matching lines...) Expand all
3998 isolate->factory()->NewExternalStringFromAscii(resource); 4041 isolate->factory()->NewExternalStringFromAscii(resource);
3999 return result; 4042 return result;
4000 } 4043 }
4001 4044
4002 4045
4003 Local<String> v8::String::NewExternal( 4046 Local<String> v8::String::NewExternal(
4004 v8::String::ExternalStringResource* resource) { 4047 v8::String::ExternalStringResource* resource) {
4005 i::Isolate* isolate = i::Isolate::Current(); 4048 i::Isolate* isolate = i::Isolate::Current();
4006 EnsureInitializedForIsolate(isolate, "v8::String::NewExternal()"); 4049 EnsureInitializedForIsolate(isolate, "v8::String::NewExternal()");
4007 LOG_API(isolate, "String::NewExternal"); 4050 LOG_API(isolate, "String::NewExternal");
4008 ENTER_V8; 4051 ENTER_V8(isolate);
4009 i::Handle<i::String> result = NewExternalStringHandle(isolate, resource); 4052 i::Handle<i::String> result = NewExternalStringHandle(isolate, resource);
4010 isolate->heap()->external_string_table()->AddString(*result); 4053 isolate->heap()->external_string_table()->AddString(*result);
4011 return Utils::ToLocal(result); 4054 return Utils::ToLocal(result);
4012 } 4055 }
4013 4056
4014 4057
4015 bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) { 4058 bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) {
4016 i::Handle<i::String> obj = Utils::OpenHandle(this); 4059 i::Handle<i::String> obj = Utils::OpenHandle(this);
4017 i::Isolate* isolate = obj->GetIsolate(); 4060 i::Isolate* isolate = obj->GetIsolate();
4018 if (IsDeadCheck(isolate, "v8::String::MakeExternal()")) return false; 4061 if (IsDeadCheck(isolate, "v8::String::MakeExternal()")) return false;
4019 if (this->IsExternal()) return false; // Already an external string. 4062 if (i::StringShape(*obj).IsExternalTwoByte()) {
4020 ENTER_V8; 4063 return false; // Already an external string.
4064 }
4065 ENTER_V8(isolate);
4021 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { 4066 if (isolate->string_tracker()->IsFreshUnusedString(obj)) {
4022 return false; 4067 return false;
4023 } 4068 }
4024 bool result = obj->MakeExternal(resource); 4069 bool result = obj->MakeExternal(resource);
4025 if (result && !obj->IsSymbol()) { 4070 if (result && !obj->IsSymbol()) {
4026 isolate->heap()->external_string_table()->AddString(*obj); 4071 isolate->heap()->external_string_table()->AddString(*obj);
4027 } 4072 }
4028 return result; 4073 return result;
4029 } 4074 }
4030 4075
4031 4076
4032 Local<String> v8::String::NewExternal( 4077 Local<String> v8::String::NewExternal(
4033 v8::String::ExternalAsciiStringResource* resource) { 4078 v8::String::ExternalAsciiStringResource* resource) {
4034 i::Isolate* isolate = i::Isolate::Current(); 4079 i::Isolate* isolate = i::Isolate::Current();
4035 EnsureInitializedForIsolate(isolate, "v8::String::NewExternal()"); 4080 EnsureInitializedForIsolate(isolate, "v8::String::NewExternal()");
4036 LOG_API(isolate, "String::NewExternal"); 4081 LOG_API(isolate, "String::NewExternal");
4037 ENTER_V8; 4082 ENTER_V8(isolate);
4038 i::Handle<i::String> result = NewExternalAsciiStringHandle(isolate, resource); 4083 i::Handle<i::String> result = NewExternalAsciiStringHandle(isolate, resource);
4039 isolate->heap()->external_string_table()->AddString(*result); 4084 isolate->heap()->external_string_table()->AddString(*result);
4040 return Utils::ToLocal(result); 4085 return Utils::ToLocal(result);
4041 } 4086 }
4042 4087
4043 4088
4044 bool v8::String::MakeExternal( 4089 bool v8::String::MakeExternal(
4045 v8::String::ExternalAsciiStringResource* resource) { 4090 v8::String::ExternalAsciiStringResource* resource) {
4046 i::Handle<i::String> obj = Utils::OpenHandle(this); 4091 i::Handle<i::String> obj = Utils::OpenHandle(this);
4047 i::Isolate* isolate = obj->GetIsolate(); 4092 i::Isolate* isolate = obj->GetIsolate();
4048 if (IsDeadCheck(isolate, "v8::String::MakeExternal()")) return false; 4093 if (IsDeadCheck(isolate, "v8::String::MakeExternal()")) return false;
4049 if (this->IsExternal()) return false; // Already an external string. 4094 if (i::StringShape(*obj).IsExternalTwoByte()) {
4050 ENTER_V8; 4095 return false; // Already an external string.
4096 }
4097 ENTER_V8(isolate);
4051 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { 4098 if (isolate->string_tracker()->IsFreshUnusedString(obj)) {
4052 return false; 4099 return false;
4053 } 4100 }
4054 bool result = obj->MakeExternal(resource); 4101 bool result = obj->MakeExternal(resource);
4055 if (result && !obj->IsSymbol()) { 4102 if (result && !obj->IsSymbol()) {
4056 isolate->heap()->external_string_table()->AddString(*obj); 4103 isolate->heap()->external_string_table()->AddString(*obj);
4057 } 4104 }
4058 return result; 4105 return result;
4059 } 4106 }
4060 4107
(...skipping 10 matching lines...) Expand all
4071 return false; 4118 return false;
4072 i::StringShape shape(*obj); 4119 i::StringShape shape(*obj);
4073 return !shape.IsExternal(); 4120 return !shape.IsExternal();
4074 } 4121 }
4075 4122
4076 4123
4077 Local<v8::Object> v8::Object::New() { 4124 Local<v8::Object> v8::Object::New() {
4078 i::Isolate* isolate = i::Isolate::Current(); 4125 i::Isolate* isolate = i::Isolate::Current();
4079 EnsureInitializedForIsolate(isolate, "v8::Object::New()"); 4126 EnsureInitializedForIsolate(isolate, "v8::Object::New()");
4080 LOG_API(isolate, "Object::New"); 4127 LOG_API(isolate, "Object::New");
4081 ENTER_V8; 4128 ENTER_V8(isolate);
4082 i::Handle<i::JSObject> obj = 4129 i::Handle<i::JSObject> obj =
4083 isolate->factory()->NewJSObject(isolate->object_function()); 4130 isolate->factory()->NewJSObject(isolate->object_function());
4084 return Utils::ToLocal(obj); 4131 return Utils::ToLocal(obj);
4085 } 4132 }
4086 4133
4087 4134
4088 Local<v8::Value> v8::Date::New(double time) { 4135 Local<v8::Value> v8::Date::New(double time) {
4089 i::Isolate* isolate = i::Isolate::Current(); 4136 i::Isolate* isolate = i::Isolate::Current();
4090 EnsureInitializedForIsolate(isolate, "v8::Date::New()"); 4137 EnsureInitializedForIsolate(isolate, "v8::Date::New()");
4091 LOG_API(isolate, "Date::New"); 4138 LOG_API(isolate, "Date::New");
4092 if (isnan(time)) { 4139 if (isnan(time)) {
4093 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. 4140 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs.
4094 time = i::OS::nan_value(); 4141 time = i::OS::nan_value();
4095 } 4142 }
4096 ENTER_V8; 4143 ENTER_V8(isolate);
4097 EXCEPTION_PREAMBLE(); 4144 EXCEPTION_PREAMBLE(isolate);
4098 i::Handle<i::Object> obj = 4145 i::Handle<i::Object> obj =
4099 i::Execution::NewDate(time, &has_pending_exception); 4146 i::Execution::NewDate(time, &has_pending_exception);
4100 EXCEPTION_BAILOUT_CHECK(Local<v8::Value>()); 4147 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Value>());
4101 return Utils::ToLocal(obj); 4148 return Utils::ToLocal(obj);
4102 } 4149 }
4103 4150
4104 4151
4105 double v8::Date::NumberValue() const { 4152 double v8::Date::NumberValue() const {
4106 i::Isolate* isolate = i::Isolate::Current(); 4153 i::Isolate* isolate = i::Isolate::Current();
4107 if (IsDeadCheck(isolate, "v8::Date::NumberValue()")) return 0; 4154 if (IsDeadCheck(isolate, "v8::Date::NumberValue()")) return 0;
4108 LOG_API(isolate, "Date::NumberValue"); 4155 LOG_API(isolate, "Date::NumberValue");
4109 i::Handle<i::Object> obj = Utils::OpenHandle(this); 4156 i::Handle<i::Object> obj = Utils::OpenHandle(this);
4110 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); 4157 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj);
4111 return jsvalue->value()->Number(); 4158 return jsvalue->value()->Number();
4112 } 4159 }
4113 4160
4114 4161
4115 void v8::Date::DateTimeConfigurationChangeNotification() { 4162 void v8::Date::DateTimeConfigurationChangeNotification() {
4116 i::Isolate* isolate = i::Isolate::Current(); 4163 i::Isolate* isolate = i::Isolate::Current();
4117 ON_BAILOUT(isolate, "v8::Date::DateTimeConfigurationChangeNotification()", 4164 ON_BAILOUT(isolate, "v8::Date::DateTimeConfigurationChangeNotification()",
4118 return); 4165 return);
4119 LOG_API(isolate, "Date::DateTimeConfigurationChangeNotification"); 4166 LOG_API(isolate, "Date::DateTimeConfigurationChangeNotification");
4120 ENTER_V8; 4167 ENTER_V8(isolate);
4121 4168
4122 i::HandleScope scope(isolate); 4169 i::HandleScope scope(isolate);
4123 // Get the function ResetDateCache (defined in date-delay.js). 4170 // Get the function ResetDateCache (defined in date-delay.js).
4124 i::Handle<i::String> func_name_str = 4171 i::Handle<i::String> func_name_str =
4125 isolate->factory()->LookupAsciiSymbol("ResetDateCache"); 4172 isolate->factory()->LookupAsciiSymbol("ResetDateCache");
4126 i::MaybeObject* result = 4173 i::MaybeObject* result =
4127 isolate->js_builtins_object()->GetProperty(*func_name_str); 4174 isolate->js_builtins_object()->GetProperty(*func_name_str);
4128 i::Object* object_func; 4175 i::Object* object_func;
4129 if (!result->ToObject(&object_func)) { 4176 if (!result->ToObject(&object_func)) {
4130 return; 4177 return;
(...skipping 19 matching lines...) Expand all
4150 if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm'; 4197 if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm';
4151 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i'; 4198 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i';
4152 ASSERT(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf))); 4199 ASSERT(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf)));
4153 return FACTORY->LookupSymbol( 4200 return FACTORY->LookupSymbol(
4154 i::Vector<const char>(flags_buf, num_flags)); 4201 i::Vector<const char>(flags_buf, num_flags));
4155 } 4202 }
4156 4203
4157 4204
4158 Local<v8::RegExp> v8::RegExp::New(Handle<String> pattern, 4205 Local<v8::RegExp> v8::RegExp::New(Handle<String> pattern,
4159 Flags flags) { 4206 Flags flags) {
4160 i::Isolate* isolate = i::Isolate::Current(); 4207 i::Isolate* isolate = Utils::OpenHandle(*pattern)->GetIsolate();
4161 EnsureInitializedForIsolate(isolate, "v8::RegExp::New()"); 4208 EnsureInitializedForIsolate(isolate, "v8::RegExp::New()");
4162 LOG_API(isolate, "RegExp::New"); 4209 LOG_API(isolate, "RegExp::New");
4163 ENTER_V8; 4210 ENTER_V8(isolate);
4164 EXCEPTION_PREAMBLE(); 4211 EXCEPTION_PREAMBLE(isolate);
4165 i::Handle<i::JSRegExp> obj = i::Execution::NewJSRegExp( 4212 i::Handle<i::JSRegExp> obj = i::Execution::NewJSRegExp(
4166 Utils::OpenHandle(*pattern), 4213 Utils::OpenHandle(*pattern),
4167 RegExpFlagsToString(flags), 4214 RegExpFlagsToString(flags),
4168 &has_pending_exception); 4215 &has_pending_exception);
4169 EXCEPTION_BAILOUT_CHECK(Local<v8::RegExp>()); 4216 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::RegExp>());
4170 return Utils::ToLocal(i::Handle<i::JSRegExp>::cast(obj)); 4217 return Utils::ToLocal(i::Handle<i::JSRegExp>::cast(obj));
4171 } 4218 }
4172 4219
4173 4220
4174 Local<v8::String> v8::RegExp::GetSource() const { 4221 Local<v8::String> v8::RegExp::GetSource() const {
4175 i::Isolate* isolate = i::Isolate::Current(); 4222 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4176 if (IsDeadCheck(isolate, "v8::RegExp::GetSource()")) { 4223 if (IsDeadCheck(isolate, "v8::RegExp::GetSource()")) {
4177 return Local<v8::String>(); 4224 return Local<v8::String>();
4178 } 4225 }
4179 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); 4226 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this);
4180 return Utils::ToLocal(i::Handle<i::String>(obj->Pattern())); 4227 return Utils::ToLocal(i::Handle<i::String>(obj->Pattern()));
4181 } 4228 }
4182 4229
4183 4230
4184 // Assert that the static flags cast in GetFlags is valid. 4231 // Assert that the static flags cast in GetFlags is valid.
4185 #define REGEXP_FLAG_ASSERT_EQ(api_flag, internal_flag) \ 4232 #define REGEXP_FLAG_ASSERT_EQ(api_flag, internal_flag) \
(...skipping 11 matching lines...) Expand all
4197 } 4244 }
4198 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); 4245 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this);
4199 return static_cast<RegExp::Flags>(obj->GetFlags().value()); 4246 return static_cast<RegExp::Flags>(obj->GetFlags().value());
4200 } 4247 }
4201 4248
4202 4249
4203 Local<v8::Array> v8::Array::New(int length) { 4250 Local<v8::Array> v8::Array::New(int length) {
4204 i::Isolate* isolate = i::Isolate::Current(); 4251 i::Isolate* isolate = i::Isolate::Current();
4205 EnsureInitializedForIsolate(isolate, "v8::Array::New()"); 4252 EnsureInitializedForIsolate(isolate, "v8::Array::New()");
4206 LOG_API(isolate, "Array::New"); 4253 LOG_API(isolate, "Array::New");
4207 ENTER_V8; 4254 ENTER_V8(isolate);
4208 int real_length = length > 0 ? length : 0; 4255 int real_length = length > 0 ? length : 0;
4209 i::Handle<i::JSArray> obj = isolate->factory()->NewJSArray(real_length); 4256 i::Handle<i::JSArray> obj = isolate->factory()->NewJSArray(real_length);
4210 obj->set_length(*isolate->factory()->NewNumberFromInt(real_length)); 4257 obj->set_length(*isolate->factory()->NewNumberFromInt(real_length));
4211 return Utils::ToLocal(obj); 4258 return Utils::ToLocal(obj);
4212 } 4259 }
4213 4260
4214 4261
4215 uint32_t v8::Array::Length() const { 4262 uint32_t v8::Array::Length() const {
4216 i::Isolate* isolate = i::Isolate::Current(); 4263 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4217 if (IsDeadCheck(isolate, "v8::Array::Length()")) return 0; 4264 if (IsDeadCheck(isolate, "v8::Array::Length()")) return 0;
4218 i::Handle<i::JSArray> obj = Utils::OpenHandle(this); 4265 i::Handle<i::JSArray> obj = Utils::OpenHandle(this);
4219 i::Object* length = obj->length(); 4266 i::Object* length = obj->length();
4220 if (length->IsSmi()) { 4267 if (length->IsSmi()) {
4221 return i::Smi::cast(length)->value(); 4268 return i::Smi::cast(length)->value();
4222 } else { 4269 } else {
4223 return static_cast<uint32_t>(length->Number()); 4270 return static_cast<uint32_t>(length->Number());
4224 } 4271 }
4225 } 4272 }
4226 4273
4227 4274
4228 Local<Object> Array::CloneElementAt(uint32_t index) { 4275 Local<Object> Array::CloneElementAt(uint32_t index) {
4229 i::Isolate* isolate = i::Isolate::Current(); 4276 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4230 ON_BAILOUT(isolate, "v8::Array::CloneElementAt()", return Local<Object>()); 4277 ON_BAILOUT(isolate, "v8::Array::CloneElementAt()", return Local<Object>());
4231 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 4278 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
4232 if (!self->HasFastElements()) { 4279 if (!self->HasFastElements()) {
4233 return Local<Object>(); 4280 return Local<Object>();
4234 } 4281 }
4235 i::FixedArray* elms = i::FixedArray::cast(self->elements()); 4282 i::FixedArray* elms = i::FixedArray::cast(self->elements());
4236 i::Object* paragon = elms->get(index); 4283 i::Object* paragon = elms->get(index);
4237 if (!paragon->IsJSObject()) { 4284 if (!paragon->IsJSObject()) {
4238 return Local<Object>(); 4285 return Local<Object>();
4239 } 4286 }
4240 i::Handle<i::JSObject> paragon_handle(i::JSObject::cast(paragon)); 4287 i::Handle<i::JSObject> paragon_handle(i::JSObject::cast(paragon));
4241 EXCEPTION_PREAMBLE(); 4288 EXCEPTION_PREAMBLE(isolate);
4242 ENTER_V8; 4289 ENTER_V8(isolate);
4243 i::Handle<i::JSObject> result = i::Copy(paragon_handle); 4290 i::Handle<i::JSObject> result = i::Copy(paragon_handle);
4244 has_pending_exception = result.is_null(); 4291 has_pending_exception = result.is_null();
4245 EXCEPTION_BAILOUT_CHECK(Local<Object>()); 4292 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>());
4246 return Utils::ToLocal(result); 4293 return Utils::ToLocal(result);
4247 } 4294 }
4248 4295
4249 4296
4250 Local<String> v8::String::NewSymbol(const char* data, int length) { 4297 Local<String> v8::String::NewSymbol(const char* data, int length) {
4251 i::Isolate* isolate = i::Isolate::Current(); 4298 i::Isolate* isolate = i::Isolate::Current();
4252 EnsureInitializedForIsolate(isolate, "v8::String::NewSymbol()"); 4299 EnsureInitializedForIsolate(isolate, "v8::String::NewSymbol()");
4253 LOG_API(isolate, "String::NewSymbol(char)"); 4300 LOG_API(isolate, "String::NewSymbol(char)");
4254 ENTER_V8; 4301 ENTER_V8(isolate);
4255 if (length == -1) length = i::StrLength(data); 4302 if (length == -1) length = i::StrLength(data);
4256 i::Handle<i::String> result = 4303 i::Handle<i::String> result =
4257 isolate->factory()->LookupSymbol(i::Vector<const char>(data, length)); 4304 isolate->factory()->LookupSymbol(i::Vector<const char>(data, length));
4258 return Utils::ToLocal(result); 4305 return Utils::ToLocal(result);
4259 } 4306 }
4260 4307
4261 4308
4262 Local<Number> v8::Number::New(double value) { 4309 Local<Number> v8::Number::New(double value) {
4263 i::Isolate* isolate = i::Isolate::Current(); 4310 i::Isolate* isolate = i::Isolate::Current();
4264 EnsureInitializedForIsolate(isolate, "v8::Number::New()"); 4311 EnsureInitializedForIsolate(isolate, "v8::Number::New()");
4265 if (isnan(value)) { 4312 if (isnan(value)) {
4266 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. 4313 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs.
4267 value = i::OS::nan_value(); 4314 value = i::OS::nan_value();
4268 } 4315 }
4269 ENTER_V8; 4316 ENTER_V8(isolate);
4270 i::Handle<i::Object> result = isolate->factory()->NewNumber(value); 4317 i::Handle<i::Object> result = isolate->factory()->NewNumber(value);
4271 return Utils::NumberToLocal(result); 4318 return Utils::NumberToLocal(result);
4272 } 4319 }
4273 4320
4274 4321
4275 Local<Integer> v8::Integer::New(int32_t value) { 4322 Local<Integer> v8::Integer::New(int32_t value) {
4276 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); 4323 i::Isolate* isolate = i::Isolate::UncheckedCurrent();
4277 EnsureInitializedForIsolate(isolate, "v8::Integer::New()"); 4324 EnsureInitializedForIsolate(isolate, "v8::Integer::New()");
4278 if (i::Smi::IsValid(value)) { 4325 if (i::Smi::IsValid(value)) {
4279 return Utils::IntegerToLocal(i::Handle<i::Object>(i::Smi::FromInt(value), 4326 return Utils::IntegerToLocal(i::Handle<i::Object>(i::Smi::FromInt(value),
4280 isolate)); 4327 isolate));
4281 } 4328 }
4282 ENTER_V8; 4329 ENTER_V8(isolate);
4283 i::Handle<i::Object> result = isolate->factory()->NewNumber(value); 4330 i::Handle<i::Object> result = isolate->factory()->NewNumber(value);
4284 return Utils::IntegerToLocal(result); 4331 return Utils::IntegerToLocal(result);
4285 } 4332 }
4286 4333
4287 4334
4288 Local<Integer> Integer::NewFromUnsigned(uint32_t value) { 4335 Local<Integer> Integer::NewFromUnsigned(uint32_t value) {
4289 bool fits_into_int32_t = (value & (1 << 31)) == 0; 4336 bool fits_into_int32_t = (value & (1 << 31)) == 0;
4290 if (fits_into_int32_t) { 4337 if (fits_into_int32_t) {
4291 return Integer::New(static_cast<int32_t>(value)); 4338 return Integer::New(static_cast<int32_t>(value));
4292 } 4339 }
4293 ENTER_V8; 4340 i::Isolate* isolate = i::Isolate::Current();
4294 i::Handle<i::Object> result = FACTORY->NewNumber(value); 4341 ENTER_V8(isolate);
4342 i::Handle<i::Object> result = isolate->factory()->NewNumber(value);
4295 return Utils::IntegerToLocal(result); 4343 return Utils::IntegerToLocal(result);
4296 } 4344 }
4297 4345
4298 4346
4299 void V8::IgnoreOutOfMemoryException() { 4347 void V8::IgnoreOutOfMemoryException() {
4300 EnterIsolateIfNeeded()->handle_scope_implementer()->set_ignore_out_of_memory( 4348 EnterIsolateIfNeeded()->handle_scope_implementer()->set_ignore_out_of_memory(
4301 true); 4349 true);
4302 } 4350 }
4303 4351
4304 4352
4305 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) { 4353 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) {
4306 i::Isolate* isolate = i::Isolate::Current(); 4354 i::Isolate* isolate = i::Isolate::Current();
4307 EnsureInitializedForIsolate(isolate, "v8::V8::AddMessageListener()"); 4355 EnsureInitializedForIsolate(isolate, "v8::V8::AddMessageListener()");
4308 ON_BAILOUT(isolate, "v8::V8::AddMessageListener()", return false); 4356 ON_BAILOUT(isolate, "v8::V8::AddMessageListener()", return false);
4309 ENTER_V8; 4357 ENTER_V8(isolate);
4310 i::HandleScope scope(isolate); 4358 i::HandleScope scope(isolate);
4311 NeanderArray listeners(isolate->factory()->message_listeners()); 4359 NeanderArray listeners(isolate->factory()->message_listeners());
4312 NeanderObject obj(2); 4360 NeanderObject obj(2);
4313 obj.set(0, *isolate->factory()->NewProxy(FUNCTION_ADDR(that))); 4361 obj.set(0, *isolate->factory()->NewProxy(FUNCTION_ADDR(that)));
4314 obj.set(1, data.IsEmpty() ? 4362 obj.set(1, data.IsEmpty() ?
4315 HEAP->undefined_value() : 4363 HEAP->undefined_value() :
4316 *Utils::OpenHandle(*data)); 4364 *Utils::OpenHandle(*data));
4317 listeners.add(obj.value()); 4365 listeners.add(obj.value());
4318 return true; 4366 return true;
4319 } 4367 }
4320 4368
4321 4369
4322 void V8::RemoveMessageListeners(MessageCallback that) { 4370 void V8::RemoveMessageListeners(MessageCallback that) {
4323 i::Isolate* isolate = i::Isolate::Current(); 4371 i::Isolate* isolate = i::Isolate::Current();
4324 EnsureInitializedForIsolate(isolate, "v8::V8::RemoveMessageListener()"); 4372 EnsureInitializedForIsolate(isolate, "v8::V8::RemoveMessageListener()");
4325 ON_BAILOUT(isolate, "v8::V8::RemoveMessageListeners()", return); 4373 ON_BAILOUT(isolate, "v8::V8::RemoveMessageListeners()", return);
4326 ENTER_V8; 4374 ENTER_V8(isolate);
4327 i::HandleScope scope(isolate); 4375 i::HandleScope scope(isolate);
4328 NeanderArray listeners(isolate->factory()->message_listeners()); 4376 NeanderArray listeners(isolate->factory()->message_listeners());
4329 for (int i = 0; i < listeners.length(); i++) { 4377 for (int i = 0; i < listeners.length(); i++) {
4330 if (listeners.get(i)->IsUndefined()) continue; // skip deleted ones 4378 if (listeners.get(i)->IsUndefined()) continue; // skip deleted ones
4331 4379
4332 NeanderObject listener(i::JSObject::cast(listeners.get(i))); 4380 NeanderObject listener(i::JSObject::cast(listeners.get(i)));
4333 i::Handle<i::Proxy> callback_obj(i::Proxy::cast(listener.get(0))); 4381 i::Handle<i::Proxy> callback_obj(i::Proxy::cast(listener.get(0)));
4334 if (callback_obj->proxy() == FUNCTION_ADDR(that)) { 4382 if (callback_obj->proxy() == FUNCTION_ADDR(that)) {
4335 listeners.set(i, HEAP->undefined_value()); 4383 listeners.set(i, HEAP->undefined_value());
4336 } 4384 }
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
4541 int V8::GetLogLines(int from_pos, char* dest_buf, int max_size) { 4589 int V8::GetLogLines(int from_pos, char* dest_buf, int max_size) {
4542 #ifdef ENABLE_LOGGING_AND_PROFILING 4590 #ifdef ENABLE_LOGGING_AND_PROFILING
4543 ASSERT(max_size >= kMinimumSizeForLogLinesBuffer); 4591 ASSERT(max_size >= kMinimumSizeForLogLinesBuffer);
4544 return LOGGER->GetLogLines(from_pos, dest_buf, max_size); 4592 return LOGGER->GetLogLines(from_pos, dest_buf, max_size);
4545 #endif 4593 #endif
4546 return 0; 4594 return 0;
4547 } 4595 }
4548 4596
4549 4597
4550 int V8::GetCurrentThreadId() { 4598 int V8::GetCurrentThreadId() {
4551 API_ENTRY_CHECK("V8::GetCurrentThreadId()"); 4599 i::Isolate* isolate = i::Isolate::Current();
4552 EnsureInitialized("V8::GetCurrentThreadId()"); 4600 EnsureInitializedForIsolate(isolate, "V8::GetCurrentThreadId()");
4553 return i::Isolate::Current()->thread_id(); 4601 return isolate->thread_id();
4554 } 4602 }
4555 4603
4556 4604
4557 void V8::TerminateExecution(int thread_id) { 4605 void V8::TerminateExecution(int thread_id) {
4558 i::Isolate* isolate = i::Isolate::Current(); 4606 i::Isolate* isolate = i::Isolate::Current();
4559 if (!isolate->IsInitialized()) return; 4607 if (!isolate->IsInitialized()) return;
4560 API_ENTRY_CHECK("V8::GetCurrentThreadId()"); 4608 API_ENTRY_CHECK("V8::TerminateExecution()");
4561 // If the thread_id identifies the current thread just terminate 4609 // If the thread_id identifies the current thread just terminate
4562 // execution right away. Otherwise, ask the thread manager to 4610 // execution right away. Otherwise, ask the thread manager to
4563 // terminate the thread with the given id if any. 4611 // terminate the thread with the given id if any.
4564 if (thread_id == isolate->thread_id()) { 4612 if (thread_id == isolate->thread_id()) {
4565 isolate->stack_guard()->TerminateExecution(); 4613 isolate->stack_guard()->TerminateExecution();
4566 } else { 4614 } else {
4567 isolate->thread_manager()->TerminateExecution(thread_id); 4615 isolate->thread_manager()->TerminateExecution(thread_id);
4568 } 4616 }
4569 } 4617 }
4570 4618
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
4619 } 4667 }
4620 4668
4621 4669
4622 void Isolate::Exit() { 4670 void Isolate::Exit() {
4623 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); 4671 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
4624 isolate->Exit(); 4672 isolate->Exit();
4625 } 4673 }
4626 4674
4627 4675
4628 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) { 4676 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) {
4629 EnsureInitialized("v8::String::Utf8Value::Utf8Value()"); 4677 i::Isolate* isolate = i::Isolate::Current();
4678 if (IsDeadCheck(isolate, "v8::String::Utf8Value::Utf8Value()")) return;
4630 if (obj.IsEmpty()) { 4679 if (obj.IsEmpty()) {
4631 str_ = NULL; 4680 str_ = NULL;
4632 length_ = 0; 4681 length_ = 0;
4633 return; 4682 return;
4634 } 4683 }
4635 ENTER_V8; 4684 ENTER_V8(isolate);
4636 HandleScope scope; 4685 i::HandleScope scope(isolate);
4637 TryCatch try_catch; 4686 TryCatch try_catch;
4638 Handle<String> str = obj->ToString(); 4687 Handle<String> str = obj->ToString();
4639 if (str.IsEmpty()) { 4688 if (str.IsEmpty()) {
4640 str_ = NULL; 4689 str_ = NULL;
4641 length_ = 0; 4690 length_ = 0;
4642 } else { 4691 } else {
4643 length_ = str->Utf8Length(); 4692 length_ = str->Utf8Length();
4644 str_ = i::NewArray<char>(length_ + 1); 4693 str_ = i::NewArray<char>(length_ + 1);
4645 str->WriteUtf8(str_); 4694 str->WriteUtf8(str_);
4646 } 4695 }
4647 } 4696 }
4648 4697
4649 4698
4650 String::Utf8Value::~Utf8Value() { 4699 String::Utf8Value::~Utf8Value() {
4651 i::DeleteArray(str_); 4700 i::DeleteArray(str_);
4652 } 4701 }
4653 4702
4654 4703
4655 String::AsciiValue::AsciiValue(v8::Handle<v8::Value> obj) { 4704 String::AsciiValue::AsciiValue(v8::Handle<v8::Value> obj) {
4656 EnsureInitialized("v8::String::AsciiValue::AsciiValue()"); 4705 i::Isolate* isolate = i::Isolate::Current();
4706 if (IsDeadCheck(isolate, "v8::String::AsciiValue::AsciiValue()")) return;
4657 if (obj.IsEmpty()) { 4707 if (obj.IsEmpty()) {
4658 str_ = NULL; 4708 str_ = NULL;
4659 length_ = 0; 4709 length_ = 0;
4660 return; 4710 return;
4661 } 4711 }
4662 ENTER_V8; 4712 ENTER_V8(isolate);
4663 HandleScope scope; 4713 i::HandleScope scope(isolate);
4664 TryCatch try_catch; 4714 TryCatch try_catch;
4665 Handle<String> str = obj->ToString(); 4715 Handle<String> str = obj->ToString();
4666 if (str.IsEmpty()) { 4716 if (str.IsEmpty()) {
4667 str_ = NULL; 4717 str_ = NULL;
4668 length_ = 0; 4718 length_ = 0;
4669 } else { 4719 } else {
4670 length_ = str->Length(); 4720 length_ = str->Length();
4671 str_ = i::NewArray<char>(length_ + 1); 4721 str_ = i::NewArray<char>(length_ + 1);
4672 str->WriteAscii(str_); 4722 str->WriteAscii(str_);
4673 } 4723 }
4674 } 4724 }
4675 4725
4676 4726
4677 String::AsciiValue::~AsciiValue() { 4727 String::AsciiValue::~AsciiValue() {
4678 i::DeleteArray(str_); 4728 i::DeleteArray(str_);
4679 } 4729 }
4680 4730
4681 4731
4682 String::Value::Value(v8::Handle<v8::Value> obj) { 4732 String::Value::Value(v8::Handle<v8::Value> obj) {
4683 EnsureInitialized("v8::String::Value::Value()"); 4733 i::Isolate* isolate = i::Isolate::Current();
4734 if (IsDeadCheck(isolate, "v8::String::Value::Value()")) return;
4684 if (obj.IsEmpty()) { 4735 if (obj.IsEmpty()) {
4685 str_ = NULL; 4736 str_ = NULL;
4686 length_ = 0; 4737 length_ = 0;
4687 return; 4738 return;
4688 } 4739 }
4689 ENTER_V8; 4740 ENTER_V8(isolate);
4690 HandleScope scope; 4741 i::HandleScope scope(isolate);
4691 TryCatch try_catch; 4742 TryCatch try_catch;
4692 Handle<String> str = obj->ToString(); 4743 Handle<String> str = obj->ToString();
4693 if (str.IsEmpty()) { 4744 if (str.IsEmpty()) {
4694 str_ = NULL; 4745 str_ = NULL;
4695 length_ = 0; 4746 length_ = 0;
4696 } else { 4747 } else {
4697 length_ = str->Length(); 4748 length_ = str->Length();
4698 str_ = i::NewArray<uint16_t>(length_ + 1); 4749 str_ = i::NewArray<uint16_t>(length_ + 1);
4699 str->Write(str_); 4750 str->Write(str_);
4700 } 4751 }
4701 } 4752 }
4702 4753
4703 4754
4704 String::Value::~Value() { 4755 String::Value::~Value() {
4705 i::DeleteArray(str_); 4756 i::DeleteArray(str_);
4706 } 4757 }
4707 4758
4708 Local<Value> Exception::RangeError(v8::Handle<v8::String> raw_message) { 4759 Local<Value> Exception::RangeError(v8::Handle<v8::String> raw_message) {
4709 i::Isolate* isolate = i::Isolate::Current(); 4760 i::Isolate* isolate = i::Isolate::Current();
4710 LOG_API(isolate, "RangeError"); 4761 LOG_API(isolate, "RangeError");
4711 ON_BAILOUT(isolate, "v8::Exception::RangeError()", return Local<Value>()); 4762 ON_BAILOUT(isolate, "v8::Exception::RangeError()", return Local<Value>());
4712 ENTER_V8; 4763 ENTER_V8(isolate);
4713 i::Object* error; 4764 i::Object* error;
4714 { 4765 {
4715 i::HandleScope scope(isolate); 4766 i::HandleScope scope(isolate);
4716 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); 4767 i::Handle<i::String> message = Utils::OpenHandle(*raw_message);
4717 i::Handle<i::Object> result = isolate->factory()->NewRangeError(message); 4768 i::Handle<i::Object> result = isolate->factory()->NewRangeError(message);
4718 error = *result; 4769 error = *result;
4719 } 4770 }
4720 i::Handle<i::Object> result(error); 4771 i::Handle<i::Object> result(error);
4721 return Utils::ToLocal(result); 4772 return Utils::ToLocal(result);
4722 } 4773 }
4723 4774
4724 Local<Value> Exception::ReferenceError(v8::Handle<v8::String> raw_message) { 4775 Local<Value> Exception::ReferenceError(v8::Handle<v8::String> raw_message) {
4725 i::Isolate* isolate = i::Isolate::Current(); 4776 i::Isolate* isolate = i::Isolate::Current();
4726 LOG_API(isolate, "ReferenceError"); 4777 LOG_API(isolate, "ReferenceError");
4727 ON_BAILOUT(isolate, "v8::Exception::ReferenceError()", return Local<Value>()); 4778 ON_BAILOUT(isolate, "v8::Exception::ReferenceError()", return Local<Value>());
4728 ENTER_V8; 4779 ENTER_V8(isolate);
4729 i::Object* error; 4780 i::Object* error;
4730 { 4781 {
4731 i::HandleScope scope(isolate); 4782 i::HandleScope scope(isolate);
4732 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); 4783 i::Handle<i::String> message = Utils::OpenHandle(*raw_message);
4733 i::Handle<i::Object> result = 4784 i::Handle<i::Object> result =
4734 isolate->factory()->NewReferenceError(message); 4785 isolate->factory()->NewReferenceError(message);
4735 error = *result; 4786 error = *result;
4736 } 4787 }
4737 i::Handle<i::Object> result(error); 4788 i::Handle<i::Object> result(error);
4738 return Utils::ToLocal(result); 4789 return Utils::ToLocal(result);
4739 } 4790 }
4740 4791
4741 Local<Value> Exception::SyntaxError(v8::Handle<v8::String> raw_message) { 4792 Local<Value> Exception::SyntaxError(v8::Handle<v8::String> raw_message) {
4742 i::Isolate* isolate = i::Isolate::Current(); 4793 i::Isolate* isolate = i::Isolate::Current();
4743 LOG_API(isolate, "SyntaxError"); 4794 LOG_API(isolate, "SyntaxError");
4744 ON_BAILOUT(isolate, "v8::Exception::SyntaxError()", return Local<Value>()); 4795 ON_BAILOUT(isolate, "v8::Exception::SyntaxError()", return Local<Value>());
4745 ENTER_V8; 4796 ENTER_V8(isolate);
4746 i::Object* error; 4797 i::Object* error;
4747 { 4798 {
4748 i::HandleScope scope(isolate); 4799 i::HandleScope scope(isolate);
4749 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); 4800 i::Handle<i::String> message = Utils::OpenHandle(*raw_message);
4750 i::Handle<i::Object> result = isolate->factory()->NewSyntaxError(message); 4801 i::Handle<i::Object> result = isolate->factory()->NewSyntaxError(message);
4751 error = *result; 4802 error = *result;
4752 } 4803 }
4753 i::Handle<i::Object> result(error); 4804 i::Handle<i::Object> result(error);
4754 return Utils::ToLocal(result); 4805 return Utils::ToLocal(result);
4755 } 4806 }
4756 4807
4757 Local<Value> Exception::TypeError(v8::Handle<v8::String> raw_message) { 4808 Local<Value> Exception::TypeError(v8::Handle<v8::String> raw_message) {
4758 i::Isolate* isolate = i::Isolate::Current(); 4809 i::Isolate* isolate = i::Isolate::Current();
4759 LOG_API(isolate, "TypeError"); 4810 LOG_API(isolate, "TypeError");
4760 ON_BAILOUT(isolate, "v8::Exception::TypeError()", return Local<Value>()); 4811 ON_BAILOUT(isolate, "v8::Exception::TypeError()", return Local<Value>());
4761 ENTER_V8; 4812 ENTER_V8(isolate);
4762 i::Object* error; 4813 i::Object* error;
4763 { 4814 {
4764 i::HandleScope scope(isolate); 4815 i::HandleScope scope(isolate);
4765 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); 4816 i::Handle<i::String> message = Utils::OpenHandle(*raw_message);
4766 i::Handle<i::Object> result = isolate->factory()->NewTypeError(message); 4817 i::Handle<i::Object> result = isolate->factory()->NewTypeError(message);
4767 error = *result; 4818 error = *result;
4768 } 4819 }
4769 i::Handle<i::Object> result(error); 4820 i::Handle<i::Object> result(error);
4770 return Utils::ToLocal(result); 4821 return Utils::ToLocal(result);
4771 } 4822 }
4772 4823
4773 Local<Value> Exception::Error(v8::Handle<v8::String> raw_message) { 4824 Local<Value> Exception::Error(v8::Handle<v8::String> raw_message) {
4774 i::Isolate* isolate = i::Isolate::Current(); 4825 i::Isolate* isolate = i::Isolate::Current();
4775 LOG_API(isolate, "Error"); 4826 LOG_API(isolate, "Error");
4776 ON_BAILOUT(isolate, "v8::Exception::Error()", return Local<Value>()); 4827 ON_BAILOUT(isolate, "v8::Exception::Error()", return Local<Value>());
4777 ENTER_V8; 4828 ENTER_V8(isolate);
4778 i::Object* error; 4829 i::Object* error;
4779 { 4830 {
4780 i::HandleScope scope(isolate); 4831 i::HandleScope scope(isolate);
4781 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); 4832 i::Handle<i::String> message = Utils::OpenHandle(*raw_message);
4782 i::Handle<i::Object> result = isolate->factory()->NewError(message); 4833 i::Handle<i::Object> result = isolate->factory()->NewError(message);
4783 error = *result; 4834 error = *result;
4784 } 4835 }
4785 i::Handle<i::Object> result(error); 4836 i::Handle<i::Object> result(error);
4786 return Utils::ToLocal(result); 4837 return Utils::ToLocal(result);
4787 } 4838 }
(...skipping 11 matching lines...) Expand all
4799 event_details.GetEventData(), 4850 event_details.GetEventData(),
4800 event_details.GetCallbackData()); 4851 event_details.GetCallbackData());
4801 } 4852 }
4802 } 4853 }
4803 4854
4804 4855
4805 bool Debug::SetDebugEventListener(EventCallback that, Handle<Value> data) { 4856 bool Debug::SetDebugEventListener(EventCallback that, Handle<Value> data) {
4806 i::Isolate* isolate = i::Isolate::Current(); 4857 i::Isolate* isolate = i::Isolate::Current();
4807 EnsureInitializedForIsolate(isolate, "v8::Debug::SetDebugEventListener()"); 4858 EnsureInitializedForIsolate(isolate, "v8::Debug::SetDebugEventListener()");
4808 ON_BAILOUT(isolate, "v8::Debug::SetDebugEventListener()", return false); 4859 ON_BAILOUT(isolate, "v8::Debug::SetDebugEventListener()", return false);
4809 ENTER_V8; 4860 ENTER_V8(isolate);
4810 4861
4811 isolate->set_debug_event_callback(that); 4862 isolate->set_debug_event_callback(that);
4812 4863
4813 i::HandleScope scope(isolate); 4864 i::HandleScope scope(isolate);
4814 i::Handle<i::Object> proxy = isolate->factory()->undefined_value(); 4865 i::Handle<i::Object> proxy = isolate->factory()->undefined_value();
4815 if (that != NULL) { 4866 if (that != NULL) {
4816 proxy = isolate->factory()->NewProxy(FUNCTION_ADDR(EventCallbackWrapper)); 4867 proxy = isolate->factory()->NewProxy(FUNCTION_ADDR(EventCallbackWrapper));
4817 } 4868 }
4818 isolate->debugger()->SetEventListener(proxy, Utils::OpenHandle(*data)); 4869 isolate->debugger()->SetEventListener(proxy, Utils::OpenHandle(*data));
4819 return true; 4870 return true;
4820 } 4871 }
4821 4872
4822 4873
4823 bool Debug::SetDebugEventListener2(EventCallback2 that, Handle<Value> data) { 4874 bool Debug::SetDebugEventListener2(EventCallback2 that, Handle<Value> data) {
4824 i::Isolate* isolate = i::Isolate::Current(); 4875 i::Isolate* isolate = i::Isolate::Current();
4825 EnsureInitializedForIsolate(isolate, "v8::Debug::SetDebugEventListener2()"); 4876 EnsureInitializedForIsolate(isolate, "v8::Debug::SetDebugEventListener2()");
4826 ON_BAILOUT(isolate, "v8::Debug::SetDebugEventListener2()", return false); 4877 ON_BAILOUT(isolate, "v8::Debug::SetDebugEventListener2()", return false);
4827 ENTER_V8; 4878 ENTER_V8(isolate);
4828 i::HandleScope scope(isolate); 4879 i::HandleScope scope(isolate);
4829 i::Handle<i::Object> proxy = isolate->factory()->undefined_value(); 4880 i::Handle<i::Object> proxy = isolate->factory()->undefined_value();
4830 if (that != NULL) { 4881 if (that != NULL) {
4831 proxy = isolate->factory()->NewProxy(FUNCTION_ADDR(that)); 4882 proxy = isolate->factory()->NewProxy(FUNCTION_ADDR(that));
4832 } 4883 }
4833 isolate->debugger()->SetEventListener(proxy, 4884 isolate->debugger()->SetEventListener(proxy,
4834 Utils::OpenHandle(*data)); 4885 Utils::OpenHandle(*data));
4835 return true; 4886 return true;
4836 } 4887 }
4837 4888
4838 4889
4839 bool Debug::SetDebugEventListener(v8::Handle<v8::Object> that, 4890 bool Debug::SetDebugEventListener(v8::Handle<v8::Object> that,
4840 Handle<Value> data) { 4891 Handle<Value> data) {
4841 i::Isolate* isolate = i::Isolate::Current(); 4892 i::Isolate* isolate = i::Isolate::Current();
4842 ON_BAILOUT(isolate, "v8::Debug::SetDebugEventListener()", return false); 4893 ON_BAILOUT(isolate, "v8::Debug::SetDebugEventListener()", return false);
4843 ENTER_V8; 4894 ENTER_V8(isolate);
4844 isolate->debugger()->SetEventListener(Utils::OpenHandle(*that), 4895 isolate->debugger()->SetEventListener(Utils::OpenHandle(*that),
4845 Utils::OpenHandle(*data)); 4896 Utils::OpenHandle(*data));
4846 return true; 4897 return true;
4847 } 4898 }
4848 4899
4849 4900
4850 void Debug::DebugBreak(Isolate* isolate) { 4901 void Debug::DebugBreak(Isolate* isolate) {
4851 // If no isolate is supplied, use the default isolate. 4902 // If no isolate is supplied, use the default isolate.
4852 if (isolate != NULL) { 4903 if (isolate != NULL) {
4853 reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->DebugBreak(); 4904 reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->DebugBreak();
(...skipping 29 matching lines...) Expand all
4883 i::Isolate* isolate = i::Isolate::Current(); 4934 i::Isolate* isolate = i::Isolate::Current();
4884 if (isolate->message_handler()) { 4935 if (isolate->message_handler()) {
4885 v8::String::Value json(message.GetJSON()); 4936 v8::String::Value json(message.GetJSON());
4886 (isolate->message_handler())(*json, json.length(), message.GetClientData()); 4937 (isolate->message_handler())(*json, json.length(), message.GetClientData());
4887 } 4938 }
4888 } 4939 }
4889 4940
4890 4941
4891 void Debug::SetMessageHandler(v8::Debug::MessageHandler handler, 4942 void Debug::SetMessageHandler(v8::Debug::MessageHandler handler,
4892 bool message_handler_thread) { 4943 bool message_handler_thread) {
4893 EnsureInitialized("v8::Debug::SetMessageHandler");
4894 ENTER_V8;
4895 i::Isolate* isolate = i::Isolate::Current(); 4944 i::Isolate* isolate = i::Isolate::Current();
4945 EnsureInitializedForIsolate(isolate, "v8::Debug::SetMessageHandler");
4946 ENTER_V8(isolate);
4947
4896 // Message handler thread not supported any more. Parameter temporally left in 4948 // Message handler thread not supported any more. Parameter temporally left in
4897 // the API for client compatability reasons. 4949 // the API for client compatibility reasons.
4898 CHECK(!message_handler_thread); 4950 CHECK(!message_handler_thread);
4899 4951
4900 // TODO(sgjesse) support the old message handler API through a simple wrapper. 4952 // TODO(sgjesse) support the old message handler API through a simple wrapper.
4901 isolate->set_message_handler(handler); 4953 isolate->set_message_handler(handler);
4902 if (handler != NULL) { 4954 if (handler != NULL) {
4903 isolate->debugger()->SetMessageHandler(MessageHandlerWrapper); 4955 isolate->debugger()->SetMessageHandler(MessageHandlerWrapper);
4904 } else { 4956 } else {
4905 isolate->debugger()->SetMessageHandler(NULL); 4957 isolate->debugger()->SetMessageHandler(NULL);
4906 } 4958 }
4907 } 4959 }
4908 4960
4909 4961
4910 void Debug::SetMessageHandler2(v8::Debug::MessageHandler2 handler) { 4962 void Debug::SetMessageHandler2(v8::Debug::MessageHandler2 handler) {
4911 EnsureInitialized("v8::Debug::SetMessageHandler"); 4963 i::Isolate* isolate = i::Isolate::Current();
4912 ENTER_V8; 4964 EnsureInitializedForIsolate(isolate, "v8::Debug::SetMessageHandler");
4913 i::Isolate::Current()->debugger()->SetMessageHandler(handler); 4965 ENTER_V8(isolate);
4966 isolate->debugger()->SetMessageHandler(handler);
4914 } 4967 }
4915 4968
4916 4969
4917 void Debug::SendCommand(const uint16_t* command, int length, 4970 void Debug::SendCommand(const uint16_t* command, int length,
4918 ClientData* client_data, 4971 ClientData* client_data,
4919 Isolate* isolate) { 4972 Isolate* isolate) {
4920 // If no isolate is supplied, use the default isolate. 4973 // If no isolate is supplied, use the default isolate.
4921 if (isolate != NULL) { 4974 if (isolate != NULL) {
4922 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); 4975 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
4923 internal_isolate->debugger()->ProcessCommand( 4976 internal_isolate->debugger()->ProcessCommand(
4924 i::Vector<const uint16_t>(command, length), client_data); 4977 i::Vector<const uint16_t>(command, length), client_data);
4925 } else { 4978 } else {
4926 i::Isolate::GetDefaultIsolateDebugger()->ProcessCommand( 4979 i::Isolate::GetDefaultIsolateDebugger()->ProcessCommand(
4927 i::Vector<const uint16_t>(command, length), client_data); 4980 i::Vector<const uint16_t>(command, length), client_data);
4928 } 4981 }
4929 } 4982 }
4930 4983
4931 4984
4932 void Debug::SetHostDispatchHandler(HostDispatchHandler handler, 4985 void Debug::SetHostDispatchHandler(HostDispatchHandler handler,
4933 int period) { 4986 int period) {
4934 EnsureInitialized("v8::Debug::SetHostDispatchHandler"); 4987 i::Isolate* isolate = i::Isolate::Current();
4935 ENTER_V8; 4988 EnsureInitializedForIsolate(isolate, "v8::Debug::SetHostDispatchHandler");
4936 i::Isolate::Current()->debugger()->SetHostDispatchHandler(handler, period); 4989 ENTER_V8(isolate);
4990 isolate->debugger()->SetHostDispatchHandler(handler, period);
4937 } 4991 }
4938 4992
4939 4993
4940 void Debug::SetDebugMessageDispatchHandler( 4994 void Debug::SetDebugMessageDispatchHandler(
4941 DebugMessageDispatchHandler handler, bool provide_locker) { 4995 DebugMessageDispatchHandler handler, bool provide_locker) {
4942 EnsureInitialized("v8::Debug::SetDebugMessageDispatchHandler"); 4996 i::Isolate* isolate = i::Isolate::Current();
4943 ENTER_V8; 4997 EnsureInitializedForIsolate(isolate,
4944 i::Isolate::Current()->debugger()->SetDebugMessageDispatchHandler( 4998 "v8::Debug::SetDebugMessageDispatchHandler");
4999 ENTER_V8(isolate);
5000 isolate->debugger()->SetDebugMessageDispatchHandler(
4945 handler, provide_locker); 5001 handler, provide_locker);
4946 } 5002 }
4947 5003
4948 5004
4949 Local<Value> Debug::Call(v8::Handle<v8::Function> fun, 5005 Local<Value> Debug::Call(v8::Handle<v8::Function> fun,
4950 v8::Handle<v8::Value> data) { 5006 v8::Handle<v8::Value> data) {
4951 i::Isolate* isolate = i::Isolate::Current(); 5007 i::Isolate* isolate = i::Isolate::Current();
4952 if (!isolate->IsInitialized()) return Local<Value>(); 5008 if (!isolate->IsInitialized()) return Local<Value>();
4953 ON_BAILOUT(isolate, "v8::Debug::Call()", return Local<Value>()); 5009 ON_BAILOUT(isolate, "v8::Debug::Call()", return Local<Value>());
4954 ENTER_V8; 5010 ENTER_V8(isolate);
4955 i::Handle<i::Object> result; 5011 i::Handle<i::Object> result;
4956 EXCEPTION_PREAMBLE(); 5012 EXCEPTION_PREAMBLE(isolate);
4957 if (data.IsEmpty()) { 5013 if (data.IsEmpty()) {
4958 result = isolate->debugger()->Call( 5014 result = isolate->debugger()->Call(Utils::OpenHandle(*fun),
4959 Utils::OpenHandle(*fun), 5015 isolate->factory()->undefined_value(),
4960 isolate->factory()->undefined_value(), 5016 &has_pending_exception);
4961 &has_pending_exception);
4962 } else { 5017 } else {
4963 result = isolate->debugger()->Call(Utils::OpenHandle(*fun), 5018 result = isolate->debugger()->Call(Utils::OpenHandle(*fun),
4964 Utils::OpenHandle(*data), 5019 Utils::OpenHandle(*data),
4965 &has_pending_exception); 5020 &has_pending_exception);
4966 } 5021 }
4967 EXCEPTION_BAILOUT_CHECK(Local<Value>()); 5022 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
4968 return Utils::ToLocal(result); 5023 return Utils::ToLocal(result);
4969 } 5024 }
4970 5025
4971 5026
4972 Local<Value> Debug::GetMirror(v8::Handle<v8::Value> obj) { 5027 Local<Value> Debug::GetMirror(v8::Handle<v8::Value> obj) {
4973 i::Isolate* isolate = i::Isolate::Current(); 5028 i::Isolate* isolate = i::Isolate::Current();
4974 if (!isolate->IsInitialized()) return Local<Value>(); 5029 if (!isolate->IsInitialized()) return Local<Value>();
4975 ON_BAILOUT(isolate, "v8::Debug::GetMirror()", return Local<Value>()); 5030 ON_BAILOUT(isolate, "v8::Debug::GetMirror()", return Local<Value>());
4976 ENTER_V8; 5031 ENTER_V8(isolate);
4977 v8::HandleScope scope; 5032 v8::HandleScope scope;
4978 i::Debug* isolate_debug = isolate->debug(); 5033 i::Debug* isolate_debug = isolate->debug();
4979 isolate_debug->Load(); 5034 isolate_debug->Load();
4980 i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global()); 5035 i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global());
4981 i::Handle<i::String> name = 5036 i::Handle<i::String> name =
4982 isolate->factory()->LookupAsciiSymbol("MakeMirror"); 5037 isolate->factory()->LookupAsciiSymbol("MakeMirror");
4983 i::Handle<i::Object> fun_obj = i::GetProperty(debug, name); 5038 i::Handle<i::Object> fun_obj = i::GetProperty(debug, name);
4984 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(fun_obj); 5039 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(fun_obj);
4985 v8::Handle<v8::Function> v8_fun = Utils::ToLocal(fun); 5040 v8::Handle<v8::Function> v8_fun = Utils::ToLocal(fun);
4986 const int kArgc = 1; 5041 const int kArgc = 1;
4987 v8::Handle<v8::Value> argv[kArgc] = { obj }; 5042 v8::Handle<v8::Value> argv[kArgc] = { obj };
4988 EXCEPTION_PREAMBLE(); 5043 EXCEPTION_PREAMBLE(isolate);
4989 v8::Handle<v8::Value> result = v8_fun->Call(Utils::ToLocal(debug), 5044 v8::Handle<v8::Value> result = v8_fun->Call(Utils::ToLocal(debug),
4990 kArgc, 5045 kArgc,
4991 argv); 5046 argv);
4992 EXCEPTION_BAILOUT_CHECK(Local<Value>()); 5047 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
4993 return scope.Close(result); 5048 return scope.Close(result);
4994 } 5049 }
4995 5050
4996 5051
4997 bool Debug::EnableAgent(const char* name, int port, bool wait_for_connection) { 5052 bool Debug::EnableAgent(const char* name, int port, bool wait_for_connection) {
4998 return i::Isolate::Current()->debugger()->StartAgent(name, port, 5053 return i::Isolate::Current()->debugger()->StartAgent(name, port,
4999 wait_for_connection); 5054 wait_for_connection);
5000 } 5055 }
5001 5056
5002 void Debug::ProcessDebugMessages() { 5057 void Debug::ProcessDebugMessages() {
5003 i::Execution::ProcessDebugMesssages(true); 5058 i::Execution::ProcessDebugMesssages(true);
5004 } 5059 }
5005 5060
5006 Local<Context> Debug::GetDebugContext() { 5061 Local<Context> Debug::GetDebugContext() {
5007 EnsureInitialized("v8::Debug::GetDebugContext()"); 5062 i::Isolate* isolate = i::Isolate::Current();
5008 ENTER_V8; 5063 EnsureInitializedForIsolate(isolate, "v8::Debug::GetDebugContext()");
5064 ENTER_V8(isolate);
5009 return Utils::ToLocal(i::Isolate::Current()->debugger()->GetDebugContext()); 5065 return Utils::ToLocal(i::Isolate::Current()->debugger()->GetDebugContext());
5010 } 5066 }
5011 5067
5012 #endif // ENABLE_DEBUGGER_SUPPORT 5068 #endif // ENABLE_DEBUGGER_SUPPORT
5013 5069
5014 5070
5015 #ifdef ENABLE_LOGGING_AND_PROFILING 5071 #ifdef ENABLE_LOGGING_AND_PROFILING
5016 5072
5017 Handle<String> CpuProfileNode::GetFunctionName() const { 5073 Handle<String> CpuProfileNode::GetFunctionName() const {
5018 i::Isolate* isolate = i::Isolate::Current(); 5074 i::Isolate* isolate = i::Isolate::Current();
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
5666 5722
5667 5723
5668 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 5724 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
5669 HandleScopeImplementer* thread_local = 5725 HandleScopeImplementer* thread_local =
5670 reinterpret_cast<HandleScopeImplementer*>(storage); 5726 reinterpret_cast<HandleScopeImplementer*>(storage);
5671 thread_local->IterateThis(v); 5727 thread_local->IterateThis(v);
5672 return storage + ArchiveSpacePerThread(); 5728 return storage + ArchiveSpacePerThread();
5673 } 5729 }
5674 5730
5675 } } // namespace v8::internal 5731 } } // 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