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

Side by Side Diff: src/api.cc

Issue 6715016: Getting rid of more TLS fetches (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Code review feedback addressed + rebase 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 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 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 FACTORY->NewStruct(i::SIGNATURE_INFO_TYPE); 833 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 = FACTORY->NewFixedArray(argc); 838 i::Handle<i::FixedArray> args = 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 FACTORY->NewStruct(i::CALL_HANDLER_INFO_TYPE); 899 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 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 FACTORY->NewStruct(i::ACCESS_CHECK_INFO_TYPE); 1193 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 FACTORY->NewFunctionFromSharedFunctionInfo( 1400 isolate->factory()->NewFunctionFromSharedFunctionInfo(
1390 function, 1401 function,
1391 i::Isolate::Current()->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 HandleScope scope;
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));
1417 fun = FACTORY->NewFunctionFromSharedFunctionInfo( 1428 fun = FACTORY->NewFunctionFromSharedFunctionInfo(
1418 function_info, i::Isolate::Current()->global_context()); 1429 function_info, i::Isolate::Current()->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));
1421 } 1432 }
1422 EXCEPTION_PREAMBLE(); 1433 EXCEPTION_PREAMBLE(isolate);
1423 i::Handle<i::Object> receiver( 1434 i::Handle<i::Object> receiver(
1424 i::Isolate::Current()->context()->global_proxy()); 1435 i::Isolate::Current()->context()->global_proxy());
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);
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;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 1582
1572 void v8::TryCatch::SetCaptureMessage(bool value) { 1583 void v8::TryCatch::SetCaptureMessage(bool value) {
1573 capture_message_ = value; 1584 capture_message_ = value;
1574 } 1585 }
1575 1586
1576 1587
1577 // --- M e s s a g e --- 1588 // --- M e s s a g e ---
1578 1589
1579 1590
1580 Local<String> Message::Get() const { 1591 Local<String> Message::Get() const {
1581 i::Isolate* isolate = i::Isolate::Current(); 1592 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1582 ON_BAILOUT(isolate, "v8::Message::Get()", return Local<String>()); 1593 ON_BAILOUT(isolate, "v8::Message::Get()", return Local<String>());
1583 ENTER_V8; 1594 ENTER_V8(isolate);
1584 HandleScope scope; 1595 HandleScope scope;
1585 i::Handle<i::Object> obj = Utils::OpenHandle(this); 1596 i::Handle<i::Object> obj = Utils::OpenHandle(this);
1586 i::Handle<i::String> raw_result = i::MessageHandler::GetMessage(obj); 1597 i::Handle<i::String> raw_result = i::MessageHandler::GetMessage(obj);
1587 Local<String> result = Utils::ToLocal(raw_result); 1598 Local<String> result = Utils::ToLocal(raw_result);
1588 return scope.Close(result); 1599 return scope.Close(result);
1589 } 1600 }
1590 1601
1591 1602
1592 v8::Handle<Value> Message::GetScriptResourceName() const { 1603 v8::Handle<Value> Message::GetScriptResourceName() const {
1593 i::Isolate* isolate = i::Isolate::Current(); 1604 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1594 if (IsDeadCheck(isolate, "v8::Message::GetScriptResourceName()")) { 1605 if (IsDeadCheck(isolate, "v8::Message::GetScriptResourceName()")) {
1595 return Local<String>(); 1606 return Local<String>();
1596 } 1607 }
1597 ENTER_V8; 1608 ENTER_V8(isolate);
1598 HandleScope scope; 1609 HandleScope scope;
1599 i::Handle<i::JSMessageObject> message = 1610 i::Handle<i::JSMessageObject> message =
1600 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); 1611 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
1601 // Return this.script.name. 1612 // Return this.script.name.
1602 i::Handle<i::JSValue> script = 1613 i::Handle<i::JSValue> script =
1603 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script())); 1614 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script()));
1604 i::Handle<i::Object> resource_name(i::Script::cast(script->value())->name()); 1615 i::Handle<i::Object> resource_name(i::Script::cast(script->value())->name());
1605 return scope.Close(Utils::ToLocal(resource_name)); 1616 return scope.Close(Utils::ToLocal(resource_name));
1606 } 1617 }
1607 1618
1608 1619
1609 v8::Handle<Value> Message::GetScriptData() const { 1620 v8::Handle<Value> Message::GetScriptData() const {
1610 i::Isolate* isolate = i::Isolate::Current(); 1621 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1611 if (IsDeadCheck(isolate, "v8::Message::GetScriptResourceData()")) { 1622 if (IsDeadCheck(isolate, "v8::Message::GetScriptResourceData()")) {
1612 return Local<Value>(); 1623 return Local<Value>();
1613 } 1624 }
1614 ENTER_V8; 1625 ENTER_V8(isolate);
1615 HandleScope scope; 1626 HandleScope scope;
1616 i::Handle<i::JSMessageObject> message = 1627 i::Handle<i::JSMessageObject> message =
1617 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); 1628 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
1618 // Return this.script.data. 1629 // Return this.script.data.
1619 i::Handle<i::JSValue> script = 1630 i::Handle<i::JSValue> script =
1620 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script())); 1631 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script()));
1621 i::Handle<i::Object> data(i::Script::cast(script->value())->data()); 1632 i::Handle<i::Object> data(i::Script::cast(script->value())->data());
1622 return scope.Close(Utils::ToLocal(data)); 1633 return scope.Close(Utils::ToLocal(data));
1623 } 1634 }
1624 1635
1625 1636
1626 v8::Handle<v8::StackTrace> Message::GetStackTrace() const { 1637 v8::Handle<v8::StackTrace> Message::GetStackTrace() const {
1627 i::Isolate* isolate = i::Isolate::Current(); 1638 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1628 if (IsDeadCheck(isolate, "v8::Message::GetStackTrace()")) { 1639 if (IsDeadCheck(isolate, "v8::Message::GetStackTrace()")) {
1629 return Local<v8::StackTrace>(); 1640 return Local<v8::StackTrace>();
1630 } 1641 }
1631 ENTER_V8; 1642 ENTER_V8(isolate);
1632 HandleScope scope; 1643 HandleScope scope;
1633 i::Handle<i::JSMessageObject> message = 1644 i::Handle<i::JSMessageObject> message =
1634 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); 1645 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
1635 i::Handle<i::Object> stackFramesObj(message->stack_frames()); 1646 i::Handle<i::Object> stackFramesObj(message->stack_frames());
1636 if (!stackFramesObj->IsJSArray()) return v8::Handle<v8::StackTrace>(); 1647 if (!stackFramesObj->IsJSArray()) return v8::Handle<v8::StackTrace>();
1637 i::Handle<i::JSArray> stackTrace = 1648 i::Handle<i::JSArray> stackTrace =
1638 i::Handle<i::JSArray>::cast(stackFramesObj); 1649 i::Handle<i::JSArray>::cast(stackFramesObj);
1639 return scope.Close(Utils::StackTraceToLocal(stackTrace)); 1650 return scope.Close(Utils::StackTraceToLocal(stackTrace));
1640 } 1651 }
1641 1652
(...skipping 21 matching lines...) Expand all
1663 i::Object** argv[1] = { data.location() }; 1674 i::Object** argv[1] = { data.location() };
1664 return CallV8HeapFunction(name, 1675 return CallV8HeapFunction(name,
1665 i::Isolate::Current()->js_builtins_object(), 1676 i::Isolate::Current()->js_builtins_object(),
1666 1, 1677 1,
1667 argv, 1678 argv,
1668 has_pending_exception); 1679 has_pending_exception);
1669 } 1680 }
1670 1681
1671 1682
1672 int Message::GetLineNumber() const { 1683 int Message::GetLineNumber() const {
1673 i::Isolate* isolate = i::Isolate::Current(); 1684 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1674 ON_BAILOUT(isolate, "v8::Message::GetLineNumber()", return kNoLineNumberInfo); 1685 ON_BAILOUT(isolate, "v8::Message::GetLineNumber()", return kNoLineNumberInfo);
1675 ENTER_V8; 1686 ENTER_V8(isolate);
1676 i::HandleScope scope(isolate); 1687 i::HandleScope scope(isolate);
1677 1688
1678 EXCEPTION_PREAMBLE(); 1689 EXCEPTION_PREAMBLE(isolate);
1679 i::Handle<i::Object> result = CallV8HeapFunction("GetLineNumber", 1690 i::Handle<i::Object> result = CallV8HeapFunction("GetLineNumber",
1680 Utils::OpenHandle(this), 1691 Utils::OpenHandle(this),
1681 &has_pending_exception); 1692 &has_pending_exception);
1682 EXCEPTION_BAILOUT_CHECK(0); 1693 EXCEPTION_BAILOUT_CHECK(isolate, 0);
1683 return static_cast<int>(result->Number()); 1694 return static_cast<int>(result->Number());
1684 } 1695 }
1685 1696
1686 1697
1687 int Message::GetStartPosition() const { 1698 int Message::GetStartPosition() const {
1688 i::Isolate* isolate = i::Isolate::Current(); 1699 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1689 if (IsDeadCheck(isolate, "v8::Message::GetStartPosition()")) return 0; 1700 if (IsDeadCheck(isolate, "v8::Message::GetStartPosition()")) return 0;
1690 ENTER_V8; 1701 ENTER_V8(isolate);
1691 i::HandleScope scope(isolate); 1702 i::HandleScope scope(isolate);
1692 i::Handle<i::JSMessageObject> message = 1703 i::Handle<i::JSMessageObject> message =
1693 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); 1704 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
1694 return message->start_position(); 1705 return message->start_position();
1695 } 1706 }
1696 1707
1697 1708
1698 int Message::GetEndPosition() const { 1709 int Message::GetEndPosition() const {
1699 i::Isolate* isolate = i::Isolate::Current(); 1710 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1700 if (IsDeadCheck(isolate, "v8::Message::GetEndPosition()")) return 0; 1711 if (IsDeadCheck(isolate, "v8::Message::GetEndPosition()")) return 0;
1701 ENTER_V8; 1712 ENTER_V8(isolate);
1702 i::HandleScope scope(isolate); 1713 i::HandleScope scope(isolate);
1703 i::Handle<i::JSMessageObject> message = 1714 i::Handle<i::JSMessageObject> message =
1704 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); 1715 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
1705 return message->end_position(); 1716 return message->end_position();
1706 } 1717 }
1707 1718
1708 1719
1709 int Message::GetStartColumn() const { 1720 int Message::GetStartColumn() const {
1710 i::Isolate* isolate = i::Isolate::Current(); 1721 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1711 if (IsDeadCheck(isolate, "v8::Message::GetStartColumn()")) { 1722 if (IsDeadCheck(isolate, "v8::Message::GetStartColumn()")) {
1712 return kNoColumnInfo; 1723 return kNoColumnInfo;
1713 } 1724 }
1714 ENTER_V8; 1725 ENTER_V8(isolate);
1715 i::HandleScope scope(isolate); 1726 i::HandleScope scope(isolate);
1716 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); 1727 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this);
1717 EXCEPTION_PREAMBLE(); 1728 EXCEPTION_PREAMBLE(isolate);
1718 i::Handle<i::Object> start_col_obj = CallV8HeapFunction( 1729 i::Handle<i::Object> start_col_obj = CallV8HeapFunction(
1719 "GetPositionInLine", 1730 "GetPositionInLine",
1720 data_obj, 1731 data_obj,
1721 &has_pending_exception); 1732 &has_pending_exception);
1722 EXCEPTION_BAILOUT_CHECK(0); 1733 EXCEPTION_BAILOUT_CHECK(isolate, 0);
1723 return static_cast<int>(start_col_obj->Number()); 1734 return static_cast<int>(start_col_obj->Number());
1724 } 1735 }
1725 1736
1726 1737
1727 int Message::GetEndColumn() const { 1738 int Message::GetEndColumn() const {
1728 i::Isolate* isolate = i::Isolate::Current(); 1739 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1729 if (IsDeadCheck(isolate, "v8::Message::GetEndColumn()")) return kNoColumnInfo; 1740 if (IsDeadCheck(isolate, "v8::Message::GetEndColumn()")) return kNoColumnInfo;
1730 ENTER_V8; 1741 ENTER_V8(isolate);
1731 i::HandleScope scope(isolate); 1742 i::HandleScope scope(isolate);
1732 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); 1743 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this);
1733 EXCEPTION_PREAMBLE(); 1744 EXCEPTION_PREAMBLE(isolate);
1734 i::Handle<i::Object> start_col_obj = CallV8HeapFunction( 1745 i::Handle<i::Object> start_col_obj = CallV8HeapFunction(
1735 "GetPositionInLine", 1746 "GetPositionInLine",
1736 data_obj, 1747 data_obj,
1737 &has_pending_exception); 1748 &has_pending_exception);
1738 EXCEPTION_BAILOUT_CHECK(0); 1749 EXCEPTION_BAILOUT_CHECK(isolate, 0);
1739 i::Handle<i::JSMessageObject> message = 1750 i::Handle<i::JSMessageObject> message =
1740 i::Handle<i::JSMessageObject>::cast(data_obj); 1751 i::Handle<i::JSMessageObject>::cast(data_obj);
1741 int start = message->start_position(); 1752 int start = message->start_position();
1742 int end = message->end_position(); 1753 int end = message->end_position();
1743 return static_cast<int>(start_col_obj->Number()) + (end - start); 1754 return static_cast<int>(start_col_obj->Number()) + (end - start);
1744 } 1755 }
1745 1756
1746 1757
1747 Local<String> Message::GetSourceLine() const { 1758 Local<String> Message::GetSourceLine() const {
1748 i::Isolate* isolate = i::Isolate::Current(); 1759 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1749 ON_BAILOUT(isolate, "v8::Message::GetSourceLine()", return Local<String>()); 1760 ON_BAILOUT(isolate, "v8::Message::GetSourceLine()", return Local<String>());
1750 ENTER_V8; 1761 ENTER_V8(isolate);
1751 HandleScope scope; 1762 HandleScope scope;
1752 EXCEPTION_PREAMBLE(); 1763 EXCEPTION_PREAMBLE(isolate);
1753 i::Handle<i::Object> result = CallV8HeapFunction("GetSourceLine", 1764 i::Handle<i::Object> result = CallV8HeapFunction("GetSourceLine",
1754 Utils::OpenHandle(this), 1765 Utils::OpenHandle(this),
1755 &has_pending_exception); 1766 &has_pending_exception);
1756 EXCEPTION_BAILOUT_CHECK(Local<v8::String>()); 1767 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::String>());
1757 if (result->IsString()) { 1768 if (result->IsString()) {
1758 return scope.Close(Utils::ToLocal(i::Handle<i::String>::cast(result))); 1769 return scope.Close(Utils::ToLocal(i::Handle<i::String>::cast(result)));
1759 } else { 1770 } else {
1760 return Local<String>(); 1771 return Local<String>();
1761 } 1772 }
1762 } 1773 }
1763 1774
1764 1775
1765 void Message::PrintCurrentStackTrace(FILE* out) { 1776 void Message::PrintCurrentStackTrace(FILE* out) {
1766 i::Isolate* isolate = i::Isolate::Current(); 1777 i::Isolate* isolate = i::Isolate::Current();
1767 if (IsDeadCheck(isolate, "v8::Message::PrintCurrentStackTrace()")) return; 1778 if (IsDeadCheck(isolate, "v8::Message::PrintCurrentStackTrace()")) return;
1768 ENTER_V8; 1779 ENTER_V8(isolate);
1769 isolate->PrintCurrentStackTrace(out); 1780 isolate->PrintCurrentStackTrace(out);
1770 } 1781 }
1771 1782
1772 1783
1773 // --- S t a c k T r a c e --- 1784 // --- S t a c k T r a c e ---
1774 1785
1775 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const { 1786 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const {
1776 i::Isolate* isolate = i::Isolate::Current(); 1787 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1777 if (IsDeadCheck(isolate, "v8::StackTrace::GetFrame()")) { 1788 if (IsDeadCheck(isolate, "v8::StackTrace::GetFrame()")) {
1778 return Local<StackFrame>(); 1789 return Local<StackFrame>();
1779 } 1790 }
1780 ENTER_V8; 1791 ENTER_V8(isolate);
1781 HandleScope scope; 1792 HandleScope scope;
1782 i::Handle<i::JSArray> self = Utils::OpenHandle(this); 1793 i::Handle<i::JSArray> self = Utils::OpenHandle(this);
1783 i::Object* raw_object = self->GetElementNoExceptionThrown(index); 1794 i::Object* raw_object = self->GetElementNoExceptionThrown(index);
1784 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_object)); 1795 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_object));
1785 return scope.Close(Utils::StackFrameToLocal(obj)); 1796 return scope.Close(Utils::StackFrameToLocal(obj));
1786 } 1797 }
1787 1798
1788 1799
1789 int StackTrace::GetFrameCount() const { 1800 int StackTrace::GetFrameCount() const {
1790 i::Isolate* isolate = i::Isolate::Current(); 1801 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1791 if (IsDeadCheck(isolate, "v8::StackTrace::GetFrameCount()")) return -1; 1802 if (IsDeadCheck(isolate, "v8::StackTrace::GetFrameCount()")) return -1;
1792 ENTER_V8; 1803 ENTER_V8(isolate);
1793 return i::Smi::cast(Utils::OpenHandle(this)->length())->value(); 1804 return i::Smi::cast(Utils::OpenHandle(this)->length())->value();
1794 } 1805 }
1795 1806
1796 1807
1797 Local<Array> StackTrace::AsArray() { 1808 Local<Array> StackTrace::AsArray() {
1798 i::Isolate* isolate = i::Isolate::Current(); 1809 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1799 if (IsDeadCheck(isolate, "v8::StackTrace::AsArray()")) Local<Array>(); 1810 if (IsDeadCheck(isolate, "v8::StackTrace::AsArray()")) Local<Array>();
1800 ENTER_V8; 1811 ENTER_V8(isolate);
1801 return Utils::ToLocal(Utils::OpenHandle(this)); 1812 return Utils::ToLocal(Utils::OpenHandle(this));
1802 } 1813 }
1803 1814
1804 1815
1805 Local<StackTrace> StackTrace::CurrentStackTrace(int frame_limit, 1816 Local<StackTrace> StackTrace::CurrentStackTrace(int frame_limit,
1806 StackTraceOptions options) { 1817 StackTraceOptions options) {
1807 i::Isolate* isolate = i::Isolate::Current(); 1818 i::Isolate* isolate = i::Isolate::Current();
1808 if (IsDeadCheck(isolate, "v8::StackTrace::CurrentStackTrace()")) { 1819 if (IsDeadCheck(isolate, "v8::StackTrace::CurrentStackTrace()")) {
1809 Local<StackTrace>(); 1820 Local<StackTrace>();
1810 } 1821 }
1811 ENTER_V8; 1822 ENTER_V8(isolate);
1812 i::Handle<i::JSArray> stackTrace = 1823 i::Handle<i::JSArray> stackTrace =
1813 isolate->CaptureCurrentStackTrace(frame_limit, options); 1824 isolate->CaptureCurrentStackTrace(frame_limit, options);
1814 return Utils::StackTraceToLocal(stackTrace); 1825 return Utils::StackTraceToLocal(stackTrace);
1815 } 1826 }
1816 1827
1817 1828
1818 // --- S t a c k F r a m e --- 1829 // --- S t a c k F r a m e ---
1819 1830
1820 int StackFrame::GetLineNumber() const { 1831 int StackFrame::GetLineNumber() const {
1821 i::Isolate* isolate = i::Isolate::Current(); 1832 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1822 if (IsDeadCheck(isolate, "v8::StackFrame::GetLineNumber()")) { 1833 if (IsDeadCheck(isolate, "v8::StackFrame::GetLineNumber()")) {
1823 return Message::kNoLineNumberInfo; 1834 return Message::kNoLineNumberInfo;
1824 } 1835 }
1825 ENTER_V8; 1836 ENTER_V8(isolate);
1826 i::HandleScope scope(isolate); 1837 i::HandleScope scope(isolate);
1827 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 1838 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
1828 i::Handle<i::Object> line = GetProperty(self, "lineNumber"); 1839 i::Handle<i::Object> line = GetProperty(self, "lineNumber");
1829 if (!line->IsSmi()) { 1840 if (!line->IsSmi()) {
1830 return Message::kNoLineNumberInfo; 1841 return Message::kNoLineNumberInfo;
1831 } 1842 }
1832 return i::Smi::cast(*line)->value(); 1843 return i::Smi::cast(*line)->value();
1833 } 1844 }
1834 1845
1835 1846
1836 int StackFrame::GetColumn() const { 1847 int StackFrame::GetColumn() const {
1837 i::Isolate* isolate = i::Isolate::Current(); 1848 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1838 if (IsDeadCheck(isolate, "v8::StackFrame::GetColumn()")) { 1849 if (IsDeadCheck(isolate, "v8::StackFrame::GetColumn()")) {
1839 return Message::kNoColumnInfo; 1850 return Message::kNoColumnInfo;
1840 } 1851 }
1841 ENTER_V8; 1852 ENTER_V8(isolate);
1842 i::HandleScope scope(isolate); 1853 i::HandleScope scope(isolate);
1843 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 1854 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
1844 i::Handle<i::Object> column = GetProperty(self, "column"); 1855 i::Handle<i::Object> column = GetProperty(self, "column");
1845 if (!column->IsSmi()) { 1856 if (!column->IsSmi()) {
1846 return Message::kNoColumnInfo; 1857 return Message::kNoColumnInfo;
1847 } 1858 }
1848 return i::Smi::cast(*column)->value(); 1859 return i::Smi::cast(*column)->value();
1849 } 1860 }
1850 1861
1851 1862
1852 Local<String> StackFrame::GetScriptName() const { 1863 Local<String> StackFrame::GetScriptName() const {
1853 i::Isolate* isolate = i::Isolate::Current(); 1864 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1854 if (IsDeadCheck(isolate, "v8::StackFrame::GetScriptName()")) { 1865 if (IsDeadCheck(isolate, "v8::StackFrame::GetScriptName()")) {
1855 return Local<String>(); 1866 return Local<String>();
1856 } 1867 }
1857 ENTER_V8; 1868 ENTER_V8(isolate);
1858 HandleScope scope; 1869 HandleScope scope;
1859 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 1870 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
1860 i::Handle<i::Object> name = GetProperty(self, "scriptName"); 1871 i::Handle<i::Object> name = GetProperty(self, "scriptName");
1861 if (!name->IsString()) { 1872 if (!name->IsString()) {
1862 return Local<String>(); 1873 return Local<String>();
1863 } 1874 }
1864 return scope.Close(Local<String>::Cast(Utils::ToLocal(name))); 1875 return scope.Close(Local<String>::Cast(Utils::ToLocal(name)));
1865 } 1876 }
1866 1877
1867 1878
1868 Local<String> StackFrame::GetScriptNameOrSourceURL() const { 1879 Local<String> StackFrame::GetScriptNameOrSourceURL() const {
1869 i::Isolate* isolate = i::Isolate::Current(); 1880 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1870 if (IsDeadCheck(isolate, "v8::StackFrame::GetScriptNameOrSourceURL()")) { 1881 if (IsDeadCheck(isolate, "v8::StackFrame::GetScriptNameOrSourceURL()")) {
1871 return Local<String>(); 1882 return Local<String>();
1872 } 1883 }
1873 ENTER_V8; 1884 ENTER_V8(isolate);
1874 HandleScope scope; 1885 HandleScope scope;
1875 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 1886 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
1876 i::Handle<i::Object> name = GetProperty(self, "scriptNameOrSourceURL"); 1887 i::Handle<i::Object> name = GetProperty(self, "scriptNameOrSourceURL");
1877 if (!name->IsString()) { 1888 if (!name->IsString()) {
1878 return Local<String>(); 1889 return Local<String>();
1879 } 1890 }
1880 return scope.Close(Local<String>::Cast(Utils::ToLocal(name))); 1891 return scope.Close(Local<String>::Cast(Utils::ToLocal(name)));
1881 } 1892 }
1882 1893
1883 1894
1884 Local<String> StackFrame::GetFunctionName() const { 1895 Local<String> StackFrame::GetFunctionName() const {
1885 i::Isolate* isolate = i::Isolate::Current(); 1896 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1886 if (IsDeadCheck(isolate, "v8::StackFrame::GetFunctionName()")) { 1897 if (IsDeadCheck(isolate, "v8::StackFrame::GetFunctionName()")) {
1887 return Local<String>(); 1898 return Local<String>();
1888 } 1899 }
1889 ENTER_V8; 1900 ENTER_V8(isolate);
1890 HandleScope scope; 1901 HandleScope scope;
1891 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 1902 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
1892 i::Handle<i::Object> name = GetProperty(self, "functionName"); 1903 i::Handle<i::Object> name = GetProperty(self, "functionName");
1893 if (!name->IsString()) { 1904 if (!name->IsString()) {
1894 return Local<String>(); 1905 return Local<String>();
1895 } 1906 }
1896 return scope.Close(Local<String>::Cast(Utils::ToLocal(name))); 1907 return scope.Close(Local<String>::Cast(Utils::ToLocal(name)));
1897 } 1908 }
1898 1909
1899 1910
1900 bool StackFrame::IsEval() const { 1911 bool StackFrame::IsEval() const {
1901 i::Isolate* isolate = i::Isolate::Current(); 1912 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1902 if (IsDeadCheck(isolate, "v8::StackFrame::IsEval()")) return false; 1913 if (IsDeadCheck(isolate, "v8::StackFrame::IsEval()")) return false;
1903 ENTER_V8; 1914 ENTER_V8(isolate);
1904 i::HandleScope scope(isolate); 1915 i::HandleScope scope(isolate);
1905 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 1916 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
1906 i::Handle<i::Object> is_eval = GetProperty(self, "isEval"); 1917 i::Handle<i::Object> is_eval = GetProperty(self, "isEval");
1907 return is_eval->IsTrue(); 1918 return is_eval->IsTrue();
1908 } 1919 }
1909 1920
1910 1921
1911 bool StackFrame::IsConstructor() const { 1922 bool StackFrame::IsConstructor() const {
1912 i::Isolate* isolate = i::Isolate::Current(); 1923 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1913 if (IsDeadCheck(isolate, "v8::StackFrame::IsConstructor()")) return false; 1924 if (IsDeadCheck(isolate, "v8::StackFrame::IsConstructor()")) return false;
1914 ENTER_V8; 1925 ENTER_V8(isolate);
1915 i::HandleScope scope(isolate); 1926 i::HandleScope scope(isolate);
1916 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 1927 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
1917 i::Handle<i::Object> is_constructor = GetProperty(self, "isConstructor"); 1928 i::Handle<i::Object> is_constructor = GetProperty(self, "isConstructor");
1918 return is_constructor->IsTrue(); 1929 return is_constructor->IsTrue();
1919 } 1930 }
1920 1931
1921 1932
1922 // --- D a t a --- 1933 // --- D a t a ---
1923 1934
1924 bool Value::IsUndefined() const { 1935 bool Value::IsUndefined() const {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
2029 2040
2030 2041
2031 bool Value::IsRegExp() const { 2042 bool Value::IsRegExp() const {
2032 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsRegExp()")) return false; 2043 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsRegExp()")) return false;
2033 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2044 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2034 return obj->IsJSRegExp(); 2045 return obj->IsJSRegExp();
2035 } 2046 }
2036 2047
2037 2048
2038 Local<String> Value::ToString() const { 2049 Local<String> Value::ToString() const {
2039 i::Isolate* isolate = i::Isolate::Current();
2040 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::ToString()")) {
2041 return Local<String>();
2042 }
2043 LOG_API(isolate, "ToString");
2044 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2050 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2045 i::Handle<i::Object> str; 2051 i::Handle<i::Object> str;
2046 if (obj->IsString()) { 2052 if (obj->IsString()) {
2047 str = obj; 2053 str = obj;
2048 } else { 2054 } else {
2049 ENTER_V8; 2055 i::Isolate* isolate = i::Isolate::Current();
2050 EXCEPTION_PREAMBLE(); 2056 if (IsDeadCheck(isolate, "v8::Value::ToString()")) {
2057 return Local<String>();
2058 }
2059 LOG_API(isolate, "ToString");
2060 ENTER_V8(isolate);
2061 EXCEPTION_PREAMBLE(isolate);
2051 str = i::Execution::ToString(obj, &has_pending_exception); 2062 str = i::Execution::ToString(obj, &has_pending_exception);
2052 EXCEPTION_BAILOUT_CHECK(Local<String>()); 2063 EXCEPTION_BAILOUT_CHECK(isolate, Local<String>());
2053 } 2064 }
2054 return Local<String>(ToApi<String>(str)); 2065 return Local<String>(ToApi<String>(str));
2055 } 2066 }
2056 2067
2057 2068
2058 Local<String> Value::ToDetailString() const { 2069 Local<String> Value::ToDetailString() const {
2059 i::Isolate* isolate = i::Isolate::Current();
2060 if (IsDeadCheck(isolate, "v8::Value::ToDetailString()")) {
2061 return Local<String>();
2062 }
2063 LOG_API(isolate, "ToDetailString");
2064 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2070 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2065 i::Handle<i::Object> str; 2071 i::Handle<i::Object> str;
2066 if (obj->IsString()) { 2072 if (obj->IsString()) {
2067 str = obj; 2073 str = obj;
2068 } else { 2074 } else {
2069 ENTER_V8; 2075 i::Isolate* isolate = i::Isolate::Current();
2070 EXCEPTION_PREAMBLE(); 2076 if (IsDeadCheck(isolate, "v8::Value::ToDetailString()")) {
2077 return Local<String>();
2078 }
2079 LOG_API(isolate, "ToDetailString");
2080 ENTER_V8(isolate);
2081 EXCEPTION_PREAMBLE(isolate);
2071 str = i::Execution::ToDetailString(obj, &has_pending_exception); 2082 str = i::Execution::ToDetailString(obj, &has_pending_exception);
2072 EXCEPTION_BAILOUT_CHECK(Local<String>()); 2083 EXCEPTION_BAILOUT_CHECK(isolate, Local<String>());
2073 } 2084 }
2074 return Local<String>(ToApi<String>(str)); 2085 return Local<String>(ToApi<String>(str));
2075 } 2086 }
2076 2087
2077 2088
2078 Local<v8::Object> Value::ToObject() const { 2089 Local<v8::Object> Value::ToObject() const {
2079 i::Isolate* isolate = i::Isolate::Current();
2080 if (IsDeadCheck(isolate, "v8::Value::ToObject()")) return Local<v8::Object>();
2081 LOG_API(isolate, "ToObject");
2082 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2090 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2083 i::Handle<i::Object> val; 2091 i::Handle<i::Object> val;
2084 if (obj->IsJSObject()) { 2092 if (obj->IsJSObject()) {
2085 val = obj; 2093 val = obj;
2086 } else { 2094 } else {
2087 ENTER_V8; 2095 i::Isolate* isolate = i::Isolate::Current();
2088 EXCEPTION_PREAMBLE(); 2096 if (IsDeadCheck(isolate, "v8::Value::ToObject()")) {
2097 return Local<v8::Object>();
2098 }
2099 LOG_API(isolate, "ToObject");
2100 ENTER_V8(isolate);
2101 EXCEPTION_PREAMBLE(isolate);
2089 val = i::Execution::ToObject(obj, &has_pending_exception); 2102 val = i::Execution::ToObject(obj, &has_pending_exception);
2090 EXCEPTION_BAILOUT_CHECK(Local<v8::Object>()); 2103 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>());
2091 } 2104 }
2092 return Local<v8::Object>(ToApi<Object>(val)); 2105 return Local<v8::Object>(ToApi<Object>(val));
2093 } 2106 }
2094 2107
2095 2108
2096 Local<Boolean> Value::ToBoolean() const { 2109 Local<Boolean> Value::ToBoolean() const {
2097 i::Isolate* isolate = i::Isolate::Current();
2098 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::ToBoolean()")) {
2099 return Local<Boolean>();
2100 }
2101 LOG_API(isolate, "ToBoolean");
2102 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2110 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2103 if (obj->IsBoolean()) { 2111 if (obj->IsBoolean()) {
2104 return Local<Boolean>(ToApi<Boolean>(obj)); 2112 return Local<Boolean>(ToApi<Boolean>(obj));
2105 } else { 2113 } else {
2106 ENTER_V8; 2114 i::Isolate* isolate = i::Isolate::Current();
2115 if (IsDeadCheck(isolate, "v8::Value::ToBoolean()")) {
2116 return Local<Boolean>();
2117 }
2118 LOG_API(isolate, "ToBoolean");
2119 ENTER_V8(isolate);
2107 i::Handle<i::Object> val = i::Execution::ToBoolean(obj); 2120 i::Handle<i::Object> val = i::Execution::ToBoolean(obj);
2108 return Local<Boolean>(ToApi<Boolean>(val)); 2121 return Local<Boolean>(ToApi<Boolean>(val));
2109 } 2122 }
2110 } 2123 }
2111 2124
2112 2125
2113 Local<Number> Value::ToNumber() const { 2126 Local<Number> Value::ToNumber() const {
2114 i::Isolate* isolate = i::Isolate::Current();
2115 if (IsDeadCheck(isolate, "v8::Value::ToNumber()")) return Local<Number>();
2116 LOG_API(isolate, "ToNumber");
2117 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2127 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2118 i::Handle<i::Object> num; 2128 i::Handle<i::Object> num;
2119 if (obj->IsNumber()) { 2129 if (obj->IsNumber()) {
2120 num = obj; 2130 num = obj;
2121 } else { 2131 } else {
2122 ENTER_V8; 2132 i::Isolate* isolate = i::Isolate::Current();
2123 EXCEPTION_PREAMBLE(); 2133 if (IsDeadCheck(isolate, "v8::Value::ToNumber()")) {
2134 return Local<Number>();
2135 }
2136 LOG_API(isolate, "ToNumber");
2137 ENTER_V8(isolate);
2138 EXCEPTION_PREAMBLE(isolate);
2124 num = i::Execution::ToNumber(obj, &has_pending_exception); 2139 num = i::Execution::ToNumber(obj, &has_pending_exception);
2125 EXCEPTION_BAILOUT_CHECK(Local<Number>()); 2140 EXCEPTION_BAILOUT_CHECK(isolate, Local<Number>());
2126 } 2141 }
2127 return Local<Number>(ToApi<Number>(num)); 2142 return Local<Number>(ToApi<Number>(num));
2128 } 2143 }
2129 2144
2130 2145
2131 Local<Integer> Value::ToInteger() const { 2146 Local<Integer> Value::ToInteger() const {
2132 i::Isolate* isolate = i::Isolate::Current();
2133 if (IsDeadCheck(isolate, "v8::Value::ToInteger()")) return Local<Integer>();
2134 LOG_API(isolate, "ToInteger");
2135 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2147 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2136 i::Handle<i::Object> num; 2148 i::Handle<i::Object> num;
2137 if (obj->IsSmi()) { 2149 if (obj->IsSmi()) {
2138 num = obj; 2150 num = obj;
2139 } else { 2151 } else {
2140 ENTER_V8; 2152 i::Isolate* isolate = i::Isolate::Current();
2141 EXCEPTION_PREAMBLE(); 2153 if (IsDeadCheck(isolate, "v8::Value::ToInteger()")) return Local<Integer>();
2154 LOG_API(isolate, "ToInteger");
2155 ENTER_V8(isolate);
2156 EXCEPTION_PREAMBLE(isolate);
2142 num = i::Execution::ToInteger(obj, &has_pending_exception); 2157 num = i::Execution::ToInteger(obj, &has_pending_exception);
2143 EXCEPTION_BAILOUT_CHECK(Local<Integer>()); 2158 EXCEPTION_BAILOUT_CHECK(isolate, Local<Integer>());
2144 } 2159 }
2145 return Local<Integer>(ToApi<Integer>(num)); 2160 return Local<Integer>(ToApi<Integer>(num));
2146 } 2161 }
2147 2162
2148 2163
2149 void External::CheckCast(v8::Value* that) { 2164 void External::CheckCast(v8::Value* that) {
2150 if (IsDeadCheck(i::Isolate::Current(), "v8::External::Cast()")) return; 2165 if (IsDeadCheck(i::Isolate::Current(), "v8::External::Cast()")) return;
2151 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2166 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2152 ApiCheck(obj->IsProxy(), 2167 ApiCheck(obj->IsProxy(),
2153 "v8::External::Cast()", 2168 "v8::External::Cast()",
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
2221 void v8::RegExp::CheckCast(v8::Value* that) { 2236 void v8::RegExp::CheckCast(v8::Value* that) {
2222 if (IsDeadCheck(i::Isolate::Current(), "v8::RegExp::Cast()")) return; 2237 if (IsDeadCheck(i::Isolate::Current(), "v8::RegExp::Cast()")) return;
2223 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2238 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2224 ApiCheck(obj->IsJSRegExp(), 2239 ApiCheck(obj->IsJSRegExp(),
2225 "v8::RegExp::Cast()", 2240 "v8::RegExp::Cast()",
2226 "Could not convert to regular expression"); 2241 "Could not convert to regular expression");
2227 } 2242 }
2228 2243
2229 2244
2230 bool Value::BooleanValue() const { 2245 bool Value::BooleanValue() const {
2231 i::Isolate* isolate = i::Isolate::Current();
2232 if (IsDeadCheck(isolate, "v8::Value::BooleanValue()")) return false;
2233 LOG_API(isolate, "BooleanValue");
2234 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2246 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2235 if (obj->IsBoolean()) { 2247 if (obj->IsBoolean()) {
2236 return obj->IsTrue(); 2248 return obj->IsTrue();
2237 } else { 2249 } else {
2238 ENTER_V8; 2250 i::Isolate* isolate = i::Isolate::Current();
2251 if (IsDeadCheck(isolate, "v8::Value::BooleanValue()")) return false;
2252 LOG_API(isolate, "BooleanValue");
2253 ENTER_V8(isolate);
2239 i::Handle<i::Object> value = i::Execution::ToBoolean(obj); 2254 i::Handle<i::Object> value = i::Execution::ToBoolean(obj);
2240 return value->IsTrue(); 2255 return value->IsTrue();
2241 } 2256 }
2242 } 2257 }
2243 2258
2244 2259
2245 double Value::NumberValue() const { 2260 double Value::NumberValue() const {
2246 i::Isolate* isolate = i::Isolate::Current();
2247 if (IsDeadCheck(isolate, "v8::Value::NumberValue()")) {
2248 return i::OS::nan_value();
2249 }
2250 LOG_API(isolate, "NumberValue");
2251 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2261 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2252 i::Handle<i::Object> num; 2262 i::Handle<i::Object> num;
2253 if (obj->IsNumber()) { 2263 if (obj->IsNumber()) {
2254 num = obj; 2264 num = obj;
2255 } else { 2265 } else {
2256 ENTER_V8; 2266 i::Isolate* isolate = i::Isolate::Current();
2257 EXCEPTION_PREAMBLE(); 2267 if (IsDeadCheck(isolate, "v8::Value::NumberValue()")) {
2268 return i::OS::nan_value();
2269 }
2270 LOG_API(isolate, "NumberValue");
2271 ENTER_V8(isolate);
2272 EXCEPTION_PREAMBLE(isolate);
2258 num = i::Execution::ToNumber(obj, &has_pending_exception); 2273 num = i::Execution::ToNumber(obj, &has_pending_exception);
2259 EXCEPTION_BAILOUT_CHECK(i::OS::nan_value()); 2274 EXCEPTION_BAILOUT_CHECK(isolate, i::OS::nan_value());
2260 } 2275 }
2261 return num->Number(); 2276 return num->Number();
2262 } 2277 }
2263 2278
2264 2279
2265 int64_t Value::IntegerValue() const { 2280 int64_t Value::IntegerValue() const {
2266 i::Isolate* isolate = i::Isolate::Current();
2267 if (IsDeadCheck(isolate, "v8::Value::IntegerValue()")) return 0;
2268 LOG_API(isolate, "IntegerValue");
2269 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2281 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2270 i::Handle<i::Object> num; 2282 i::Handle<i::Object> num;
2271 if (obj->IsNumber()) { 2283 if (obj->IsNumber()) {
2272 num = obj; 2284 num = obj;
2273 } else { 2285 } else {
2274 ENTER_V8; 2286 i::Isolate* isolate = i::Isolate::Current();
2275 EXCEPTION_PREAMBLE(); 2287 if (IsDeadCheck(isolate, "v8::Value::IntegerValue()")) return 0;
2288 LOG_API(isolate, "IntegerValue");
2289 ENTER_V8(isolate);
2290 EXCEPTION_PREAMBLE(isolate);
2276 num = i::Execution::ToInteger(obj, &has_pending_exception); 2291 num = i::Execution::ToInteger(obj, &has_pending_exception);
2277 EXCEPTION_BAILOUT_CHECK(0); 2292 EXCEPTION_BAILOUT_CHECK(isolate, 0);
2278 } 2293 }
2279 if (num->IsSmi()) { 2294 if (num->IsSmi()) {
2280 return i::Smi::cast(*num)->value(); 2295 return i::Smi::cast(*num)->value();
2281 } else { 2296 } else {
2282 return static_cast<int64_t>(num->Number()); 2297 return static_cast<int64_t>(num->Number());
2283 } 2298 }
2284 } 2299 }
2285 2300
2286 2301
2287 Local<Int32> Value::ToInt32() const { 2302 Local<Int32> Value::ToInt32() const {
2288 i::Isolate* isolate = i::Isolate::Current();
2289 if (IsDeadCheck(isolate, "v8::Value::ToInt32()")) return Local<Int32>();
2290 LOG_API(isolate, "ToInt32");
2291 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2303 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2292 i::Handle<i::Object> num; 2304 i::Handle<i::Object> num;
2293 if (obj->IsSmi()) { 2305 if (obj->IsSmi()) {
2294 num = obj; 2306 num = obj;
2295 } else { 2307 } else {
2296 ENTER_V8; 2308 i::Isolate* isolate = i::Isolate::Current();
2297 EXCEPTION_PREAMBLE(); 2309 if (IsDeadCheck(isolate, "v8::Value::ToInt32()")) return Local<Int32>();
2310 LOG_API(isolate, "ToInt32");
2311 ENTER_V8(isolate);
2312 EXCEPTION_PREAMBLE(isolate);
2298 num = i::Execution::ToInt32(obj, &has_pending_exception); 2313 num = i::Execution::ToInt32(obj, &has_pending_exception);
2299 EXCEPTION_BAILOUT_CHECK(Local<Int32>()); 2314 EXCEPTION_BAILOUT_CHECK(isolate, Local<Int32>());
2300 } 2315 }
2301 return Local<Int32>(ToApi<Int32>(num)); 2316 return Local<Int32>(ToApi<Int32>(num));
2302 } 2317 }
2303 2318
2304 2319
2305 Local<Uint32> Value::ToUint32() const { 2320 Local<Uint32> Value::ToUint32() const {
2306 i::Isolate* isolate = i::Isolate::Current();
2307 if (IsDeadCheck(isolate, "v8::Value::ToUint32()")) return Local<Uint32>();
2308 LOG_API(isolate, "ToUInt32");
2309 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2321 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2310 i::Handle<i::Object> num; 2322 i::Handle<i::Object> num;
2311 if (obj->IsSmi()) { 2323 if (obj->IsSmi()) {
2312 num = obj; 2324 num = obj;
2313 } else { 2325 } else {
2314 ENTER_V8; 2326 i::Isolate* isolate = i::Isolate::Current();
2315 EXCEPTION_PREAMBLE(); 2327 if (IsDeadCheck(isolate, "v8::Value::ToUint32()")) return Local<Uint32>();
2328 LOG_API(isolate, "ToUInt32");
2329 ENTER_V8(isolate);
2330 EXCEPTION_PREAMBLE(isolate);
2316 num = i::Execution::ToUint32(obj, &has_pending_exception); 2331 num = i::Execution::ToUint32(obj, &has_pending_exception);
2317 EXCEPTION_BAILOUT_CHECK(Local<Uint32>()); 2332 EXCEPTION_BAILOUT_CHECK(isolate, Local<Uint32>());
2318 } 2333 }
2319 return Local<Uint32>(ToApi<Uint32>(num)); 2334 return Local<Uint32>(ToApi<Uint32>(num));
2320 } 2335 }
2321 2336
2322 2337
2323 Local<Uint32> Value::ToArrayIndex() const { 2338 Local<Uint32> Value::ToArrayIndex() const {
2324 i::Isolate* isolate = i::Isolate::Current();
2325 if (IsDeadCheck(isolate, "v8::Value::ToArrayIndex()")) return Local<Uint32>();
2326 LOG_API(isolate, "ToArrayIndex");
2327 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2339 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2328 if (obj->IsSmi()) { 2340 if (obj->IsSmi()) {
2329 if (i::Smi::cast(*obj)->value() >= 0) return Utils::Uint32ToLocal(obj); 2341 if (i::Smi::cast(*obj)->value() >= 0) return Utils::Uint32ToLocal(obj);
2330 return Local<Uint32>(); 2342 return Local<Uint32>();
2331 } 2343 }
2332 ENTER_V8; 2344 i::Isolate* isolate = i::Isolate::Current();
2333 EXCEPTION_PREAMBLE(); 2345 if (IsDeadCheck(isolate, "v8::Value::ToArrayIndex()")) return Local<Uint32>();
2346 LOG_API(isolate, "ToArrayIndex");
2347 ENTER_V8(isolate);
2348 EXCEPTION_PREAMBLE(isolate);
2334 i::Handle<i::Object> string_obj = 2349 i::Handle<i::Object> string_obj =
2335 i::Execution::ToString(obj, &has_pending_exception); 2350 i::Execution::ToString(obj, &has_pending_exception);
2336 EXCEPTION_BAILOUT_CHECK(Local<Uint32>()); 2351 EXCEPTION_BAILOUT_CHECK(isolate, Local<Uint32>());
2337 i::Handle<i::String> str = i::Handle<i::String>::cast(string_obj); 2352 i::Handle<i::String> str = i::Handle<i::String>::cast(string_obj);
2338 uint32_t index; 2353 uint32_t index;
2339 if (str->AsArrayIndex(&index)) { 2354 if (str->AsArrayIndex(&index)) {
2340 i::Handle<i::Object> value; 2355 i::Handle<i::Object> value;
2341 if (index <= static_cast<uint32_t>(i::Smi::kMaxValue)) { 2356 if (index <= static_cast<uint32_t>(i::Smi::kMaxValue)) {
2342 value = i::Handle<i::Object>(i::Smi::FromInt(index)); 2357 value = i::Handle<i::Object>(i::Smi::FromInt(index));
2343 } else { 2358 } else {
2344 value = FACTORY->NewNumber(index); 2359 value = FACTORY->NewNumber(index);
2345 } 2360 }
2346 return Utils::Uint32ToLocal(value); 2361 return Utils::Uint32ToLocal(value);
2347 } 2362 }
2348 return Local<Uint32>(); 2363 return Local<Uint32>();
2349 } 2364 }
2350 2365
2351 2366
2352 int32_t Value::Int32Value() const { 2367 int32_t Value::Int32Value() const {
2353 i::Isolate* isolate = i::Isolate::Current();
2354 if (IsDeadCheck(isolate, "v8::Value::Int32Value()")) return 0;
2355 LOG_API(isolate, "Int32Value");
2356 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2368 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2357 if (obj->IsSmi()) { 2369 if (obj->IsSmi()) {
2358 return i::Smi::cast(*obj)->value(); 2370 return i::Smi::cast(*obj)->value();
2359 } else { 2371 } else {
2372 i::Isolate* isolate = i::Isolate::Current();
2373 if (IsDeadCheck(isolate, "v8::Value::Int32Value()")) return 0;
2360 LOG_API(isolate, "Int32Value (slow)"); 2374 LOG_API(isolate, "Int32Value (slow)");
2361 ENTER_V8; 2375 ENTER_V8(isolate);
2362 EXCEPTION_PREAMBLE(); 2376 EXCEPTION_PREAMBLE(isolate);
2363 i::Handle<i::Object> num = 2377 i::Handle<i::Object> num =
2364 i::Execution::ToInt32(obj, &has_pending_exception); 2378 i::Execution::ToInt32(obj, &has_pending_exception);
2365 EXCEPTION_BAILOUT_CHECK(0); 2379 EXCEPTION_BAILOUT_CHECK(isolate, 0);
2366 if (num->IsSmi()) { 2380 if (num->IsSmi()) {
2367 return i::Smi::cast(*num)->value(); 2381 return i::Smi::cast(*num)->value();
2368 } else { 2382 } else {
2369 return static_cast<int32_t>(num->Number()); 2383 return static_cast<int32_t>(num->Number());
2370 } 2384 }
2371 } 2385 }
2372 } 2386 }
2373 2387
2374 2388
2375 bool Value::Equals(Handle<Value> that) const { 2389 bool Value::Equals(Handle<Value> that) const {
2376 i::Isolate* isolate = i::Isolate::Current(); 2390 i::Isolate* isolate = i::Isolate::Current();
2377 if (IsDeadCheck(isolate, "v8::Value::Equals()") 2391 if (IsDeadCheck(isolate, "v8::Value::Equals()")
2378 || EmptyCheck("v8::Value::Equals()", this) 2392 || EmptyCheck("v8::Value::Equals()", this)
2379 || EmptyCheck("v8::Value::Equals()", that)) { 2393 || EmptyCheck("v8::Value::Equals()", that)) {
2380 return false; 2394 return false;
2381 } 2395 }
2382 LOG_API(isolate, "Equals"); 2396 LOG_API(isolate, "Equals");
2383 ENTER_V8; 2397 ENTER_V8(isolate);
2384 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2398 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2385 i::Handle<i::Object> other = Utils::OpenHandle(*that); 2399 i::Handle<i::Object> other = Utils::OpenHandle(*that);
2386 // If both obj and other are JSObjects, we'd better compare by identity 2400 // If both obj and other are JSObjects, we'd better compare by identity
2387 // immediately when going into JS builtin. The reason is Invoke 2401 // immediately when going into JS builtin. The reason is Invoke
2388 // would overwrite global object receiver with global proxy. 2402 // would overwrite global object receiver with global proxy.
2389 if (obj->IsJSObject() && other->IsJSObject()) { 2403 if (obj->IsJSObject() && other->IsJSObject()) {
2390 return *obj == *other; 2404 return *obj == *other;
2391 } 2405 }
2392 i::Object** args[1] = { other.location() }; 2406 i::Object** args[1] = { other.location() };
2393 EXCEPTION_PREAMBLE(); 2407 EXCEPTION_PREAMBLE(isolate);
2394 i::Handle<i::Object> result = 2408 i::Handle<i::Object> result =
2395 CallV8HeapFunction("EQUALS", obj, 1, args, &has_pending_exception); 2409 CallV8HeapFunction("EQUALS", obj, 1, args, &has_pending_exception);
2396 EXCEPTION_BAILOUT_CHECK(false); 2410 EXCEPTION_BAILOUT_CHECK(isolate, false);
2397 return *result == i::Smi::FromInt(i::EQUAL); 2411 return *result == i::Smi::FromInt(i::EQUAL);
2398 } 2412 }
2399 2413
2400 2414
2401 bool Value::StrictEquals(Handle<Value> that) const { 2415 bool Value::StrictEquals(Handle<Value> that) const {
2402 i::Isolate* isolate = i::Isolate::Current(); 2416 i::Isolate* isolate = i::Isolate::Current();
2403 if (IsDeadCheck(isolate, "v8::Value::StrictEquals()") 2417 if (IsDeadCheck(isolate, "v8::Value::StrictEquals()")
2404 || EmptyCheck("v8::Value::StrictEquals()", this) 2418 || EmptyCheck("v8::Value::StrictEquals()", this)
2405 || EmptyCheck("v8::Value::StrictEquals()", that)) { 2419 || EmptyCheck("v8::Value::StrictEquals()", that)) {
2406 return false; 2420 return false;
(...skipping 17 matching lines...) Expand all
2424 i::String::cast(*obj)->Equals(i::String::cast(*other)); 2438 i::String::cast(*obj)->Equals(i::String::cast(*other));
2425 } else if (obj->IsUndefined() || obj->IsUndetectableObject()) { 2439 } else if (obj->IsUndefined() || obj->IsUndetectableObject()) {
2426 return other->IsUndefined() || other->IsUndetectableObject(); 2440 return other->IsUndefined() || other->IsUndetectableObject();
2427 } else { 2441 } else {
2428 return false; 2442 return false;
2429 } 2443 }
2430 } 2444 }
2431 2445
2432 2446
2433 uint32_t Value::Uint32Value() const { 2447 uint32_t Value::Uint32Value() const {
2434 i::Isolate* isolate = i::Isolate::Current();
2435 if (IsDeadCheck(isolate, "v8::Value::Uint32Value()")) return 0;
2436 LOG_API(isolate, "Uint32Value");
2437 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2448 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2438 if (obj->IsSmi()) { 2449 if (obj->IsSmi()) {
2439 return i::Smi::cast(*obj)->value(); 2450 return i::Smi::cast(*obj)->value();
2440 } else { 2451 } else {
2441 ENTER_V8; 2452 i::Isolate* isolate = i::Isolate::Current();
2442 EXCEPTION_PREAMBLE(); 2453 if (IsDeadCheck(isolate, "v8::Value::Uint32Value()")) return 0;
2454 LOG_API(isolate, "Uint32Value");
2455 ENTER_V8(isolate);
2456 EXCEPTION_PREAMBLE(isolate);
2443 i::Handle<i::Object> num = 2457 i::Handle<i::Object> num =
2444 i::Execution::ToUint32(obj, &has_pending_exception); 2458 i::Execution::ToUint32(obj, &has_pending_exception);
2445 EXCEPTION_BAILOUT_CHECK(0); 2459 EXCEPTION_BAILOUT_CHECK(isolate, 0);
2446 if (num->IsSmi()) { 2460 if (num->IsSmi()) {
2447 return i::Smi::cast(*num)->value(); 2461 return i::Smi::cast(*num)->value();
2448 } else { 2462 } else {
2449 return static_cast<uint32_t>(num->Number()); 2463 return static_cast<uint32_t>(num->Number());
2450 } 2464 }
2451 } 2465 }
2452 } 2466 }
2453 2467
2454 2468
2455 bool v8::Object::Set(v8::Handle<Value> key, v8::Handle<Value> value, 2469 bool v8::Object::Set(v8::Handle<Value> key, v8::Handle<Value> value,
2456 v8::PropertyAttribute attribs) { 2470 v8::PropertyAttribute attribs) {
2457 i::Isolate* isolate = i::Isolate::Current(); 2471 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2458 ON_BAILOUT(isolate, "v8::Object::Set()", return false); 2472 ON_BAILOUT(isolate, "v8::Object::Set()", return false);
2459 ENTER_V8; 2473 ENTER_V8(isolate);
2460 i::HandleScope scope(isolate); 2474 i::HandleScope scope(isolate);
2461 i::Handle<i::Object> self = Utils::OpenHandle(this); 2475 i::Handle<i::Object> self = Utils::OpenHandle(this);
2462 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 2476 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
2463 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); 2477 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
2464 EXCEPTION_PREAMBLE(); 2478 EXCEPTION_PREAMBLE(isolate);
2465 i::Handle<i::Object> obj = i::SetProperty( 2479 i::Handle<i::Object> obj = i::SetProperty(
2466 self, 2480 self,
2467 key_obj, 2481 key_obj,
2468 value_obj, 2482 value_obj,
2469 static_cast<PropertyAttributes>(attribs), 2483 static_cast<PropertyAttributes>(attribs),
2470 i::kNonStrictMode); 2484 i::kNonStrictMode);
2471 has_pending_exception = obj.is_null(); 2485 has_pending_exception = obj.is_null();
2472 EXCEPTION_BAILOUT_CHECK(false); 2486 EXCEPTION_BAILOUT_CHECK(isolate, false);
2473 return true; 2487 return true;
2474 } 2488 }
2475 2489
2476 2490
2477 bool v8::Object::Set(uint32_t index, v8::Handle<Value> value) { 2491 bool v8::Object::Set(uint32_t index, v8::Handle<Value> value) {
2478 i::Isolate* isolate = i::Isolate::Current(); 2492 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2479 ON_BAILOUT(isolate, "v8::Object::Set()", return false); 2493 ON_BAILOUT(isolate, "v8::Object::Set()", return false);
2480 ENTER_V8; 2494 ENTER_V8(isolate);
2481 i::HandleScope scope(isolate); 2495 i::HandleScope scope(isolate);
2482 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2496 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2483 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); 2497 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
2484 EXCEPTION_PREAMBLE(); 2498 EXCEPTION_PREAMBLE(isolate);
2485 i::Handle<i::Object> obj = i::SetElement( 2499 i::Handle<i::Object> obj = i::SetElement(
2486 self, 2500 self,
2487 index, 2501 index,
2488 value_obj, 2502 value_obj,
2489 i::kNonStrictMode); 2503 i::kNonStrictMode);
2490 has_pending_exception = obj.is_null(); 2504 has_pending_exception = obj.is_null();
2491 EXCEPTION_BAILOUT_CHECK(false); 2505 EXCEPTION_BAILOUT_CHECK(isolate, false);
2492 return true; 2506 return true;
2493 } 2507 }
2494 2508
2495 2509
2496 bool v8::Object::ForceSet(v8::Handle<Value> key, 2510 bool v8::Object::ForceSet(v8::Handle<Value> key,
2497 v8::Handle<Value> value, 2511 v8::Handle<Value> value,
2498 v8::PropertyAttribute attribs) { 2512 v8::PropertyAttribute attribs) {
2499 i::Isolate* isolate = i::Isolate::Current(); 2513 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2500 ON_BAILOUT(isolate, "v8::Object::ForceSet()", return false); 2514 ON_BAILOUT(isolate, "v8::Object::ForceSet()", return false);
2501 ENTER_V8; 2515 ENTER_V8(isolate);
2502 i::HandleScope scope(isolate); 2516 i::HandleScope scope(isolate);
2503 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2517 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2504 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 2518 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
2505 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); 2519 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
2506 EXCEPTION_PREAMBLE(); 2520 EXCEPTION_PREAMBLE(isolate);
2507 i::Handle<i::Object> obj = i::ForceSetProperty( 2521 i::Handle<i::Object> obj = i::ForceSetProperty(
2508 self, 2522 self,
2509 key_obj, 2523 key_obj,
2510 value_obj, 2524 value_obj,
2511 static_cast<PropertyAttributes>(attribs)); 2525 static_cast<PropertyAttributes>(attribs));
2512 has_pending_exception = obj.is_null(); 2526 has_pending_exception = obj.is_null();
2513 EXCEPTION_BAILOUT_CHECK(false); 2527 EXCEPTION_BAILOUT_CHECK(isolate, false);
2514 return true; 2528 return true;
2515 } 2529 }
2516 2530
2517 2531
2518 bool v8::Object::ForceDelete(v8::Handle<Value> key) { 2532 bool v8::Object::ForceDelete(v8::Handle<Value> key) {
2519 i::Isolate* isolate = i::Isolate::Current(); 2533 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2520 ON_BAILOUT(isolate, "v8::Object::ForceDelete()", return false); 2534 ON_BAILOUT(isolate, "v8::Object::ForceDelete()", return false);
2521 ENTER_V8; 2535 ENTER_V8(isolate);
2522 i::HandleScope scope(isolate); 2536 i::HandleScope scope(isolate);
2523 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2537 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2524 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 2538 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
2525 2539
2526 // When turning on access checks for a global object deoptimize all functions 2540 // When turning on access checks for a global object deoptimize all functions
2527 // as optimized code does not always handle access checks. 2541 // as optimized code does not always handle access checks.
2528 i::Deoptimizer::DeoptimizeGlobalObject(*self); 2542 i::Deoptimizer::DeoptimizeGlobalObject(*self);
2529 2543
2530 EXCEPTION_PREAMBLE(); 2544 EXCEPTION_PREAMBLE(isolate);
2531 i::Handle<i::Object> obj = i::ForceDeleteProperty(self, key_obj); 2545 i::Handle<i::Object> obj = i::ForceDeleteProperty(self, key_obj);
2532 has_pending_exception = obj.is_null(); 2546 has_pending_exception = obj.is_null();
2533 EXCEPTION_BAILOUT_CHECK(false); 2547 EXCEPTION_BAILOUT_CHECK(isolate, false);
2534 return obj->IsTrue(); 2548 return obj->IsTrue();
2535 } 2549 }
2536 2550
2537 2551
2538 Local<Value> v8::Object::Get(v8::Handle<Value> key) { 2552 Local<Value> v8::Object::Get(v8::Handle<Value> key) {
2539 i::Isolate* isolate = i::Isolate::Current(); 2553 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2540 ON_BAILOUT(isolate, "v8::Object::Get()", return Local<v8::Value>()); 2554 ON_BAILOUT(isolate, "v8::Object::Get()", return Local<v8::Value>());
2541 ENTER_V8; 2555 ENTER_V8(isolate);
2542 i::Handle<i::Object> self = Utils::OpenHandle(this); 2556 i::Handle<i::Object> self = Utils::OpenHandle(this);
2543 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 2557 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
2544 EXCEPTION_PREAMBLE(); 2558 EXCEPTION_PREAMBLE(isolate);
2545 i::Handle<i::Object> result = i::GetProperty(self, key_obj); 2559 i::Handle<i::Object> result = i::GetProperty(self, key_obj);
2546 has_pending_exception = result.is_null(); 2560 has_pending_exception = result.is_null();
2547 EXCEPTION_BAILOUT_CHECK(Local<Value>()); 2561 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
2548 return Utils::ToLocal(result); 2562 return Utils::ToLocal(result);
2549 } 2563 }
2550 2564
2551 2565
2552 Local<Value> v8::Object::Get(uint32_t index) { 2566 Local<Value> v8::Object::Get(uint32_t index) {
2553 i::Isolate* isolate = i::Isolate::Current(); 2567 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2554 ON_BAILOUT(isolate, "v8::Object::Get()", return Local<v8::Value>()); 2568 ON_BAILOUT(isolate, "v8::Object::Get()", return Local<v8::Value>());
2555 ENTER_V8; 2569 ENTER_V8(isolate);
2556 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2570 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2557 EXCEPTION_PREAMBLE(); 2571 EXCEPTION_PREAMBLE(isolate);
2558 i::Handle<i::Object> result = i::GetElement(self, index); 2572 i::Handle<i::Object> result = i::GetElement(self, index);
2559 has_pending_exception = result.is_null(); 2573 has_pending_exception = result.is_null();
2560 EXCEPTION_BAILOUT_CHECK(Local<Value>()); 2574 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
2561 return Utils::ToLocal(result); 2575 return Utils::ToLocal(result);
2562 } 2576 }
2563 2577
2564 2578
2565 Local<Value> v8::Object::GetPrototype() { 2579 Local<Value> v8::Object::GetPrototype() {
2566 ON_BAILOUT(i::Isolate::Current(), "v8::Object::GetPrototype()", 2580 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2581 ON_BAILOUT(isolate, "v8::Object::GetPrototype()",
2567 return Local<v8::Value>()); 2582 return Local<v8::Value>());
2568 ENTER_V8; 2583 ENTER_V8(isolate);
2569 i::Handle<i::Object> self = Utils::OpenHandle(this); 2584 i::Handle<i::Object> self = Utils::OpenHandle(this);
2570 i::Handle<i::Object> result = i::GetPrototype(self); 2585 i::Handle<i::Object> result = i::GetPrototype(self);
2571 return Utils::ToLocal(result); 2586 return Utils::ToLocal(result);
2572 } 2587 }
2573 2588
2574 2589
2575 bool v8::Object::SetPrototype(Handle<Value> value) { 2590 bool v8::Object::SetPrototype(Handle<Value> value) {
2576 i::Isolate* isolate = i::Isolate::Current(); 2591 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2577 ON_BAILOUT(isolate, "v8::Object::SetPrototype()", return false); 2592 ON_BAILOUT(isolate, "v8::Object::SetPrototype()", return false);
2578 ENTER_V8; 2593 ENTER_V8(isolate);
2579 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2594 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2580 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); 2595 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
2581 EXCEPTION_PREAMBLE(); 2596 EXCEPTION_PREAMBLE(isolate);
2582 i::Handle<i::Object> result = i::SetPrototype(self, value_obj); 2597 i::Handle<i::Object> result = i::SetPrototype(self, value_obj);
2583 has_pending_exception = result.is_null(); 2598 has_pending_exception = result.is_null();
2584 EXCEPTION_BAILOUT_CHECK(false); 2599 EXCEPTION_BAILOUT_CHECK(isolate, false);
2585 return true; 2600 return true;
2586 } 2601 }
2587 2602
2588 2603
2589 Local<Object> v8::Object::FindInstanceInPrototypeChain( 2604 Local<Object> v8::Object::FindInstanceInPrototypeChain(
2590 v8::Handle<FunctionTemplate> tmpl) { 2605 v8::Handle<FunctionTemplate> tmpl) {
2591 ON_BAILOUT(i::Isolate::Current(), 2606 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2607 ON_BAILOUT(isolate,
2592 "v8::Object::FindInstanceInPrototypeChain()", 2608 "v8::Object::FindInstanceInPrototypeChain()",
2593 return Local<v8::Object>()); 2609 return Local<v8::Object>());
2594 ENTER_V8; 2610 ENTER_V8(isolate);
2595 i::JSObject* object = *Utils::OpenHandle(this); 2611 i::JSObject* object = *Utils::OpenHandle(this);
2596 i::FunctionTemplateInfo* tmpl_info = *Utils::OpenHandle(*tmpl); 2612 i::FunctionTemplateInfo* tmpl_info = *Utils::OpenHandle(*tmpl);
2597 while (!object->IsInstanceOf(tmpl_info)) { 2613 while (!object->IsInstanceOf(tmpl_info)) {
2598 i::Object* prototype = object->GetPrototype(); 2614 i::Object* prototype = object->GetPrototype();
2599 if (!prototype->IsJSObject()) return Local<Object>(); 2615 if (!prototype->IsJSObject()) return Local<Object>();
2600 object = i::JSObject::cast(prototype); 2616 object = i::JSObject::cast(prototype);
2601 } 2617 }
2602 return Utils::ToLocal(i::Handle<i::JSObject>(object)); 2618 return Utils::ToLocal(i::Handle<i::JSObject>(object));
2603 } 2619 }
2604 2620
2605 2621
2606 Local<Array> v8::Object::GetPropertyNames() { 2622 Local<Array> v8::Object::GetPropertyNames() {
2607 ON_BAILOUT(i::Isolate::Current(), "v8::Object::GetPropertyNames()", 2623 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2624 ON_BAILOUT(isolate, "v8::Object::GetPropertyNames()",
2608 return Local<v8::Array>()); 2625 return Local<v8::Array>());
2609 ENTER_V8; 2626 ENTER_V8(isolate);
2610 v8::HandleScope scope; 2627 v8::HandleScope scope;
2611 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2628 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2612 i::Handle<i::FixedArray> value = 2629 i::Handle<i::FixedArray> value =
2613 i::GetKeysInFixedArrayFor(self, i::INCLUDE_PROTOS); 2630 i::GetKeysInFixedArrayFor(self, i::INCLUDE_PROTOS);
2614 // Because we use caching to speed up enumeration it is important 2631 // Because we use caching to speed up enumeration it is important
2615 // to never change the result of the basic enumeration function so 2632 // to never change the result of the basic enumeration function so
2616 // we clone the result. 2633 // we clone the result.
2617 i::Handle<i::FixedArray> elms = FACTORY->CopyFixedArray(value); 2634 i::Handle<i::FixedArray> elms = FACTORY->CopyFixedArray(value);
2618 i::Handle<i::JSArray> result = FACTORY->NewJSArrayWithElements(elms); 2635 i::Handle<i::JSArray> result = FACTORY->NewJSArrayWithElements(elms);
2619 return scope.Close(Utils::ToLocal(result)); 2636 return scope.Close(Utils::ToLocal(result));
2620 } 2637 }
2621 2638
2622 2639
2623 Local<String> v8::Object::ObjectProtoToString() { 2640 Local<String> v8::Object::ObjectProtoToString() {
2624 ON_BAILOUT(i::Isolate::Current(), "v8::Object::ObjectProtoToString()", 2641 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2642 ON_BAILOUT(isolate, "v8::Object::ObjectProtoToString()",
2625 return Local<v8::String>()); 2643 return Local<v8::String>());
2626 ENTER_V8; 2644 ENTER_V8(isolate);
2627 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2645 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2628 2646
2629 i::Handle<i::Object> name(self->class_name()); 2647 i::Handle<i::Object> name(self->class_name());
2630 2648
2631 // Native implementation of Object.prototype.toString (v8natives.js): 2649 // Native implementation of Object.prototype.toString (v8natives.js):
2632 // var c = %ClassOf(this); 2650 // var c = %ClassOf(this);
2633 // if (c === 'Arguments') c = 'Object'; 2651 // if (c === 'Arguments') c = 'Object';
2634 // return "[object " + c + "]"; 2652 // return "[object " + c + "]";
2635 2653
2636 if (!name->IsString()) { 2654 if (!name->IsString()) {
(...skipping 30 matching lines...) Expand all
2667 2685
2668 // Copy the buffer into a heap-allocated string and return it. 2686 // Copy the buffer into a heap-allocated string and return it.
2669 Local<String> result = v8::String::New(buf.start(), buf_len); 2687 Local<String> result = v8::String::New(buf.start(), buf_len);
2670 return result; 2688 return result;
2671 } 2689 }
2672 } 2690 }
2673 } 2691 }
2674 2692
2675 2693
2676 Local<String> v8::Object::GetConstructorName() { 2694 Local<String> v8::Object::GetConstructorName() {
2677 i::Isolate* isolate = i::Isolate::Current(); 2695 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2678 ON_BAILOUT(isolate, "v8::Object::GetConstructorName()", 2696 ON_BAILOUT(isolate, "v8::Object::GetConstructorName()",
2679 return Local<v8::String>()); 2697 return Local<v8::String>());
2680 ENTER_V8; 2698 ENTER_V8(isolate);
2681 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2699 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2682 i::Handle<i::String> name(self->constructor_name()); 2700 i::Handle<i::String> name(self->constructor_name());
2683 return Utils::ToLocal(name); 2701 return Utils::ToLocal(name);
2684 } 2702 }
2685 2703
2686 2704
2687 bool v8::Object::Delete(v8::Handle<String> key) { 2705 bool v8::Object::Delete(v8::Handle<String> key) {
2688 i::Isolate* isolate = i::Isolate::Current(); 2706 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2689 ON_BAILOUT(isolate, "v8::Object::Delete()", return false); 2707 ON_BAILOUT(isolate, "v8::Object::Delete()", return false);
2690 ENTER_V8; 2708 ENTER_V8(isolate);
2691 i::HandleScope scope(isolate); 2709 i::HandleScope scope(isolate);
2692 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2710 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2693 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 2711 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
2694 return i::DeleteProperty(self, key_obj)->IsTrue(); 2712 return i::DeleteProperty(self, key_obj)->IsTrue();
2695 } 2713 }
2696 2714
2697 2715
2698 bool v8::Object::Has(v8::Handle<String> key) { 2716 bool v8::Object::Has(v8::Handle<String> key) {
2699 ON_BAILOUT(i::Isolate::Current(), "v8::Object::Has()", return false); 2717 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2700 ENTER_V8; 2718 ON_BAILOUT(isolate, "v8::Object::Has()", return false);
2719 ENTER_V8(isolate);
2701 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2720 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2702 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 2721 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
2703 return self->HasProperty(*key_obj); 2722 return self->HasProperty(*key_obj);
2704 } 2723 }
2705 2724
2706 2725
2707 bool v8::Object::Delete(uint32_t index) { 2726 bool v8::Object::Delete(uint32_t index) {
2708 ON_BAILOUT(i::Isolate::Current(), "v8::Object::DeleteProperty()", 2727 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2728 ON_BAILOUT(isolate, "v8::Object::DeleteProperty()",
2709 return false); 2729 return false);
2710 ENTER_V8; 2730 ENTER_V8(isolate);
2711 HandleScope scope; 2731 HandleScope scope;
2712 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2732 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2713 return i::DeleteElement(self, index)->IsTrue(); 2733 return i::DeleteElement(self, index)->IsTrue();
2714 } 2734 }
2715 2735
2716 2736
2717 bool v8::Object::Has(uint32_t index) { 2737 bool v8::Object::Has(uint32_t index) {
2718 ON_BAILOUT(i::Isolate::Current(), "v8::Object::HasProperty()", return false); 2738 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2739 ON_BAILOUT(isolate, "v8::Object::HasProperty()", return false);
2719 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2740 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2720 return self->HasElement(index); 2741 return self->HasElement(index);
2721 } 2742 }
2722 2743
2723 2744
2724 bool Object::SetAccessor(Handle<String> name, 2745 bool Object::SetAccessor(Handle<String> name,
2725 AccessorGetter getter, 2746 AccessorGetter getter,
2726 AccessorSetter setter, 2747 AccessorSetter setter,
2727 v8::Handle<Value> data, 2748 v8::Handle<Value> data,
2728 AccessControl settings, 2749 AccessControl settings,
2729 PropertyAttribute attributes) { 2750 PropertyAttribute attributes) {
2730 i::Isolate* isolate = i::Isolate::Current(); 2751 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2731 ON_BAILOUT(isolate, "v8::Object::SetAccessor()", return false); 2752 ON_BAILOUT(isolate, "v8::Object::SetAccessor()", return false);
2732 ENTER_V8; 2753 ENTER_V8(isolate);
2733 i::HandleScope scope(isolate); 2754 i::HandleScope scope(isolate);
2734 i::Handle<i::AccessorInfo> info = MakeAccessorInfo(name, 2755 i::Handle<i::AccessorInfo> info = MakeAccessorInfo(name,
2735 getter, setter, data, 2756 getter, setter, data,
2736 settings, attributes); 2757 settings, attributes);
2737 i::Handle<i::Object> result = i::SetAccessor(Utils::OpenHandle(this), info); 2758 i::Handle<i::Object> result = i::SetAccessor(Utils::OpenHandle(this), info);
2738 return !result.is_null() && !result->IsUndefined(); 2759 return !result.is_null() && !result->IsUndefined();
2739 } 2760 }
2740 2761
2741 2762
2742 bool v8::Object::HasRealNamedProperty(Handle<String> key) { 2763 bool v8::Object::HasRealNamedProperty(Handle<String> key) {
2743 ON_BAILOUT(i::Isolate::Current(), "v8::Object::HasRealNamedProperty()", 2764 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2765 ON_BAILOUT(isolate, "v8::Object::HasRealNamedProperty()",
2744 return false); 2766 return false);
2745 return Utils::OpenHandle(this)->HasRealNamedProperty( 2767 return Utils::OpenHandle(this)->HasRealNamedProperty(
2746 *Utils::OpenHandle(*key)); 2768 *Utils::OpenHandle(*key));
2747 } 2769 }
2748 2770
2749 2771
2750 bool v8::Object::HasRealIndexedProperty(uint32_t index) { 2772 bool v8::Object::HasRealIndexedProperty(uint32_t index) {
2751 ON_BAILOUT(i::Isolate::Current(), "v8::Object::HasRealIndexedProperty()", 2773 ON_BAILOUT(Utils::OpenHandle(this)->GetIsolate(),
2774 "v8::Object::HasRealIndexedProperty()",
2752 return false); 2775 return false);
2753 return Utils::OpenHandle(this)->HasRealElementProperty(index); 2776 return Utils::OpenHandle(this)->HasRealElementProperty(index);
2754 } 2777 }
2755 2778
2756 2779
2757 bool v8::Object::HasRealNamedCallbackProperty(Handle<String> key) { 2780 bool v8::Object::HasRealNamedCallbackProperty(Handle<String> key) {
2758 ON_BAILOUT(i::Isolate::Current(), 2781 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2782 ON_BAILOUT(isolate,
2759 "v8::Object::HasRealNamedCallbackProperty()", 2783 "v8::Object::HasRealNamedCallbackProperty()",
2760 return false); 2784 return false);
2761 ENTER_V8; 2785 ENTER_V8(isolate);
2762 return Utils::OpenHandle(this)->HasRealNamedCallbackProperty( 2786 return Utils::OpenHandle(this)->HasRealNamedCallbackProperty(
2763 *Utils::OpenHandle(*key)); 2787 *Utils::OpenHandle(*key));
2764 } 2788 }
2765 2789
2766 2790
2767 bool v8::Object::HasNamedLookupInterceptor() { 2791 bool v8::Object::HasNamedLookupInterceptor() {
2768 ON_BAILOUT(i::Isolate::Current(), "v8::Object::HasNamedLookupInterceptor()", 2792 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2793 ON_BAILOUT(isolate, "v8::Object::HasNamedLookupInterceptor()",
2769 return false); 2794 return false);
2770 return Utils::OpenHandle(this)->HasNamedInterceptor(); 2795 return Utils::OpenHandle(this)->HasNamedInterceptor();
2771 } 2796 }
2772 2797
2773 2798
2774 bool v8::Object::HasIndexedLookupInterceptor() { 2799 bool v8::Object::HasIndexedLookupInterceptor() {
2775 ON_BAILOUT(i::Isolate::Current(), "v8::Object::HasIndexedLookupInterceptor()", 2800 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2801 ON_BAILOUT(isolate, "v8::Object::HasIndexedLookupInterceptor()",
2776 return false); 2802 return false);
2777 return Utils::OpenHandle(this)->HasIndexedInterceptor(); 2803 return Utils::OpenHandle(this)->HasIndexedInterceptor();
2778 } 2804 }
2779 2805
2780 2806
2781 Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( 2807 Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain(
2782 Handle<String> key) { 2808 Handle<String> key) {
2783 ON_BAILOUT(i::Isolate::Current(), 2809 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2810 ON_BAILOUT(isolate,
2784 "v8::Object::GetRealNamedPropertyInPrototypeChain()", 2811 "v8::Object::GetRealNamedPropertyInPrototypeChain()",
2785 return Local<Value>()); 2812 return Local<Value>());
2786 ENTER_V8; 2813 ENTER_V8(isolate);
2787 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); 2814 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this);
2788 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 2815 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
2789 i::LookupResult lookup; 2816 i::LookupResult lookup;
2790 self_obj->LookupRealNamedPropertyInPrototypes(*key_obj, &lookup); 2817 self_obj->LookupRealNamedPropertyInPrototypes(*key_obj, &lookup);
2791 if (lookup.IsProperty()) { 2818 if (lookup.IsProperty()) {
2792 PropertyAttributes attributes; 2819 PropertyAttributes attributes;
2793 i::Object* property = 2820 i::Object* property =
2794 self_obj->GetProperty(*self_obj, 2821 self_obj->GetProperty(*self_obj,
2795 &lookup, 2822 &lookup,
2796 *key_obj, 2823 *key_obj,
2797 &attributes)->ToObjectUnchecked(); 2824 &attributes)->ToObjectUnchecked();
2798 i::Handle<i::Object> result(property); 2825 i::Handle<i::Object> result(property);
2799 return Utils::ToLocal(result); 2826 return Utils::ToLocal(result);
2800 } 2827 }
2801 return Local<Value>(); // No real property was found in prototype chain. 2828 return Local<Value>(); // No real property was found in prototype chain.
2802 } 2829 }
2803 2830
2804 2831
2805 Local<Value> v8::Object::GetRealNamedProperty(Handle<String> key) { 2832 Local<Value> v8::Object::GetRealNamedProperty(Handle<String> key) {
2806 ON_BAILOUT(i::Isolate::Current(), "v8::Object::GetRealNamedProperty()", 2833 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2834 ON_BAILOUT(isolate, "v8::Object::GetRealNamedProperty()",
2807 return Local<Value>()); 2835 return Local<Value>());
2808 ENTER_V8; 2836 ENTER_V8(isolate);
2809 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); 2837 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this);
2810 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 2838 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
2811 i::LookupResult lookup; 2839 i::LookupResult lookup;
2812 self_obj->LookupRealNamedProperty(*key_obj, &lookup); 2840 self_obj->LookupRealNamedProperty(*key_obj, &lookup);
2813 if (lookup.IsProperty()) { 2841 if (lookup.IsProperty()) {
2814 PropertyAttributes attributes; 2842 PropertyAttributes attributes;
2815 i::Object* property = 2843 i::Object* property =
2816 self_obj->GetProperty(*self_obj, 2844 self_obj->GetProperty(*self_obj,
2817 &lookup, 2845 &lookup,
2818 *key_obj, 2846 *key_obj,
2819 &attributes)->ToObjectUnchecked(); 2847 &attributes)->ToObjectUnchecked();
2820 i::Handle<i::Object> result(property); 2848 i::Handle<i::Object> result(property);
2821 return Utils::ToLocal(result); 2849 return Utils::ToLocal(result);
2822 } 2850 }
2823 return Local<Value>(); // No real property was found in prototype chain. 2851 return Local<Value>(); // No real property was found in prototype chain.
2824 } 2852 }
2825 2853
2826 2854
2827 // Turns on access checks by copying the map and setting the check flag. 2855 // Turns on access checks by copying the map and setting the check flag.
2828 // Because the object gets a new map, existing inline cache caching 2856 // Because the object gets a new map, existing inline cache caching
2829 // the old map of this object will fail. 2857 // the old map of this object will fail.
2830 void v8::Object::TurnOnAccessCheck() { 2858 void v8::Object::TurnOnAccessCheck() {
2831 i::Isolate* isolate = i::Isolate::Current(); 2859 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2832 ON_BAILOUT(isolate, "v8::Object::TurnOnAccessCheck()", return); 2860 ON_BAILOUT(isolate, "v8::Object::TurnOnAccessCheck()", return);
2833 ENTER_V8; 2861 ENTER_V8(isolate);
2834 i::HandleScope scope(isolate); 2862 i::HandleScope scope(isolate);
2835 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); 2863 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
2836 2864
2837 // When turning on access checks for a global object deoptimize all functions 2865 // When turning on access checks for a global object deoptimize all functions
2838 // as optimized code does not always handle access checks. 2866 // as optimized code does not always handle access checks.
2839 i::Deoptimizer::DeoptimizeGlobalObject(*obj); 2867 i::Deoptimizer::DeoptimizeGlobalObject(*obj);
2840 2868
2841 i::Handle<i::Map> new_map = 2869 i::Handle<i::Map> new_map =
2842 FACTORY->CopyMapDropTransitions(i::Handle<i::Map>(obj->map())); 2870 isolate->factory()->CopyMapDropTransitions(i::Handle<i::Map>(obj->map()));
2843 new_map->set_is_access_check_needed(true); 2871 new_map->set_is_access_check_needed(true);
2844 obj->set_map(*new_map); 2872 obj->set_map(*new_map);
2845 } 2873 }
2846 2874
2847 2875
2848 bool v8::Object::IsDirty() { 2876 bool v8::Object::IsDirty() {
2849 return Utils::OpenHandle(this)->IsDirty(); 2877 return Utils::OpenHandle(this)->IsDirty();
2850 } 2878 }
2851 2879
2852 2880
2853 Local<v8::Object> v8::Object::Clone() { 2881 Local<v8::Object> v8::Object::Clone() {
2854 i::Isolate* isolate = i::Isolate::Current(); 2882 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2855 ON_BAILOUT(isolate, "v8::Object::Clone()", return Local<Object>()); 2883 ON_BAILOUT(isolate, "v8::Object::Clone()", return Local<Object>());
2856 ENTER_V8; 2884 ENTER_V8(isolate);
2857 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2885 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2858 EXCEPTION_PREAMBLE(); 2886 EXCEPTION_PREAMBLE(isolate);
2859 i::Handle<i::JSObject> result = i::Copy(self); 2887 i::Handle<i::JSObject> result = i::Copy(self);
2860 has_pending_exception = result.is_null(); 2888 has_pending_exception = result.is_null();
2861 EXCEPTION_BAILOUT_CHECK(Local<Object>()); 2889 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>());
2862 return Utils::ToLocal(result); 2890 return Utils::ToLocal(result);
2863 } 2891 }
2864 2892
2865 2893
2866 int v8::Object::GetIdentityHash() { 2894 int v8::Object::GetIdentityHash() {
2867 i::Isolate* isolate = i::Isolate::Current(); 2895 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2868 ON_BAILOUT(isolate, "v8::Object::GetIdentityHash()", return 0); 2896 ON_BAILOUT(isolate, "v8::Object::GetIdentityHash()", return 0);
2869 ENTER_V8; 2897 ENTER_V8(isolate);
2870 i::HandleScope scope(isolate); 2898 i::HandleScope scope(isolate);
2871 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2899 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2872 i::Handle<i::Object> hidden_props_obj(i::GetHiddenProperties(self, true)); 2900 i::Handle<i::Object> hidden_props_obj(i::GetHiddenProperties(self, true));
2873 if (!hidden_props_obj->IsJSObject()) { 2901 if (!hidden_props_obj->IsJSObject()) {
2874 // We failed to create hidden properties. That's a detached 2902 // We failed to create hidden properties. That's a detached
2875 // global proxy. 2903 // global proxy.
2876 ASSERT(hidden_props_obj->IsUndefined()); 2904 ASSERT(hidden_props_obj->IsUndefined());
2877 return 0; 2905 return 0;
2878 } 2906 }
2879 i::Handle<i::JSObject> hidden_props = 2907 i::Handle<i::JSObject> hidden_props =
(...skipping 20 matching lines...) Expand all
2900 hash_symbol, 2928 hash_symbol,
2901 i::Handle<i::Object>(i::Smi::FromInt(hash_value)), 2929 i::Handle<i::Object>(i::Smi::FromInt(hash_value)),
2902 static_cast<PropertyAttributes>(None)).is_null()); 2930 static_cast<PropertyAttributes>(None)).is_null());
2903 2931
2904 return hash_value; 2932 return hash_value;
2905 } 2933 }
2906 2934
2907 2935
2908 bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key, 2936 bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key,
2909 v8::Handle<v8::Value> value) { 2937 v8::Handle<v8::Value> value) {
2910 i::Isolate* isolate = i::Isolate::Current(); 2938 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2911 ON_BAILOUT(isolate, "v8::Object::SetHiddenValue()", return false); 2939 ON_BAILOUT(isolate, "v8::Object::SetHiddenValue()", return false);
2912 ENTER_V8; 2940 ENTER_V8(isolate);
2913 i::HandleScope scope(isolate); 2941 i::HandleScope scope(isolate);
2914 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2942 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2915 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, true)); 2943 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, true));
2916 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 2944 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
2917 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); 2945 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
2918 EXCEPTION_PREAMBLE(); 2946 EXCEPTION_PREAMBLE(isolate);
2919 i::Handle<i::Object> obj = i::SetProperty( 2947 i::Handle<i::Object> obj = i::SetProperty(
2920 hidden_props, 2948 hidden_props,
2921 key_obj, 2949 key_obj,
2922 value_obj, 2950 value_obj,
2923 static_cast<PropertyAttributes>(None), 2951 static_cast<PropertyAttributes>(None),
2924 i::kNonStrictMode); 2952 i::kNonStrictMode);
2925 has_pending_exception = obj.is_null(); 2953 has_pending_exception = obj.is_null();
2926 EXCEPTION_BAILOUT_CHECK(false); 2954 EXCEPTION_BAILOUT_CHECK(isolate, false);
2927 return true; 2955 return true;
2928 } 2956 }
2929 2957
2930 2958
2931 v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Handle<v8::String> key) { 2959 v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Handle<v8::String> key) {
2932 i::Isolate* isolate = i::Isolate::Current(); 2960 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2933 ON_BAILOUT(isolate, "v8::Object::GetHiddenValue()", 2961 ON_BAILOUT(isolate, "v8::Object::GetHiddenValue()",
2934 return Local<v8::Value>()); 2962 return Local<v8::Value>());
2935 ENTER_V8; 2963 ENTER_V8(isolate);
2936 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2964 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2937 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, false)); 2965 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, false));
2938 if (hidden_props->IsUndefined()) { 2966 if (hidden_props->IsUndefined()) {
2939 return v8::Local<v8::Value>(); 2967 return v8::Local<v8::Value>();
2940 } 2968 }
2941 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 2969 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
2942 EXCEPTION_PREAMBLE(); 2970 EXCEPTION_PREAMBLE(isolate);
2943 i::Handle<i::Object> result = i::GetProperty(hidden_props, key_obj); 2971 i::Handle<i::Object> result = i::GetProperty(hidden_props, key_obj);
2944 has_pending_exception = result.is_null(); 2972 has_pending_exception = result.is_null();
2945 EXCEPTION_BAILOUT_CHECK(v8::Local<v8::Value>()); 2973 EXCEPTION_BAILOUT_CHECK(isolate, v8::Local<v8::Value>());
2946 if (result->IsUndefined()) { 2974 if (result->IsUndefined()) {
2947 return v8::Local<v8::Value>(); 2975 return v8::Local<v8::Value>();
2948 } 2976 }
2949 return Utils::ToLocal(result); 2977 return Utils::ToLocal(result);
2950 } 2978 }
2951 2979
2952 2980
2953 bool v8::Object::DeleteHiddenValue(v8::Handle<v8::String> key) { 2981 bool v8::Object::DeleteHiddenValue(v8::Handle<v8::String> key) {
2954 i::Isolate* isolate = i::Isolate::Current(); 2982 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2955 ON_BAILOUT(isolate, "v8::DeleteHiddenValue()", return false); 2983 ON_BAILOUT(isolate, "v8::DeleteHiddenValue()", return false);
2956 ENTER_V8; 2984 ENTER_V8(isolate);
2957 i::HandleScope scope(isolate); 2985 i::HandleScope scope(isolate);
2958 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2986 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2959 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, false)); 2987 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, false));
2960 if (hidden_props->IsUndefined()) { 2988 if (hidden_props->IsUndefined()) {
2961 return true; 2989 return true;
2962 } 2990 }
2963 i::Handle<i::JSObject> js_obj(i::JSObject::cast(*hidden_props)); 2991 i::Handle<i::JSObject> js_obj(i::JSObject::cast(*hidden_props));
2964 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 2992 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
2965 return i::DeleteProperty(js_obj, key_obj)->IsTrue(); 2993 return i::DeleteProperty(js_obj, key_obj)->IsTrue();
2966 } 2994 }
2967 2995
2968 2996
2969 namespace { 2997 namespace {
2970 2998
2971 void PrepareExternalArrayElements(i::Handle<i::JSObject> object, 2999 void PrepareExternalArrayElements(i::Handle<i::JSObject> object,
2972 void* data, 3000 void* data,
2973 ExternalArrayType array_type, 3001 ExternalArrayType array_type,
2974 int length) { 3002 int length) {
3003 i::Isolate* isolate = object->GetIsolate();
2975 i::Handle<i::ExternalArray> array = 3004 i::Handle<i::ExternalArray> array =
2976 FACTORY->NewExternalArray(length, array_type, data); 3005 isolate->factory()->NewExternalArray(length, array_type, data);
2977 3006
2978 // If the object already has external elements, create a new, unique 3007 // If the object already has external elements, create a new, unique
2979 // map if the element type is now changing, because assumptions about 3008 // map if the element type is now changing, because assumptions about
2980 // generated code based on the receiver's map will be invalid. 3009 // generated code based on the receiver's map will be invalid.
2981 i::Handle<i::HeapObject> elements(object->elements()); 3010 i::Handle<i::HeapObject> elements(object->elements());
2982 bool force_unique_map = 3011 bool force_unique_map =
2983 elements->map()->IsUndefined() || 3012 elements->map()->IsUndefined() ||
2984 !elements->map()->has_external_array_elements() || 3013 !elements->map()->has_external_array_elements() ||
2985 elements->map() != HEAP->MapForExternalArrayType(array_type); 3014 elements->map() != HEAP->MapForExternalArrayType(array_type);
2986 if (force_unique_map) { 3015 if (force_unique_map) {
2987 i::Handle<i::Map> external_array_map = 3016 i::Handle<i::Map> external_array_map =
2988 FACTORY->NewExternalArrayElementsMap( 3017 isolate->factory()->NewExternalArrayElementsMap(
2989 i::Handle<i::Map>(object->map())); 3018 i::Handle<i::Map>(object->map()));
2990 object->set_map(*external_array_map); 3019 object->set_map(*external_array_map);
2991 } 3020 }
2992 object->set_elements(*array); 3021 object->set_elements(*array);
2993 } 3022 }
2994 3023
2995 } // namespace 3024 } // namespace
2996 3025
2997 3026
2998 void v8::Object::SetIndexedPropertiesToPixelData(uint8_t* data, int length) { 3027 void v8::Object::SetIndexedPropertiesToPixelData(uint8_t* data, int length) {
2999 i::Isolate* isolate = i::Isolate::Current(); 3028 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3000 ON_BAILOUT(isolate, "v8::SetElementsToPixelData()", return); 3029 ON_BAILOUT(isolate, "v8::SetElementsToPixelData()", return);
3001 ENTER_V8; 3030 ENTER_V8(isolate);
3002 i::HandleScope scope(isolate); 3031 i::HandleScope scope(isolate);
3003 if (!ApiCheck(length <= i::ExternalPixelArray::kMaxLength, 3032 if (!ApiCheck(length <= i::ExternalPixelArray::kMaxLength,
3004 "v8::Object::SetIndexedPropertiesToPixelData()", 3033 "v8::Object::SetIndexedPropertiesToPixelData()",
3005 "length exceeds max acceptable value")) { 3034 "length exceeds max acceptable value")) {
3006 return; 3035 return;
3007 } 3036 }
3008 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3037 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3009 if (!ApiCheck(!self->IsJSArray(), 3038 if (!ApiCheck(!self->IsJSArray(),
3010 "v8::Object::SetIndexedPropertiesToPixelData()", 3039 "v8::Object::SetIndexedPropertiesToPixelData()",
3011 "JSArray is not supported")) { 3040 "JSArray is not supported")) {
3012 return; 3041 return;
3013 } 3042 }
3014 PrepareExternalArrayElements(self, data, kExternalPixelArray, length); 3043 PrepareExternalArrayElements(self, data, kExternalPixelArray, length);
3015 } 3044 }
3016 3045
3017 3046
3018 bool v8::Object::HasIndexedPropertiesInPixelData() { 3047 bool v8::Object::HasIndexedPropertiesInPixelData() {
3019 ON_BAILOUT(i::Isolate::Current(), "v8::HasIndexedPropertiesInPixelData()", 3048 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3049 ON_BAILOUT(self->GetIsolate(), "v8::HasIndexedPropertiesInPixelData()",
3020 return false); 3050 return false);
3021 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3022 return self->HasExternalPixelElements(); 3051 return self->HasExternalPixelElements();
3023 } 3052 }
3024 3053
3025 3054
3026 uint8_t* v8::Object::GetIndexedPropertiesPixelData() { 3055 uint8_t* v8::Object::GetIndexedPropertiesPixelData() {
3027 ON_BAILOUT(i::Isolate::Current(), "v8::GetIndexedPropertiesPixelData()", 3056 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3057 ON_BAILOUT(self->GetIsolate(), "v8::GetIndexedPropertiesPixelData()",
3028 return NULL); 3058 return NULL);
3029 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3030 if (self->HasExternalPixelElements()) { 3059 if (self->HasExternalPixelElements()) {
3031 return i::ExternalPixelArray::cast(self->elements())-> 3060 return i::ExternalPixelArray::cast(self->elements())->
3032 external_pixel_pointer(); 3061 external_pixel_pointer();
3033 } else { 3062 } else {
3034 return NULL; 3063 return NULL;
3035 } 3064 }
3036 } 3065 }
3037 3066
3038 3067
3039 int v8::Object::GetIndexedPropertiesPixelDataLength() { 3068 int v8::Object::GetIndexedPropertiesPixelDataLength() {
3040 ON_BAILOUT(i::Isolate::Current(), "v8::GetIndexedPropertiesPixelDataLength()", 3069 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3070 ON_BAILOUT(self->GetIsolate(), "v8::GetIndexedPropertiesPixelDataLength()",
3041 return -1); 3071 return -1);
3042 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3043 if (self->HasExternalPixelElements()) { 3072 if (self->HasExternalPixelElements()) {
3044 return i::ExternalPixelArray::cast(self->elements())->length(); 3073 return i::ExternalPixelArray::cast(self->elements())->length();
3045 } else { 3074 } else {
3046 return -1; 3075 return -1;
3047 } 3076 }
3048 } 3077 }
3049 3078
3050 void v8::Object::SetIndexedPropertiesToExternalArrayData( 3079 void v8::Object::SetIndexedPropertiesToExternalArrayData(
3051 void* data, 3080 void* data,
3052 ExternalArrayType array_type, 3081 ExternalArrayType array_type,
3053 int length) { 3082 int length) {
3054 i::Isolate* isolate = i::Isolate::Current(); 3083 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3055 ON_BAILOUT(isolate, "v8::SetIndexedPropertiesToExternalArrayData()", return); 3084 ON_BAILOUT(isolate, "v8::SetIndexedPropertiesToExternalArrayData()", return);
3056 ENTER_V8; 3085 ENTER_V8(isolate);
3057 i::HandleScope scope(isolate); 3086 i::HandleScope scope(isolate);
3058 if (!ApiCheck(length <= i::ExternalArray::kMaxLength, 3087 if (!ApiCheck(length <= i::ExternalArray::kMaxLength,
3059 "v8::Object::SetIndexedPropertiesToExternalArrayData()", 3088 "v8::Object::SetIndexedPropertiesToExternalArrayData()",
3060 "length exceeds max acceptable value")) { 3089 "length exceeds max acceptable value")) {
3061 return; 3090 return;
3062 } 3091 }
3063 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3092 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3064 if (!ApiCheck(!self->IsJSArray(), 3093 if (!ApiCheck(!self->IsJSArray(),
3065 "v8::Object::SetIndexedPropertiesToExternalArrayData()", 3094 "v8::Object::SetIndexedPropertiesToExternalArrayData()",
3066 "JSArray is not supported")) { 3095 "JSArray is not supported")) {
3067 return; 3096 return;
3068 } 3097 }
3069 PrepareExternalArrayElements(self, data, array_type, length); 3098 PrepareExternalArrayElements(self, data, array_type, length);
3070 } 3099 }
3071 3100
3072 3101
3073 bool v8::Object::HasIndexedPropertiesInExternalArrayData() { 3102 bool v8::Object::HasIndexedPropertiesInExternalArrayData() {
3074 ON_BAILOUT(i::Isolate::Current(), 3103 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3104 ON_BAILOUT(self->GetIsolate(),
3075 "v8::HasIndexedPropertiesInExternalArrayData()", 3105 "v8::HasIndexedPropertiesInExternalArrayData()",
3076 return false); 3106 return false);
3077 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3078 return self->HasExternalArrayElements(); 3107 return self->HasExternalArrayElements();
3079 } 3108 }
3080 3109
3081 3110
3082 void* v8::Object::GetIndexedPropertiesExternalArrayData() { 3111 void* v8::Object::GetIndexedPropertiesExternalArrayData() {
3083 ON_BAILOUT(i::Isolate::Current(), 3112 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3113 ON_BAILOUT(self->GetIsolate(),
3084 "v8::GetIndexedPropertiesExternalArrayData()", 3114 "v8::GetIndexedPropertiesExternalArrayData()",
3085 return NULL); 3115 return NULL);
3086 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3087 if (self->HasExternalArrayElements()) { 3116 if (self->HasExternalArrayElements()) {
3088 return i::ExternalArray::cast(self->elements())->external_pointer(); 3117 return i::ExternalArray::cast(self->elements())->external_pointer();
3089 } else { 3118 } else {
3090 return NULL; 3119 return NULL;
3091 } 3120 }
3092 } 3121 }
3093 3122
3094 3123
3095 ExternalArrayType v8::Object::GetIndexedPropertiesExternalArrayDataType() { 3124 ExternalArrayType v8::Object::GetIndexedPropertiesExternalArrayDataType() {
3096 ON_BAILOUT(i::Isolate::Current(), 3125 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3126 ON_BAILOUT(self->GetIsolate(),
3097 "v8::GetIndexedPropertiesExternalArrayDataType()", 3127 "v8::GetIndexedPropertiesExternalArrayDataType()",
3098 return static_cast<ExternalArrayType>(-1)); 3128 return static_cast<ExternalArrayType>(-1));
3099 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3100 switch (self->elements()->map()->instance_type()) { 3129 switch (self->elements()->map()->instance_type()) {
3101 case i::EXTERNAL_BYTE_ARRAY_TYPE: 3130 case i::EXTERNAL_BYTE_ARRAY_TYPE:
3102 return kExternalByteArray; 3131 return kExternalByteArray;
3103 case i::EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: 3132 case i::EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE:
3104 return kExternalUnsignedByteArray; 3133 return kExternalUnsignedByteArray;
3105 case i::EXTERNAL_SHORT_ARRAY_TYPE: 3134 case i::EXTERNAL_SHORT_ARRAY_TYPE:
3106 return kExternalShortArray; 3135 return kExternalShortArray;
3107 case i::EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: 3136 case i::EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE:
3108 return kExternalUnsignedShortArray; 3137 return kExternalUnsignedShortArray;
3109 case i::EXTERNAL_INT_ARRAY_TYPE: 3138 case i::EXTERNAL_INT_ARRAY_TYPE:
3110 return kExternalIntArray; 3139 return kExternalIntArray;
3111 case i::EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: 3140 case i::EXTERNAL_UNSIGNED_INT_ARRAY_TYPE:
3112 return kExternalUnsignedIntArray; 3141 return kExternalUnsignedIntArray;
3113 case i::EXTERNAL_FLOAT_ARRAY_TYPE: 3142 case i::EXTERNAL_FLOAT_ARRAY_TYPE:
3114 return kExternalFloatArray; 3143 return kExternalFloatArray;
3115 case i::EXTERNAL_PIXEL_ARRAY_TYPE: 3144 case i::EXTERNAL_PIXEL_ARRAY_TYPE:
3116 return kExternalPixelArray; 3145 return kExternalPixelArray;
3117 default: 3146 default:
3118 return static_cast<ExternalArrayType>(-1); 3147 return static_cast<ExternalArrayType>(-1);
3119 } 3148 }
3120 } 3149 }
3121 3150
3122 3151
3123 int v8::Object::GetIndexedPropertiesExternalArrayDataLength() { 3152 int v8::Object::GetIndexedPropertiesExternalArrayDataLength() {
3124 ON_BAILOUT(i::Isolate::Current(), 3153 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3154 ON_BAILOUT(self->GetIsolate(),
3125 "v8::GetIndexedPropertiesExternalArrayDataLength()", 3155 "v8::GetIndexedPropertiesExternalArrayDataLength()",
3126 return 0); 3156 return 0);
3127 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3128 if (self->HasExternalArrayElements()) { 3157 if (self->HasExternalArrayElements()) {
3129 return i::ExternalArray::cast(self->elements())->length(); 3158 return i::ExternalArray::cast(self->elements())->length();
3130 } else { 3159 } else {
3131 return -1; 3160 return -1;
3132 } 3161 }
3133 } 3162 }
3134 3163
3135 3164
3136 Local<v8::Object> Function::NewInstance() const { 3165 Local<v8::Object> Function::NewInstance() const {
3137 return NewInstance(0, NULL); 3166 return NewInstance(0, NULL);
3138 } 3167 }
3139 3168
3140 3169
3141 Local<v8::Object> Function::NewInstance(int argc, 3170 Local<v8::Object> Function::NewInstance(int argc,
3142 v8::Handle<v8::Value> argv[]) const { 3171 v8::Handle<v8::Value> argv[]) const {
3143 i::Isolate* isolate = i::Isolate::Current(); 3172 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3144 ON_BAILOUT(isolate, "v8::Function::NewInstance()", 3173 ON_BAILOUT(isolate, "v8::Function::NewInstance()",
3145 return Local<v8::Object>()); 3174 return Local<v8::Object>());
3146 LOG_API(isolate, "Function::NewInstance"); 3175 LOG_API(isolate, "Function::NewInstance");
3147 ENTER_V8; 3176 ENTER_V8(isolate);
3148 HandleScope scope; 3177 HandleScope scope;
3149 i::Handle<i::JSFunction> function = Utils::OpenHandle(this); 3178 i::Handle<i::JSFunction> function = Utils::OpenHandle(this);
3150 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); 3179 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**));
3151 i::Object*** args = reinterpret_cast<i::Object***>(argv); 3180 i::Object*** args = reinterpret_cast<i::Object***>(argv);
3152 EXCEPTION_PREAMBLE(); 3181 EXCEPTION_PREAMBLE(isolate);
3153 i::Handle<i::Object> returned = 3182 i::Handle<i::Object> returned =
3154 i::Execution::New(function, argc, args, &has_pending_exception); 3183 i::Execution::New(function, argc, args, &has_pending_exception);
3155 EXCEPTION_BAILOUT_CHECK(Local<v8::Object>()); 3184 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>());
3156 return scope.Close(Utils::ToLocal(i::Handle<i::JSObject>::cast(returned))); 3185 return scope.Close(Utils::ToLocal(i::Handle<i::JSObject>::cast(returned)));
3157 } 3186 }
3158 3187
3159 3188
3160 Local<v8::Value> Function::Call(v8::Handle<v8::Object> recv, int argc, 3189 Local<v8::Value> Function::Call(v8::Handle<v8::Object> recv, int argc,
3161 v8::Handle<v8::Value> argv[]) { 3190 v8::Handle<v8::Value> argv[]) {
3162 i::Isolate* isolate = i::Isolate::Current(); 3191 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3163 ON_BAILOUT(isolate, "v8::Function::Call()", return Local<v8::Value>()); 3192 ON_BAILOUT(isolate, "v8::Function::Call()", return Local<v8::Value>());
3164 LOG_API(isolate, "Function::Call"); 3193 LOG_API(isolate, "Function::Call");
3165 ENTER_V8; 3194 ENTER_V8(isolate);
3166 i::Object* raw_result = NULL; 3195 i::Object* raw_result = NULL;
3167 { 3196 {
3168 i::HandleScope scope(isolate); 3197 i::HandleScope scope(isolate);
3169 i::Handle<i::JSFunction> fun = Utils::OpenHandle(this); 3198 i::Handle<i::JSFunction> fun = Utils::OpenHandle(this);
3170 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); 3199 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv);
3171 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); 3200 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**));
3172 i::Object*** args = reinterpret_cast<i::Object***>(argv); 3201 i::Object*** args = reinterpret_cast<i::Object***>(argv);
3173 EXCEPTION_PREAMBLE(); 3202 EXCEPTION_PREAMBLE(isolate);
3174 i::Handle<i::Object> returned = 3203 i::Handle<i::Object> returned =
3175 i::Execution::Call(fun, recv_obj, argc, args, &has_pending_exception); 3204 i::Execution::Call(fun, recv_obj, argc, args, &has_pending_exception);
3176 EXCEPTION_BAILOUT_CHECK(Local<Object>()); 3205 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>());
3177 raw_result = *returned; 3206 raw_result = *returned;
3178 } 3207 }
3179 i::Handle<i::Object> result(raw_result); 3208 i::Handle<i::Object> result(raw_result);
3180 return Utils::ToLocal(result); 3209 return Utils::ToLocal(result);
3181 } 3210 }
3182 3211
3183 3212
3184 void Function::SetName(v8::Handle<v8::String> name) { 3213 void Function::SetName(v8::Handle<v8::String> name) {
3185 ENTER_V8; 3214 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3215 ENTER_V8(isolate);
3186 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); 3216 i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
3187 func->shared()->set_name(*Utils::OpenHandle(*name)); 3217 func->shared()->set_name(*Utils::OpenHandle(*name));
3188 } 3218 }
3189 3219
3190 3220
3191 Handle<Value> Function::GetName() const { 3221 Handle<Value> Function::GetName() const {
3192 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); 3222 i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
3193 return Utils::ToLocal(i::Handle<i::Object>(func->shared()->name())); 3223 return Utils::ToLocal(i::Handle<i::Object>(func->shared()->name()));
3194 } 3224 }
3195 3225
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3230 int String::Utf8Length() const { 3260 int String::Utf8Length() const {
3231 if (IsDeadCheck(i::Isolate::Current(), "v8::String::Utf8Length()")) return 0; 3261 if (IsDeadCheck(i::Isolate::Current(), "v8::String::Utf8Length()")) return 0;
3232 return Utils::OpenHandle(this)->Utf8Length(); 3262 return Utils::OpenHandle(this)->Utf8Length();
3233 } 3263 }
3234 3264
3235 3265
3236 int String::WriteUtf8(char* buffer, 3266 int String::WriteUtf8(char* buffer,
3237 int capacity, 3267 int capacity,
3238 int* nchars_ref, 3268 int* nchars_ref,
3239 WriteHints hints) const { 3269 WriteHints hints) const {
3240 i::Isolate* isolate = i::Isolate::Current(); 3270 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3241 if (IsDeadCheck(isolate, "v8::String::WriteUtf8()")) return 0; 3271 if (IsDeadCheck(isolate, "v8::String::WriteUtf8()")) return 0;
3242 LOG_API(isolate, "String::WriteUtf8"); 3272 LOG_API(isolate, "String::WriteUtf8");
3243 ENTER_V8; 3273 ENTER_V8(isolate);
3244 i::StringInputBuffer& write_input_buffer = *isolate->write_input_buffer(); 3274 i::StringInputBuffer& write_input_buffer = *isolate->write_input_buffer();
3245 i::Handle<i::String> str = Utils::OpenHandle(this); 3275 i::Handle<i::String> str = Utils::OpenHandle(this);
3246 isolate->string_tracker()->RecordWrite(str); 3276 isolate->string_tracker()->RecordWrite(str);
3247 if (hints & HINT_MANY_WRITES_EXPECTED) { 3277 if (hints & HINT_MANY_WRITES_EXPECTED) {
3248 // Flatten the string for efficiency. This applies whether we are 3278 // Flatten the string for efficiency. This applies whether we are
3249 // using StringInputBuffer or Get(i) to access the characters. 3279 // using StringInputBuffer or Get(i) to access the characters.
3250 str->TryFlatten(); 3280 str->TryFlatten();
3251 } 3281 }
3252 write_input_buffer.Reset(0, *str); 3282 write_input_buffer.Reset(0, *str);
3253 int len = str->length(); 3283 int len = str->length();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3287 if (i == len && (capacity == -1 || pos < capacity)) 3317 if (i == len && (capacity == -1 || pos < capacity))
3288 buffer[pos++] = '\0'; 3318 buffer[pos++] = '\0';
3289 return pos; 3319 return pos;
3290 } 3320 }
3291 3321
3292 3322
3293 int String::WriteAscii(char* buffer, 3323 int String::WriteAscii(char* buffer,
3294 int start, 3324 int start,
3295 int length, 3325 int length,
3296 WriteHints hints) const { 3326 WriteHints hints) const {
3297 i::Isolate* isolate = i::Isolate::Current(); 3327 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3298 if (IsDeadCheck(isolate, "v8::String::WriteAscii()")) return 0; 3328 if (IsDeadCheck(isolate, "v8::String::WriteAscii()")) return 0;
3299 LOG_API(isolate, "String::WriteAscii"); 3329 LOG_API(isolate, "String::WriteAscii");
3300 ENTER_V8; 3330 ENTER_V8(isolate);
3301 i::StringInputBuffer& write_input_buffer = *isolate->write_input_buffer(); 3331 i::StringInputBuffer& write_input_buffer = *isolate->write_input_buffer();
3302 ASSERT(start >= 0 && length >= -1); 3332 ASSERT(start >= 0 && length >= -1);
3303 i::Handle<i::String> str = Utils::OpenHandle(this); 3333 i::Handle<i::String> str = Utils::OpenHandle(this);
3304 isolate->string_tracker()->RecordWrite(str); 3334 isolate->string_tracker()->RecordWrite(str);
3305 if (hints & HINT_MANY_WRITES_EXPECTED) { 3335 if (hints & HINT_MANY_WRITES_EXPECTED) {
3306 // Flatten the string for efficiency. This applies whether we are 3336 // Flatten the string for efficiency. This applies whether we are
3307 // using StringInputBuffer or Get(i) to access the characters. 3337 // using StringInputBuffer or Get(i) to access the characters.
3308 str->TryFlatten(); 3338 str->TryFlatten();
3309 } 3339 }
3310 int end = length; 3340 int end = length;
(...skipping 10 matching lines...) Expand all
3321 if (length == -1 || i < length) 3351 if (length == -1 || i < length)
3322 buffer[i] = '\0'; 3352 buffer[i] = '\0';
3323 return i; 3353 return i;
3324 } 3354 }
3325 3355
3326 3356
3327 int String::Write(uint16_t* buffer, 3357 int String::Write(uint16_t* buffer,
3328 int start, 3358 int start,
3329 int length, 3359 int length,
3330 WriteHints hints) const { 3360 WriteHints hints) const {
3331 i::Isolate* isolate = i::Isolate::Current(); 3361 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3332 if (IsDeadCheck(isolate, "v8::String::Write()")) return 0; 3362 if (IsDeadCheck(isolate, "v8::String::Write()")) return 0;
3333 LOG_API(isolate, "String::Write"); 3363 LOG_API(isolate, "String::Write");
3334 ENTER_V8; 3364 ENTER_V8(isolate);
3335 ASSERT(start >= 0 && length >= -1); 3365 ASSERT(start >= 0 && length >= -1);
3336 i::Handle<i::String> str = Utils::OpenHandle(this); 3366 i::Handle<i::String> str = Utils::OpenHandle(this);
3337 isolate->string_tracker()->RecordWrite(str); 3367 isolate->string_tracker()->RecordWrite(str);
3338 if (hints & HINT_MANY_WRITES_EXPECTED) { 3368 if (hints & HINT_MANY_WRITES_EXPECTED) {
3339 // Flatten the string for efficiency. This applies whether we are 3369 // Flatten the string for efficiency. This applies whether we are
3340 // using StringInputBuffer or Get(i) to access the characters. 3370 // using StringInputBuffer or Get(i) to access the characters.
3341 str->TryFlatten(); 3371 str->TryFlatten();
3342 } 3372 }
3343 int end = start + length; 3373 int end = start + length;
3344 if ((length == -1) || (length > str->length() - start) ) 3374 if ((length == -1) || (length > str->length() - start) )
3345 end = str->length(); 3375 end = str->length();
3346 if (end < 0) return 0; 3376 if (end < 0) return 0;
3347 i::String::WriteToFlat(*str, buffer, start, end); 3377 i::String::WriteToFlat(*str, buffer, start, end);
3348 if (length == -1 || end - start < length) { 3378 if (length == -1 || end - start < length) {
3349 buffer[end - start] = '\0'; 3379 buffer[end - start] = '\0';
3350 } 3380 }
3351 return end - start; 3381 return end - start;
3352 } 3382 }
3353 3383
3354 3384
3355 bool v8::String::IsExternal() const { 3385 bool v8::String::IsExternal() const {
3356 EnsureInitialized("v8::String::IsExternal()");
3357 i::Handle<i::String> str = Utils::OpenHandle(this); 3386 i::Handle<i::String> str = Utils::OpenHandle(this);
3387 if (IsDeadCheck(str->GetIsolate(), "v8::String::IsExternal()")) {
3388 return false;
3389 }
3390 EnsureInitializedForIsolate(str->GetIsolate(), "v8::String::IsExternal()");
3358 return i::StringShape(*str).IsExternalTwoByte(); 3391 return i::StringShape(*str).IsExternalTwoByte();
3359 } 3392 }
3360 3393
3361 3394
3362 bool v8::String::IsExternalAscii() const { 3395 bool v8::String::IsExternalAscii() const {
3363 EnsureInitialized("v8::String::IsExternalAscii()");
3364 i::Handle<i::String> str = Utils::OpenHandle(this); 3396 i::Handle<i::String> str = Utils::OpenHandle(this);
3397 if (IsDeadCheck(str->GetIsolate(), "v8::String::IsExternalAscii()")) {
3398 return false;
3399 }
3365 return i::StringShape(*str).IsExternalAscii(); 3400 return i::StringShape(*str).IsExternalAscii();
3366 } 3401 }
3367 3402
3368 3403
3369 void v8::String::VerifyExternalStringResource( 3404 void v8::String::VerifyExternalStringResource(
3370 v8::String::ExternalStringResource* value) const { 3405 v8::String::ExternalStringResource* value) const {
3371 i::Handle<i::String> str = Utils::OpenHandle(this); 3406 i::Handle<i::String> str = Utils::OpenHandle(this);
3372 v8::String::ExternalStringResource* expected; 3407 v8::String::ExternalStringResource* expected;
3373 if (i::StringShape(*str).IsExternalTwoByte()) { 3408 if (i::StringShape(*str).IsExternalTwoByte()) {
3374 void* resource = i::Handle<i::ExternalTwoByteString>::cast(str)->resource(); 3409 void* resource = i::Handle<i::ExternalTwoByteString>::cast(str)->resource();
3375 expected = reinterpret_cast<ExternalStringResource*>(resource); 3410 expected = reinterpret_cast<ExternalStringResource*>(resource);
3376 } else { 3411 } else {
3377 expected = NULL; 3412 expected = NULL;
3378 } 3413 }
3379 CHECK_EQ(expected, value); 3414 CHECK_EQ(expected, value);
3380 } 3415 }
3381 3416
3382 3417
3383 v8::String::ExternalAsciiStringResource* 3418 v8::String::ExternalAsciiStringResource*
3384 v8::String::GetExternalAsciiStringResource() const { 3419 v8::String::GetExternalAsciiStringResource() const {
3385 EnsureInitialized("v8::String::GetExternalAsciiStringResource()");
3386 i::Handle<i::String> str = Utils::OpenHandle(this); 3420 i::Handle<i::String> str = Utils::OpenHandle(this);
3421 if (IsDeadCheck(str->GetIsolate(),
3422 "v8::String::GetExternalAsciiStringResource()")) {
3423 return NULL;
3424 }
3387 if (i::StringShape(*str).IsExternalAscii()) { 3425 if (i::StringShape(*str).IsExternalAscii()) {
3388 void* resource = i::Handle<i::ExternalAsciiString>::cast(str)->resource(); 3426 void* resource = i::Handle<i::ExternalAsciiString>::cast(str)->resource();
3389 return reinterpret_cast<ExternalAsciiStringResource*>(resource); 3427 return reinterpret_cast<ExternalAsciiStringResource*>(resource);
3390 } else { 3428 } else {
3391 return NULL; 3429 return NULL;
3392 } 3430 }
3393 } 3431 }
3394 3432
3395 3433
3396 double Number::Value() const { 3434 double Number::Value() const {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3434 i::Handle<i::Object> obj = Utils::OpenHandle(this); 3472 i::Handle<i::Object> obj = Utils::OpenHandle(this);
3435 if (obj->IsSmi()) { 3473 if (obj->IsSmi()) {
3436 return i::Smi::cast(*obj)->value(); 3474 return i::Smi::cast(*obj)->value();
3437 } else { 3475 } else {
3438 return static_cast<uint32_t>(obj->Number()); 3476 return static_cast<uint32_t>(obj->Number());
3439 } 3477 }
3440 } 3478 }
3441 3479
3442 3480
3443 int v8::Object::InternalFieldCount() { 3481 int v8::Object::InternalFieldCount() {
3444 if (IsDeadCheck(i::Isolate::Current(), "v8::Object::InternalFieldCount()")) { 3482 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
3483 if (IsDeadCheck(obj->GetIsolate(), "v8::Object::InternalFieldCount()")) {
3445 return 0; 3484 return 0;
3446 } 3485 }
3447 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
3448 return obj->GetInternalFieldCount(); 3486 return obj->GetInternalFieldCount();
3449 } 3487 }
3450 3488
3451 3489
3452 Local<Value> v8::Object::CheckedGetInternalField(int index) { 3490 Local<Value> v8::Object::CheckedGetInternalField(int index) {
3453 if (IsDeadCheck(i::Isolate::Current(), "v8::Object::GetInternalField()")) { 3491 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
3492 if (IsDeadCheck(obj->GetIsolate(), "v8::Object::GetInternalField()")) {
3454 return Local<Value>(); 3493 return Local<Value>();
3455 } 3494 }
3456 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
3457 if (!ApiCheck(index < obj->GetInternalFieldCount(), 3495 if (!ApiCheck(index < obj->GetInternalFieldCount(),
3458 "v8::Object::GetInternalField()", 3496 "v8::Object::GetInternalField()",
3459 "Reading internal field out of bounds")) { 3497 "Reading internal field out of bounds")) {
3460 return Local<Value>(); 3498 return Local<Value>();
3461 } 3499 }
3462 i::Handle<i::Object> value(obj->GetInternalField(index)); 3500 i::Handle<i::Object> value(obj->GetInternalField(index));
3463 Local<Value> result = Utils::ToLocal(value); 3501 Local<Value> result = Utils::ToLocal(value);
3464 #ifdef DEBUG 3502 #ifdef DEBUG
3465 Local<Value> unchecked = UncheckedGetInternalField(index); 3503 Local<Value> unchecked = UncheckedGetInternalField(index);
3466 ASSERT(unchecked.IsEmpty() || (unchecked == result)); 3504 ASSERT(unchecked.IsEmpty() || (unchecked == result));
3467 #endif 3505 #endif
3468 return result; 3506 return result;
3469 } 3507 }
3470 3508
3471 3509
3472 void v8::Object::SetInternalField(int index, v8::Handle<Value> value) { 3510 void v8::Object::SetInternalField(int index, v8::Handle<Value> value) {
3473 if (IsDeadCheck(i::Isolate::Current(), "v8::Object::SetInternalField()")) { 3511 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
3512 i::Isolate* isolate = obj->GetIsolate();
3513 if (IsDeadCheck(isolate, "v8::Object::SetInternalField()")) {
3474 return; 3514 return;
3475 } 3515 }
3476 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
3477 if (!ApiCheck(index < obj->GetInternalFieldCount(), 3516 if (!ApiCheck(index < obj->GetInternalFieldCount(),
3478 "v8::Object::SetInternalField()", 3517 "v8::Object::SetInternalField()",
3479 "Writing internal field out of bounds")) { 3518 "Writing internal field out of bounds")) {
3480 return; 3519 return;
3481 } 3520 }
3482 ENTER_V8; 3521 ENTER_V8(isolate);
3483 i::Handle<i::Object> val = Utils::OpenHandle(*value); 3522 i::Handle<i::Object> val = Utils::OpenHandle(*value);
3484 obj->SetInternalField(index, *val); 3523 obj->SetInternalField(index, *val);
3485 } 3524 }
3486 3525
3487 3526
3488 static bool CanBeEncodedAsSmi(void* ptr) { 3527 static bool CanBeEncodedAsSmi(void* ptr) {
3489 const uintptr_t address = reinterpret_cast<uintptr_t>(ptr); 3528 const uintptr_t address = reinterpret_cast<uintptr_t>(ptr);
3490 return ((address & i::kEncodablePointerMask) == 0); 3529 return ((address & i::kEncodablePointerMask) == 0);
3491 } 3530 }
3492 3531
3493 3532
3494 static i::Smi* EncodeAsSmi(void* ptr) { 3533 static i::Smi* EncodeAsSmi(void* ptr) {
3495 ASSERT(CanBeEncodedAsSmi(ptr)); 3534 ASSERT(CanBeEncodedAsSmi(ptr));
3496 const uintptr_t address = reinterpret_cast<uintptr_t>(ptr); 3535 const uintptr_t address = reinterpret_cast<uintptr_t>(ptr);
3497 i::Smi* result = reinterpret_cast<i::Smi*>(address << i::kPointerToSmiShift); 3536 i::Smi* result = reinterpret_cast<i::Smi*>(address << i::kPointerToSmiShift);
3498 ASSERT(i::Internals::HasSmiTag(result)); 3537 ASSERT(i::Internals::HasSmiTag(result));
3499 ASSERT_EQ(result, i::Smi::FromInt(result->value())); 3538 ASSERT_EQ(result, i::Smi::FromInt(result->value()));
3500 ASSERT_EQ(ptr, i::Internals::GetExternalPointerFromSmi(result)); 3539 ASSERT_EQ(ptr, i::Internals::GetExternalPointerFromSmi(result));
3501 return result; 3540 return result;
3502 } 3541 }
3503 3542
3504 3543
3505 void v8::Object::SetPointerInInternalField(int index, void* value) { 3544 void v8::Object::SetPointerInInternalField(int index, void* value) {
3506 ENTER_V8; 3545 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3546 ENTER_V8(isolate);
3507 if (CanBeEncodedAsSmi(value)) { 3547 if (CanBeEncodedAsSmi(value)) {
3508 Utils::OpenHandle(this)->SetInternalField(index, EncodeAsSmi(value)); 3548 Utils::OpenHandle(this)->SetInternalField(index, EncodeAsSmi(value));
3509 } else { 3549 } else {
3510 HandleScope scope; 3550 HandleScope scope;
3511 i::Handle<i::Proxy> proxy = 3551 i::Handle<i::Proxy> proxy =
3512 FACTORY->NewProxy(reinterpret_cast<i::Address>(value), i::TENURED); 3552 isolate->factory()->NewProxy(
3553 reinterpret_cast<i::Address>(value), i::TENURED);
3513 if (!proxy.is_null()) 3554 if (!proxy.is_null())
3514 Utils::OpenHandle(this)->SetInternalField(index, *proxy); 3555 Utils::OpenHandle(this)->SetInternalField(index, *proxy);
3515 } 3556 }
3516 ASSERT_EQ(value, GetPointerFromInternalField(index)); 3557 ASSERT_EQ(value, GetPointerFromInternalField(index));
3517 } 3558 }
3518 3559
3519 3560
3520 // --- E n v i r o n m e n t --- 3561 // --- E n v i r o n m e n t ---
3521 3562
3522 3563
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
3598 v8::Handle<ObjectTemplate> global_template, 3639 v8::Handle<ObjectTemplate> global_template,
3599 v8::Handle<Value> global_object) { 3640 v8::Handle<Value> global_object) {
3600 i::Isolate* isolate = i::Isolate::Current(); 3641 i::Isolate* isolate = i::Isolate::Current();
3601 EnsureInitializedForIsolate(isolate, "v8::Context::New()"); 3642 EnsureInitializedForIsolate(isolate, "v8::Context::New()");
3602 LOG_API(isolate, "Context::New"); 3643 LOG_API(isolate, "Context::New");
3603 ON_BAILOUT(isolate, "v8::Context::New()", return Persistent<Context>()); 3644 ON_BAILOUT(isolate, "v8::Context::New()", return Persistent<Context>());
3604 3645
3605 // Enter V8 via an ENTER_V8 scope. 3646 // Enter V8 via an ENTER_V8 scope.
3606 i::Handle<i::Context> env; 3647 i::Handle<i::Context> env;
3607 { 3648 {
3608 ENTER_V8; 3649 ENTER_V8(isolate);
3609 v8::Handle<ObjectTemplate> proxy_template = global_template; 3650 v8::Handle<ObjectTemplate> proxy_template = global_template;
3610 i::Handle<i::FunctionTemplateInfo> proxy_constructor; 3651 i::Handle<i::FunctionTemplateInfo> proxy_constructor;
3611 i::Handle<i::FunctionTemplateInfo> global_constructor; 3652 i::Handle<i::FunctionTemplateInfo> global_constructor;
3612 3653
3613 if (!global_template.IsEmpty()) { 3654 if (!global_template.IsEmpty()) {
3614 // Make sure that the global_template has a constructor. 3655 // Make sure that the global_template has a constructor.
3615 global_constructor = 3656 global_constructor =
3616 EnsureConstructor(Utils::OpenHandle(*global_template)); 3657 EnsureConstructor(Utils::OpenHandle(*global_template));
3617 3658
3618 // Create a fresh template for the global proxy object. 3659 // Create a fresh template for the global proxy object.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
3657 } 3698 }
3658 // Leave V8. 3699 // Leave V8.
3659 3700
3660 if (env.is_null()) 3701 if (env.is_null())
3661 return Persistent<Context>(); 3702 return Persistent<Context>();
3662 return Persistent<Context>(Utils::ToLocal(env)); 3703 return Persistent<Context>(Utils::ToLocal(env));
3663 } 3704 }
3664 3705
3665 3706
3666 void v8::Context::SetSecurityToken(Handle<Value> token) { 3707 void v8::Context::SetSecurityToken(Handle<Value> token) {
3667 if (IsDeadCheck(i::Isolate::Current(), "v8::Context::SetSecurityToken()")) { 3708 i::Isolate* isolate = i::Isolate::Current();
3709 if (IsDeadCheck(isolate, "v8::Context::SetSecurityToken()")) {
3668 return; 3710 return;
3669 } 3711 }
3670 ENTER_V8; 3712 ENTER_V8(isolate);
3671 i::Handle<i::Context> env = Utils::OpenHandle(this); 3713 i::Handle<i::Context> env = Utils::OpenHandle(this);
3672 i::Handle<i::Object> token_handle = Utils::OpenHandle(*token); 3714 i::Handle<i::Object> token_handle = Utils::OpenHandle(*token);
3673 env->set_security_token(*token_handle); 3715 env->set_security_token(*token_handle);
3674 } 3716 }
3675 3717
3676 3718
3677 void v8::Context::UseDefaultSecurityToken() { 3719 void v8::Context::UseDefaultSecurityToken() {
3678 if (IsDeadCheck(i::Isolate::Current(), 3720 i::Isolate* isolate = i::Isolate::Current();
3721 if (IsDeadCheck(isolate,
3679 "v8::Context::UseDefaultSecurityToken()")) { 3722 "v8::Context::UseDefaultSecurityToken()")) {
3680 return; 3723 return;
3681 } 3724 }
3682 ENTER_V8; 3725 ENTER_V8(isolate);
3683 i::Handle<i::Context> env = Utils::OpenHandle(this); 3726 i::Handle<i::Context> env = Utils::OpenHandle(this);
3684 env->set_security_token(env->global()); 3727 env->set_security_token(env->global());
3685 } 3728 }
3686 3729
3687 3730
3688 Handle<Value> v8::Context::GetSecurityToken() { 3731 Handle<Value> v8::Context::GetSecurityToken() {
3689 if (IsDeadCheck(i::Isolate::Current(), "v8::Context::GetSecurityToken()")) { 3732 i::Isolate* isolate = i::Isolate::Current();
3733 if (IsDeadCheck(isolate, "v8::Context::GetSecurityToken()")) {
3690 return Handle<Value>(); 3734 return Handle<Value>();
3691 } 3735 }
3692 i::Handle<i::Context> env = Utils::OpenHandle(this); 3736 i::Handle<i::Context> env = Utils::OpenHandle(this);
3693 i::Object* security_token = env->security_token(); 3737 i::Object* security_token = env->security_token();
3694 i::Handle<i::Object> token_handle(security_token); 3738 i::Handle<i::Object> token_handle(security_token);
3695 return Utils::ToLocal(token_handle); 3739 return Utils::ToLocal(token_handle);
3696 } 3740 }
3697 3741
3698 3742
3699 bool Context::HasOutOfMemoryException() { 3743 bool Context::HasOutOfMemoryException() {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
3748 } 3792 }
3749 i::Object** ctx = reinterpret_cast<i::Object**>(this); 3793 i::Object** ctx = reinterpret_cast<i::Object**>(this);
3750 i::Handle<i::Context> context = 3794 i::Handle<i::Context> context =
3751 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx)); 3795 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx));
3752 i::Handle<i::Object> global(context->global_proxy()); 3796 i::Handle<i::Object> global(context->global_proxy());
3753 return Utils::ToLocal(i::Handle<i::JSObject>::cast(global)); 3797 return Utils::ToLocal(i::Handle<i::JSObject>::cast(global));
3754 } 3798 }
3755 3799
3756 3800
3757 void Context::DetachGlobal() { 3801 void Context::DetachGlobal() {
3758 if (IsDeadCheck(i::Isolate::Current(), "v8::Context::DetachGlobal()")) return; 3802 i::Isolate* isolate = i::Isolate::Current();
3759 ENTER_V8; 3803 if (IsDeadCheck(isolate, "v8::Context::DetachGlobal()")) return;
3804 ENTER_V8(isolate);
3760 i::Object** ctx = reinterpret_cast<i::Object**>(this); 3805 i::Object** ctx = reinterpret_cast<i::Object**>(this);
3761 i::Handle<i::Context> context = 3806 i::Handle<i::Context> context =
3762 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx)); 3807 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx));
3763 i::Isolate::Current()->bootstrapper()->DetachGlobal(context); 3808 isolate->bootstrapper()->DetachGlobal(context);
3764 } 3809 }
3765 3810
3766 3811
3767 void Context::ReattachGlobal(Handle<Object> global_object) { 3812 void Context::ReattachGlobal(Handle<Object> global_object) {
3768 i::Isolate* isolate = i::Isolate::Current(); 3813 i::Isolate* isolate = i::Isolate::Current();
3769 if (IsDeadCheck(isolate, "v8::Context::ReattachGlobal()")) return; 3814 if (IsDeadCheck(isolate, "v8::Context::ReattachGlobal()")) return;
3770 ENTER_V8; 3815 ENTER_V8(isolate);
3771 i::Object** ctx = reinterpret_cast<i::Object**>(this); 3816 i::Object** ctx = reinterpret_cast<i::Object**>(this);
3772 i::Handle<i::Context> context = 3817 i::Handle<i::Context> context =
3773 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx)); 3818 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx));
3774 isolate->bootstrapper()->ReattachGlobal( 3819 isolate->bootstrapper()->ReattachGlobal(
3775 context, 3820 context,
3776 Utils::OpenHandle(*global_object)); 3821 Utils::OpenHandle(*global_object));
3777 } 3822 }
3778 3823
3779 3824
3780 void V8::SetWrapperClassId(i::Object** global_handle, uint16_t class_id) { 3825 void V8::SetWrapperClassId(i::Object** global_handle, uint16_t class_id) {
3781 i::GlobalHandles::SetWrapperClassId(global_handle, class_id); 3826 i::GlobalHandles::SetWrapperClassId(global_handle, class_id);
3782 } 3827 }
3783 3828
3784 3829
3785 Local<v8::Object> ObjectTemplate::NewInstance() { 3830 Local<v8::Object> ObjectTemplate::NewInstance() {
3786 i::Isolate* isolate = i::Isolate::Current(); 3831 i::Isolate* isolate = i::Isolate::Current();
3787 ON_BAILOUT(isolate, "v8::ObjectTemplate::NewInstance()", 3832 ON_BAILOUT(isolate, "v8::ObjectTemplate::NewInstance()",
3788 return Local<v8::Object>()); 3833 return Local<v8::Object>());
3789 LOG_API(isolate, "ObjectTemplate::NewInstance"); 3834 LOG_API(isolate, "ObjectTemplate::NewInstance");
3790 ENTER_V8; 3835 ENTER_V8(isolate);
3791 EXCEPTION_PREAMBLE(); 3836 EXCEPTION_PREAMBLE(isolate);
3792 i::Handle<i::Object> obj = 3837 i::Handle<i::Object> obj =
3793 i::Execution::InstantiateObject(Utils::OpenHandle(this), 3838 i::Execution::InstantiateObject(Utils::OpenHandle(this),
3794 &has_pending_exception); 3839 &has_pending_exception);
3795 EXCEPTION_BAILOUT_CHECK(Local<v8::Object>()); 3840 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>());
3796 return Utils::ToLocal(i::Handle<i::JSObject>::cast(obj)); 3841 return Utils::ToLocal(i::Handle<i::JSObject>::cast(obj));
3797 } 3842 }
3798 3843
3799 3844
3800 Local<v8::Function> FunctionTemplate::GetFunction() { 3845 Local<v8::Function> FunctionTemplate::GetFunction() {
3801 i::Isolate* isolate = i::Isolate::Current(); 3846 i::Isolate* isolate = i::Isolate::Current();
3802 ON_BAILOUT(isolate, "v8::FunctionTemplate::GetFunction()", 3847 ON_BAILOUT(isolate, "v8::FunctionTemplate::GetFunction()",
3803 return Local<v8::Function>()); 3848 return Local<v8::Function>());
3804 LOG_API(isolate, "FunctionTemplate::GetFunction"); 3849 LOG_API(isolate, "FunctionTemplate::GetFunction");
3805 ENTER_V8; 3850 ENTER_V8(isolate);
3806 EXCEPTION_PREAMBLE(); 3851 EXCEPTION_PREAMBLE(isolate);
3807 i::Handle<i::Object> obj = 3852 i::Handle<i::Object> obj =
3808 i::Execution::InstantiateFunction(Utils::OpenHandle(this), 3853 i::Execution::InstantiateFunction(Utils::OpenHandle(this),
3809 &has_pending_exception); 3854 &has_pending_exception);
3810 EXCEPTION_BAILOUT_CHECK(Local<v8::Function>()); 3855 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Function>());
3811 return Utils::ToLocal(i::Handle<i::JSFunction>::cast(obj)); 3856 return Utils::ToLocal(i::Handle<i::JSFunction>::cast(obj));
3812 } 3857 }
3813 3858
3814 3859
3815 bool FunctionTemplate::HasInstance(v8::Handle<v8::Value> value) { 3860 bool FunctionTemplate::HasInstance(v8::Handle<v8::Value> value) {
3816 ON_BAILOUT(i::Isolate::Current(), "v8::FunctionTemplate::HasInstanceOf()", 3861 ON_BAILOUT(i::Isolate::Current(), "v8::FunctionTemplate::HasInstanceOf()",
3817 return false); 3862 return false);
3818 i::Object* obj = *Utils::OpenHandle(*value); 3863 i::Object* obj = *Utils::OpenHandle(*value);
3819 return obj->IsInstanceOf(*Utils::OpenHandle(this)); 3864 return obj->IsInstanceOf(*Utils::OpenHandle(this));
3820 } 3865 }
3821 3866
3822 3867
3823 static Local<External> ExternalNewImpl(void* data) { 3868 static Local<External> ExternalNewImpl(void* data) {
3824 return Utils::ToLocal(FACTORY->NewProxy(static_cast<i::Address>(data))); 3869 return Utils::ToLocal(FACTORY->NewProxy(static_cast<i::Address>(data)));
3825 } 3870 }
3826 3871
3827 static void* ExternalValueImpl(i::Handle<i::Object> obj) { 3872 static void* ExternalValueImpl(i::Handle<i::Object> obj) {
3828 return reinterpret_cast<void*>(i::Proxy::cast(*obj)->proxy()); 3873 return reinterpret_cast<void*>(i::Proxy::cast(*obj)->proxy());
3829 } 3874 }
3830 3875
3831 3876
3832 Local<Value> v8::External::Wrap(void* data) { 3877 Local<Value> v8::External::Wrap(void* data) {
3833 i::Isolate* isolate = i::Isolate::Current(); 3878 i::Isolate* isolate = i::Isolate::Current();
3834 STATIC_ASSERT(sizeof(data) == sizeof(i::Address)); 3879 STATIC_ASSERT(sizeof(data) == sizeof(i::Address));
3835 LOG_API(isolate, "External::Wrap"); 3880 LOG_API(isolate, "External::Wrap");
3836 EnsureInitializedForIsolate(isolate, "v8::External::Wrap()"); 3881 EnsureInitializedForIsolate(isolate, "v8::External::Wrap()");
3837 ENTER_V8; 3882 ENTER_V8(isolate);
3838 3883
3839 v8::Local<v8::Value> result = CanBeEncodedAsSmi(data) 3884 v8::Local<v8::Value> result = CanBeEncodedAsSmi(data)
3840 ? Utils::ToLocal(i::Handle<i::Object>(EncodeAsSmi(data))) 3885 ? Utils::ToLocal(i::Handle<i::Object>(EncodeAsSmi(data)))
3841 : v8::Local<v8::Value>(ExternalNewImpl(data)); 3886 : v8::Local<v8::Value>(ExternalNewImpl(data));
3842 3887
3843 ASSERT_EQ(data, Unwrap(result)); 3888 ASSERT_EQ(data, Unwrap(result));
3844 return result; 3889 return result;
3845 } 3890 }
3846 3891
3847 3892
(...skipping 24 matching lines...) Expand all
3872 ASSERT_EQ(result, QuickUnwrap(wrapper)); 3917 ASSERT_EQ(result, QuickUnwrap(wrapper));
3873 return result; 3918 return result;
3874 } 3919 }
3875 3920
3876 3921
3877 Local<External> v8::External::New(void* data) { 3922 Local<External> v8::External::New(void* data) {
3878 STATIC_ASSERT(sizeof(data) == sizeof(i::Address)); 3923 STATIC_ASSERT(sizeof(data) == sizeof(i::Address));
3879 i::Isolate* isolate = i::Isolate::Current(); 3924 i::Isolate* isolate = i::Isolate::Current();
3880 LOG_API(isolate, "External::New"); 3925 LOG_API(isolate, "External::New");
3881 EnsureInitializedForIsolate(isolate, "v8::External::New()"); 3926 EnsureInitializedForIsolate(isolate, "v8::External::New()");
3882 ENTER_V8; 3927 ENTER_V8(isolate);
3883 return ExternalNewImpl(data); 3928 return ExternalNewImpl(data);
3884 } 3929 }
3885 3930
3886 3931
3887 void* External::Value() const { 3932 void* External::Value() const {
3888 if (IsDeadCheck(i::Isolate::Current(), "v8::External::Value()")) return 0; 3933 if (IsDeadCheck(i::Isolate::Current(), "v8::External::Value()")) return 0;
3889 i::Handle<i::Object> obj = Utils::OpenHandle(this); 3934 i::Handle<i::Object> obj = Utils::OpenHandle(this);
3890 return ExternalValueImpl(obj); 3935 return ExternalValueImpl(obj);
3891 } 3936 }
3892 3937
3893 3938
3894 Local<String> v8::String::Empty() { 3939 Local<String> v8::String::Empty() {
3895 i::Isolate* isolate = i::Isolate::Current(); 3940 i::Isolate* isolate = i::Isolate::Current();
3896 EnsureInitializedForIsolate(isolate, "v8::String::Empty()"); 3941 EnsureInitializedForIsolate(isolate, "v8::String::Empty()");
3897 LOG_API(isolate, "String::Empty()"); 3942 LOG_API(isolate, "String::Empty()");
3898 return Utils::ToLocal(isolate->factory()->empty_symbol()); 3943 return Utils::ToLocal(isolate->factory()->empty_symbol());
3899 } 3944 }
3900 3945
3901 3946
3902 Local<String> v8::String::New(const char* data, int length) { 3947 Local<String> v8::String::New(const char* data, int length) {
3903 i::Isolate* isolate = i::Isolate::Current(); 3948 i::Isolate* isolate = i::Isolate::Current();
3904 EnsureInitializedForIsolate(isolate, "v8::String::New()"); 3949 EnsureInitializedForIsolate(isolate, "v8::String::New()");
3905 LOG_API(isolate, "String::New(char)"); 3950 LOG_API(isolate, "String::New(char)");
3906 if (length == 0) return Empty(); 3951 if (length == 0) return Empty();
3907 ENTER_V8; 3952 ENTER_V8(isolate);
3908 if (length == -1) length = i::StrLength(data); 3953 if (length == -1) length = i::StrLength(data);
3909 i::Handle<i::String> result = 3954 i::Handle<i::String> result =
3910 isolate->factory()->NewStringFromUtf8( 3955 isolate->factory()->NewStringFromUtf8(
3911 i::Vector<const char>(data, length)); 3956 i::Vector<const char>(data, length));
3912 return Utils::ToLocal(result); 3957 return Utils::ToLocal(result);
3913 } 3958 }
3914 3959
3915 3960
3916 Local<String> v8::String::Concat(Handle<String> left, Handle<String> right) { 3961 Local<String> v8::String::Concat(Handle<String> left, Handle<String> right) {
3917 i::Handle<i::String> left_string = Utils::OpenHandle(*left); 3962 i::Handle<i::String> left_string = Utils::OpenHandle(*left);
3918 i::Isolate* isolate = left_string->GetIsolate(); 3963 i::Isolate* isolate = left_string->GetIsolate();
3919 EnsureInitializedForIsolate(isolate, "v8::String::Concat()"); 3964 EnsureInitializedForIsolate(isolate, "v8::String::New()");
3920 LOG_API(isolate, "String::Concat()"); 3965 LOG_API(isolate, "String::New(char)");
3921 ENTER_V8; 3966 ENTER_V8(isolate);
3922 i::Handle<i::String> right_string = Utils::OpenHandle(*right); 3967 i::Handle<i::String> right_string = Utils::OpenHandle(*right);
3923 i::Handle<i::String> result = isolate->factory()->NewConsString(left_string, 3968 i::Handle<i::String> result = isolate->factory()->NewConsString(left_string,
3924 right_string); 3969 right_string);
3925 return Utils::ToLocal(result); 3970 return Utils::ToLocal(result);
3926 } 3971 }
3927 3972
3928 3973
3929 Local<String> v8::String::NewUndetectable(const char* data, int length) { 3974 Local<String> v8::String::NewUndetectable(const char* data, int length) {
3930 i::Isolate* isolate = i::Isolate::Current(); 3975 i::Isolate* isolate = i::Isolate::Current();
3931 EnsureInitializedForIsolate(isolate, "v8::String::NewUndetectable()"); 3976 EnsureInitializedForIsolate(isolate, "v8::String::NewUndetectable()");
3932 LOG_API(isolate, "String::NewUndetectable(char)"); 3977 LOG_API(isolate, "String::NewUndetectable(char)");
3933 ENTER_V8; 3978 ENTER_V8(isolate);
3934 if (length == -1) length = i::StrLength(data); 3979 if (length == -1) length = i::StrLength(data);
3935 i::Handle<i::String> result = 3980 i::Handle<i::String> result =
3936 isolate->factory()->NewStringFromUtf8( 3981 isolate->factory()->NewStringFromUtf8(
3937 i::Vector<const char>(data, length)); 3982 i::Vector<const char>(data, length));
3938 result->MarkAsUndetectable(); 3983 result->MarkAsUndetectable();
3939 return Utils::ToLocal(result); 3984 return Utils::ToLocal(result);
3940 } 3985 }
3941 3986
3942 3987
3943 static int TwoByteStringLength(const uint16_t* data) { 3988 static int TwoByteStringLength(const uint16_t* data) {
3944 int length = 0; 3989 int length = 0;
3945 while (data[length] != '\0') length++; 3990 while (data[length] != '\0') length++;
3946 return length; 3991 return length;
3947 } 3992 }
3948 3993
3949 3994
3950 Local<String> v8::String::New(const uint16_t* data, int length) { 3995 Local<String> v8::String::New(const uint16_t* data, int length) {
3951 i::Isolate* isolate = i::Isolate::Current(); 3996 i::Isolate* isolate = i::Isolate::Current();
3952 EnsureInitializedForIsolate(isolate, "v8::String::New()"); 3997 EnsureInitializedForIsolate(isolate, "v8::String::New()");
3953 LOG_API(isolate, "String::New(uint16_)"); 3998 LOG_API(isolate, "String::New(uint16_)");
3954 if (length == 0) return Empty(); 3999 if (length == 0) return Empty();
3955 ENTER_V8; 4000 ENTER_V8(isolate);
3956 if (length == -1) length = TwoByteStringLength(data); 4001 if (length == -1) length = TwoByteStringLength(data);
3957 i::Handle<i::String> result = 4002 i::Handle<i::String> result =
3958 isolate->factory()->NewStringFromTwoByte( 4003 isolate->factory()->NewStringFromTwoByte(
3959 i::Vector<const uint16_t>(data, length)); 4004 i::Vector<const uint16_t>(data, length));
3960 return Utils::ToLocal(result); 4005 return Utils::ToLocal(result);
3961 } 4006 }
3962 4007
3963 4008
3964 Local<String> v8::String::NewUndetectable(const uint16_t* data, int length) { 4009 Local<String> v8::String::NewUndetectable(const uint16_t* data, int length) {
3965 i::Isolate* isolate = i::Isolate::Current(); 4010 i::Isolate* isolate = i::Isolate::Current();
3966 EnsureInitializedForIsolate(isolate, "v8::String::NewUndetectable()"); 4011 EnsureInitializedForIsolate(isolate, "v8::String::NewUndetectable()");
3967 LOG_API(isolate, "String::NewUndetectable(uint16_)"); 4012 LOG_API(isolate, "String::NewUndetectable(uint16_)");
3968 ENTER_V8; 4013 ENTER_V8(isolate);
3969 if (length == -1) length = TwoByteStringLength(data); 4014 if (length == -1) length = TwoByteStringLength(data);
3970 i::Handle<i::String> result = 4015 i::Handle<i::String> result =
3971 isolate->factory()->NewStringFromTwoByte( 4016 isolate->factory()->NewStringFromTwoByte(
3972 i::Vector<const uint16_t>(data, length)); 4017 i::Vector<const uint16_t>(data, length));
3973 result->MarkAsUndetectable(); 4018 result->MarkAsUndetectable();
3974 return Utils::ToLocal(result); 4019 return Utils::ToLocal(result);
3975 } 4020 }
3976 4021
3977 4022
3978 i::Handle<i::String> NewExternalStringHandle(i::Isolate* isolate, 4023 i::Handle<i::String> NewExternalStringHandle(i::Isolate* isolate,
(...skipping 10 matching lines...) Expand all
3989 isolate->factory()->NewExternalStringFromAscii(resource); 4034 isolate->factory()->NewExternalStringFromAscii(resource);
3990 return result; 4035 return result;
3991 } 4036 }
3992 4037
3993 4038
3994 Local<String> v8::String::NewExternal( 4039 Local<String> v8::String::NewExternal(
3995 v8::String::ExternalStringResource* resource) { 4040 v8::String::ExternalStringResource* resource) {
3996 i::Isolate* isolate = i::Isolate::Current(); 4041 i::Isolate* isolate = i::Isolate::Current();
3997 EnsureInitializedForIsolate(isolate, "v8::String::NewExternal()"); 4042 EnsureInitializedForIsolate(isolate, "v8::String::NewExternal()");
3998 LOG_API(isolate, "String::NewExternal"); 4043 LOG_API(isolate, "String::NewExternal");
3999 ENTER_V8; 4044 ENTER_V8(isolate);
4000 i::Handle<i::String> result = NewExternalStringHandle(isolate, resource); 4045 i::Handle<i::String> result = NewExternalStringHandle(isolate, resource);
4001 isolate->heap()->external_string_table()->AddString(*result); 4046 isolate->heap()->external_string_table()->AddString(*result);
4002 return Utils::ToLocal(result); 4047 return Utils::ToLocal(result);
4003 } 4048 }
4004 4049
4005 4050
4006 bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) { 4051 bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) {
4007 i::Handle<i::String> obj = Utils::OpenHandle(this); 4052 i::Handle<i::String> obj = Utils::OpenHandle(this);
4008 i::Isolate* isolate = obj->GetIsolate(); 4053 i::Isolate* isolate = obj->GetIsolate();
4009 if (IsDeadCheck(isolate, "v8::String::MakeExternal()")) return false; 4054 if (IsDeadCheck(isolate, "v8::String::MakeExternal()")) return false;
4010 if (this->IsExternal()) return false; // Already an external string. 4055 if (i::StringShape(*obj).IsExternalTwoByte()) {
4011 ENTER_V8; 4056 return false; // Already an external string.
4057 }
4058 ENTER_V8(isolate);
4012 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { 4059 if (isolate->string_tracker()->IsFreshUnusedString(obj)) {
4013 return false; 4060 return false;
4014 } 4061 }
4015 bool result = obj->MakeExternal(resource); 4062 bool result = obj->MakeExternal(resource);
4016 if (result && !obj->IsSymbol()) { 4063 if (result && !obj->IsSymbol()) {
4017 isolate->heap()->external_string_table()->AddString(*obj); 4064 isolate->heap()->external_string_table()->AddString(*obj);
4018 } 4065 }
4019 return result; 4066 return result;
4020 } 4067 }
4021 4068
4022 4069
4023 Local<String> v8::String::NewExternal( 4070 Local<String> v8::String::NewExternal(
4024 v8::String::ExternalAsciiStringResource* resource) { 4071 v8::String::ExternalAsciiStringResource* resource) {
4025 i::Isolate* isolate = i::Isolate::Current(); 4072 i::Isolate* isolate = i::Isolate::Current();
4026 EnsureInitializedForIsolate(isolate, "v8::String::NewExternal()"); 4073 EnsureInitializedForIsolate(isolate, "v8::String::NewExternal()");
4027 LOG_API(isolate, "String::NewExternal"); 4074 LOG_API(isolate, "String::NewExternal");
4028 ENTER_V8; 4075 ENTER_V8(isolate);
4029 i::Handle<i::String> result = NewExternalAsciiStringHandle(isolate, resource); 4076 i::Handle<i::String> result = NewExternalAsciiStringHandle(isolate, resource);
4030 isolate->heap()->external_string_table()->AddString(*result); 4077 isolate->heap()->external_string_table()->AddString(*result);
4031 return Utils::ToLocal(result); 4078 return Utils::ToLocal(result);
4032 } 4079 }
4033 4080
4034 4081
4035 bool v8::String::MakeExternal( 4082 bool v8::String::MakeExternal(
4036 v8::String::ExternalAsciiStringResource* resource) { 4083 v8::String::ExternalAsciiStringResource* resource) {
4037 i::Handle<i::String> obj = Utils::OpenHandle(this); 4084 i::Handle<i::String> obj = Utils::OpenHandle(this);
4038 i::Isolate* isolate = obj->GetIsolate(); 4085 i::Isolate* isolate = obj->GetIsolate();
4039 if (IsDeadCheck(isolate, "v8::String::MakeExternal()")) return false; 4086 if (IsDeadCheck(isolate, "v8::String::MakeExternal()")) return false;
4040 if (this->IsExternal()) return false; // Already an external string. 4087 if (i::StringShape(*obj).IsExternalTwoByte()) {
4041 ENTER_V8; 4088 return false; // Already an external string.
4089 }
4090 ENTER_V8(isolate);
4042 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { 4091 if (isolate->string_tracker()->IsFreshUnusedString(obj)) {
4043 return false; 4092 return false;
4044 } 4093 }
4045 bool result = obj->MakeExternal(resource); 4094 bool result = obj->MakeExternal(resource);
4046 if (result && !obj->IsSymbol()) { 4095 if (result && !obj->IsSymbol()) {
4047 isolate->heap()->external_string_table()->AddString(*obj); 4096 isolate->heap()->external_string_table()->AddString(*obj);
4048 } 4097 }
4049 return result; 4098 return result;
4050 } 4099 }
4051 4100
(...skipping 10 matching lines...) Expand all
4062 return false; 4111 return false;
4063 i::StringShape shape(*obj); 4112 i::StringShape shape(*obj);
4064 return !shape.IsExternal(); 4113 return !shape.IsExternal();
4065 } 4114 }
4066 4115
4067 4116
4068 Local<v8::Object> v8::Object::New() { 4117 Local<v8::Object> v8::Object::New() {
4069 i::Isolate* isolate = i::Isolate::Current(); 4118 i::Isolate* isolate = i::Isolate::Current();
4070 EnsureInitializedForIsolate(isolate, "v8::Object::New()"); 4119 EnsureInitializedForIsolate(isolate, "v8::Object::New()");
4071 LOG_API(isolate, "Object::New"); 4120 LOG_API(isolate, "Object::New");
4072 ENTER_V8; 4121 ENTER_V8(isolate);
4073 i::Handle<i::JSObject> obj = 4122 i::Handle<i::JSObject> obj =
4074 isolate->factory()->NewJSObject(i::Isolate::Current()->object_function()); 4123 isolate->factory()->NewJSObject(isolate->object_function());
4075 return Utils::ToLocal(obj); 4124 return Utils::ToLocal(obj);
4076 } 4125 }
4077 4126
4078 4127
4079 Local<v8::Value> v8::Date::New(double time) { 4128 Local<v8::Value> v8::Date::New(double time) {
4080 i::Isolate* isolate = i::Isolate::Current(); 4129 i::Isolate* isolate = i::Isolate::Current();
4081 EnsureInitializedForIsolate(isolate, "v8::Date::New()"); 4130 EnsureInitializedForIsolate(isolate, "v8::Date::New()");
4082 LOG_API(isolate, "Date::New"); 4131 LOG_API(isolate, "Date::New");
4083 if (isnan(time)) { 4132 if (isnan(time)) {
4084 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. 4133 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs.
4085 time = i::OS::nan_value(); 4134 time = i::OS::nan_value();
4086 } 4135 }
4087 ENTER_V8; 4136 ENTER_V8(isolate);
4088 EXCEPTION_PREAMBLE(); 4137 EXCEPTION_PREAMBLE(isolate);
4089 i::Handle<i::Object> obj = 4138 i::Handle<i::Object> obj =
4090 i::Execution::NewDate(time, &has_pending_exception); 4139 i::Execution::NewDate(time, &has_pending_exception);
4091 EXCEPTION_BAILOUT_CHECK(Local<v8::Value>()); 4140 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Value>());
4092 return Utils::ToLocal(obj); 4141 return Utils::ToLocal(obj);
4093 } 4142 }
4094 4143
4095 4144
4096 double v8::Date::NumberValue() const { 4145 double v8::Date::NumberValue() const {
4097 i::Isolate* isolate = i::Isolate::Current(); 4146 i::Isolate* isolate = i::Isolate::Current();
4098 if (IsDeadCheck(isolate, "v8::Date::NumberValue()")) return 0; 4147 if (IsDeadCheck(isolate, "v8::Date::NumberValue()")) return 0;
4099 LOG_API(isolate, "Date::NumberValue"); 4148 LOG_API(isolate, "Date::NumberValue");
4100 i::Handle<i::Object> obj = Utils::OpenHandle(this); 4149 i::Handle<i::Object> obj = Utils::OpenHandle(this);
4101 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); 4150 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj);
4102 return jsvalue->value()->Number(); 4151 return jsvalue->value()->Number();
4103 } 4152 }
4104 4153
4105 4154
4106 void v8::Date::DateTimeConfigurationChangeNotification() { 4155 void v8::Date::DateTimeConfigurationChangeNotification() {
4107 i::Isolate* isolate = i::Isolate::Current(); 4156 i::Isolate* isolate = i::Isolate::Current();
4108 ON_BAILOUT(isolate, "v8::Date::DateTimeConfigurationChangeNotification()", 4157 ON_BAILOUT(isolate, "v8::Date::DateTimeConfigurationChangeNotification()",
4109 return); 4158 return);
4110 LOG_API(isolate, "Date::DateTimeConfigurationChangeNotification"); 4159 LOG_API(isolate, "Date::DateTimeConfigurationChangeNotification");
4111 ENTER_V8; 4160 ENTER_V8(isolate);
4112 4161
4113 i::HandleScope scope(isolate); 4162 i::HandleScope scope(isolate);
4114 // Get the function ResetDateCache (defined in date-delay.js). 4163 // Get the function ResetDateCache (defined in date-delay.js).
4115 i::Handle<i::String> func_name_str = 4164 i::Handle<i::String> func_name_str =
4116 isolate->factory()->LookupAsciiSymbol("ResetDateCache"); 4165 isolate->factory()->LookupAsciiSymbol("ResetDateCache");
4117 i::MaybeObject* result = 4166 i::MaybeObject* result =
4118 isolate->js_builtins_object()->GetProperty(*func_name_str); 4167 isolate->js_builtins_object()->GetProperty(*func_name_str);
4119 i::Object* object_func; 4168 i::Object* object_func;
4120 if (!result->ToObject(&object_func)) { 4169 if (!result->ToObject(&object_func)) {
4121 return; 4170 return;
(...skipping 19 matching lines...) Expand all
4141 if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm'; 4190 if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm';
4142 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i'; 4191 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i';
4143 ASSERT(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf))); 4192 ASSERT(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf)));
4144 return FACTORY->LookupSymbol( 4193 return FACTORY->LookupSymbol(
4145 i::Vector<const char>(flags_buf, num_flags)); 4194 i::Vector<const char>(flags_buf, num_flags));
4146 } 4195 }
4147 4196
4148 4197
4149 Local<v8::RegExp> v8::RegExp::New(Handle<String> pattern, 4198 Local<v8::RegExp> v8::RegExp::New(Handle<String> pattern,
4150 Flags flags) { 4199 Flags flags) {
4151 i::Isolate* isolate = i::Isolate::Current(); 4200 i::Isolate* isolate = Utils::OpenHandle(*pattern)->GetIsolate();
4152 EnsureInitializedForIsolate(isolate, "v8::RegExp::New()"); 4201 EnsureInitializedForIsolate(isolate, "v8::RegExp::New()");
4153 LOG_API(isolate, "RegExp::New"); 4202 LOG_API(isolate, "RegExp::New");
4154 ENTER_V8; 4203 ENTER_V8(isolate);
4155 EXCEPTION_PREAMBLE(); 4204 EXCEPTION_PREAMBLE(isolate);
4156 i::Handle<i::JSRegExp> obj = i::Execution::NewJSRegExp( 4205 i::Handle<i::JSRegExp> obj = i::Execution::NewJSRegExp(
4157 Utils::OpenHandle(*pattern), 4206 Utils::OpenHandle(*pattern),
4158 RegExpFlagsToString(flags), 4207 RegExpFlagsToString(flags),
4159 &has_pending_exception); 4208 &has_pending_exception);
4160 EXCEPTION_BAILOUT_CHECK(Local<v8::RegExp>()); 4209 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::RegExp>());
4161 return Utils::ToLocal(i::Handle<i::JSRegExp>::cast(obj)); 4210 return Utils::ToLocal(i::Handle<i::JSRegExp>::cast(obj));
4162 } 4211 }
4163 4212
4164 4213
4165 Local<v8::String> v8::RegExp::GetSource() const { 4214 Local<v8::String> v8::RegExp::GetSource() const {
4166 i::Isolate* isolate = i::Isolate::Current(); 4215 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4167 if (IsDeadCheck(isolate, "v8::RegExp::GetSource()")) { 4216 if (IsDeadCheck(isolate, "v8::RegExp::GetSource()")) {
4168 return Local<v8::String>(); 4217 return Local<v8::String>();
4169 } 4218 }
4170 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); 4219 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this);
4171 return Utils::ToLocal(i::Handle<i::String>(obj->Pattern())); 4220 return Utils::ToLocal(i::Handle<i::String>(obj->Pattern()));
4172 } 4221 }
4173 4222
4174 4223
4175 // Assert that the static flags cast in GetFlags is valid. 4224 // Assert that the static flags cast in GetFlags is valid.
4176 #define REGEXP_FLAG_ASSERT_EQ(api_flag, internal_flag) \ 4225 #define REGEXP_FLAG_ASSERT_EQ(api_flag, internal_flag) \
(...skipping 11 matching lines...) Expand all
4188 } 4237 }
4189 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); 4238 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this);
4190 return static_cast<RegExp::Flags>(obj->GetFlags().value()); 4239 return static_cast<RegExp::Flags>(obj->GetFlags().value());
4191 } 4240 }
4192 4241
4193 4242
4194 Local<v8::Array> v8::Array::New(int length) { 4243 Local<v8::Array> v8::Array::New(int length) {
4195 i::Isolate* isolate = i::Isolate::Current(); 4244 i::Isolate* isolate = i::Isolate::Current();
4196 EnsureInitializedForIsolate(isolate, "v8::Array::New()"); 4245 EnsureInitializedForIsolate(isolate, "v8::Array::New()");
4197 LOG_API(isolate, "Array::New"); 4246 LOG_API(isolate, "Array::New");
4198 ENTER_V8; 4247 ENTER_V8(isolate);
4199 int real_length = length > 0 ? length : 0; 4248 int real_length = length > 0 ? length : 0;
4200 i::Handle<i::JSArray> obj = isolate->factory()->NewJSArray(real_length); 4249 i::Handle<i::JSArray> obj = isolate->factory()->NewJSArray(real_length);
4201 obj->set_length(*isolate->factory()->NewNumberFromInt(real_length)); 4250 obj->set_length(*isolate->factory()->NewNumberFromInt(real_length));
4202 return Utils::ToLocal(obj); 4251 return Utils::ToLocal(obj);
4203 } 4252 }
4204 4253
4205 4254
4206 uint32_t v8::Array::Length() const { 4255 uint32_t v8::Array::Length() const {
4207 i::Isolate* isolate = i::Isolate::Current(); 4256 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4208 if (IsDeadCheck(isolate, "v8::Array::Length()")) return 0; 4257 if (IsDeadCheck(isolate, "v8::Array::Length()")) return 0;
4209 i::Handle<i::JSArray> obj = Utils::OpenHandle(this); 4258 i::Handle<i::JSArray> obj = Utils::OpenHandle(this);
4210 i::Object* length = obj->length(); 4259 i::Object* length = obj->length();
4211 if (length->IsSmi()) { 4260 if (length->IsSmi()) {
4212 return i::Smi::cast(length)->value(); 4261 return i::Smi::cast(length)->value();
4213 } else { 4262 } else {
4214 return static_cast<uint32_t>(length->Number()); 4263 return static_cast<uint32_t>(length->Number());
4215 } 4264 }
4216 } 4265 }
4217 4266
4218 4267
4219 Local<Object> Array::CloneElementAt(uint32_t index) { 4268 Local<Object> Array::CloneElementAt(uint32_t index) {
4220 i::Isolate* isolate = i::Isolate::Current(); 4269 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4221 ON_BAILOUT(isolate, "v8::Array::CloneElementAt()", return Local<Object>()); 4270 ON_BAILOUT(isolate, "v8::Array::CloneElementAt()", return Local<Object>());
4222 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 4271 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
4223 if (!self->HasFastElements()) { 4272 if (!self->HasFastElements()) {
4224 return Local<Object>(); 4273 return Local<Object>();
4225 } 4274 }
4226 i::FixedArray* elms = i::FixedArray::cast(self->elements()); 4275 i::FixedArray* elms = i::FixedArray::cast(self->elements());
4227 i::Object* paragon = elms->get(index); 4276 i::Object* paragon = elms->get(index);
4228 if (!paragon->IsJSObject()) { 4277 if (!paragon->IsJSObject()) {
4229 return Local<Object>(); 4278 return Local<Object>();
4230 } 4279 }
4231 i::Handle<i::JSObject> paragon_handle(i::JSObject::cast(paragon)); 4280 i::Handle<i::JSObject> paragon_handle(i::JSObject::cast(paragon));
4232 EXCEPTION_PREAMBLE(); 4281 EXCEPTION_PREAMBLE(isolate);
4233 ENTER_V8; 4282 ENTER_V8(isolate);
4234 i::Handle<i::JSObject> result = i::Copy(paragon_handle); 4283 i::Handle<i::JSObject> result = i::Copy(paragon_handle);
4235 has_pending_exception = result.is_null(); 4284 has_pending_exception = result.is_null();
4236 EXCEPTION_BAILOUT_CHECK(Local<Object>()); 4285 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>());
4237 return Utils::ToLocal(result); 4286 return Utils::ToLocal(result);
4238 } 4287 }
4239 4288
4240 4289
4241 Local<String> v8::String::NewSymbol(const char* data, int length) { 4290 Local<String> v8::String::NewSymbol(const char* data, int length) {
4242 i::Isolate* isolate = i::Isolate::Current(); 4291 i::Isolate* isolate = i::Isolate::Current();
4243 EnsureInitializedForIsolate(isolate, "v8::String::NewSymbol()"); 4292 EnsureInitializedForIsolate(isolate, "v8::String::NewSymbol()");
4244 LOG_API(isolate, "String::NewSymbol(char)"); 4293 LOG_API(isolate, "String::NewSymbol(char)");
4245 ENTER_V8; 4294 ENTER_V8(isolate);
4246 if (length == -1) length = i::StrLength(data); 4295 if (length == -1) length = i::StrLength(data);
4247 i::Handle<i::String> result = 4296 i::Handle<i::String> result =
4248 FACTORY->LookupSymbol(i::Vector<const char>(data, length)); 4297 isolate->factory()->LookupSymbol(i::Vector<const char>(data, length));
4249 return Utils::ToLocal(result); 4298 return Utils::ToLocal(result);
4250 } 4299 }
4251 4300
4252 4301
4253 Local<Number> v8::Number::New(double value) { 4302 Local<Number> v8::Number::New(double value) {
4254 i::Isolate* isolate = i::Isolate::Current(); 4303 i::Isolate* isolate = i::Isolate::Current();
4255 EnsureInitializedForIsolate(isolate, "v8::Number::New()"); 4304 EnsureInitializedForIsolate(isolate, "v8::Number::New()");
4256 if (isnan(value)) { 4305 if (isnan(value)) {
4257 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. 4306 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs.
4258 value = i::OS::nan_value(); 4307 value = i::OS::nan_value();
4259 } 4308 }
4260 ENTER_V8; 4309 ENTER_V8(isolate);
4261 i::Handle<i::Object> result = isolate->factory()->NewNumber(value); 4310 i::Handle<i::Object> result = isolate->factory()->NewNumber(value);
4262 return Utils::NumberToLocal(result); 4311 return Utils::NumberToLocal(result);
4263 } 4312 }
4264 4313
4265 4314
4266 Local<Integer> v8::Integer::New(int32_t value) { 4315 Local<Integer> v8::Integer::New(int32_t value) {
4267 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); 4316 i::Isolate* isolate = i::Isolate::UncheckedCurrent();
4268 EnsureInitializedForIsolate(isolate, "v8::Integer::New()"); 4317 EnsureInitializedForIsolate(isolate, "v8::Integer::New()");
4269 if (i::Smi::IsValid(value)) { 4318 if (i::Smi::IsValid(value)) {
4270 return Utils::IntegerToLocal(i::Handle<i::Object>(i::Smi::FromInt(value), 4319 return Utils::IntegerToLocal(i::Handle<i::Object>(i::Smi::FromInt(value),
4271 isolate)); 4320 isolate));
4272 } 4321 }
4273 ENTER_V8; 4322 ENTER_V8(isolate);
4274 i::Handle<i::Object> result = isolate->factory()->NewNumber(value); 4323 i::Handle<i::Object> result = isolate->factory()->NewNumber(value);
4275 return Utils::IntegerToLocal(result); 4324 return Utils::IntegerToLocal(result);
4276 } 4325 }
4277 4326
4278 4327
4279 Local<Integer> Integer::NewFromUnsigned(uint32_t value) { 4328 Local<Integer> Integer::NewFromUnsigned(uint32_t value) {
4280 bool fits_into_int32_t = (value & (1 << 31)) == 0; 4329 bool fits_into_int32_t = (value & (1 << 31)) == 0;
4281 if (fits_into_int32_t) { 4330 if (fits_into_int32_t) {
4282 return Integer::New(static_cast<int32_t>(value)); 4331 return Integer::New(static_cast<int32_t>(value));
4283 } 4332 }
4284 ENTER_V8; 4333 i::Isolate* isolate = i::Isolate::Current();
4285 i::Handle<i::Object> result = FACTORY->NewNumber(value); 4334 ENTER_V8(isolate);
4335 i::Handle<i::Object> result = isolate->factory()->NewNumber(value);
4286 return Utils::IntegerToLocal(result); 4336 return Utils::IntegerToLocal(result);
4287 } 4337 }
4288 4338
4289 4339
4290 void V8::IgnoreOutOfMemoryException() { 4340 void V8::IgnoreOutOfMemoryException() {
4291 EnterIsolateIfNeeded()->handle_scope_implementer()->set_ignore_out_of_memory( 4341 EnterIsolateIfNeeded()->handle_scope_implementer()->set_ignore_out_of_memory(
4292 true); 4342 true);
4293 } 4343 }
4294 4344
4295 4345
4296 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) { 4346 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) {
4297 i::Isolate* isolate = i::Isolate::Current(); 4347 i::Isolate* isolate = i::Isolate::Current();
4298 EnsureInitializedForIsolate(isolate, "v8::V8::AddMessageListener()"); 4348 EnsureInitializedForIsolate(isolate, "v8::V8::AddMessageListener()");
4299 ON_BAILOUT(isolate, "v8::V8::AddMessageListener()", return false); 4349 ON_BAILOUT(isolate, "v8::V8::AddMessageListener()", return false);
4300 ENTER_V8; 4350 ENTER_V8(isolate);
4301 i::HandleScope scope(isolate); 4351 i::HandleScope scope(isolate);
4302 NeanderArray listeners(isolate->factory()->message_listeners()); 4352 NeanderArray listeners(isolate->factory()->message_listeners());
4303 NeanderObject obj(2); 4353 NeanderObject obj(2);
4304 obj.set(0, *isolate->factory()->NewProxy(FUNCTION_ADDR(that))); 4354 obj.set(0, *isolate->factory()->NewProxy(FUNCTION_ADDR(that)));
4305 obj.set(1, data.IsEmpty() ? 4355 obj.set(1, data.IsEmpty() ?
4306 HEAP->undefined_value() : 4356 HEAP->undefined_value() :
4307 *Utils::OpenHandle(*data)); 4357 *Utils::OpenHandle(*data));
4308 listeners.add(obj.value()); 4358 listeners.add(obj.value());
4309 return true; 4359 return true;
4310 } 4360 }
4311 4361
4312 4362
4313 void V8::RemoveMessageListeners(MessageCallback that) { 4363 void V8::RemoveMessageListeners(MessageCallback that) {
4314 i::Isolate* isolate = i::Isolate::Current(); 4364 i::Isolate* isolate = i::Isolate::Current();
4315 EnsureInitializedForIsolate(isolate, "v8::V8::RemoveMessageListener()"); 4365 EnsureInitializedForIsolate(isolate, "v8::V8::RemoveMessageListener()");
4316 ON_BAILOUT(isolate, "v8::V8::RemoveMessageListeners()", return); 4366 ON_BAILOUT(isolate, "v8::V8::RemoveMessageListeners()", return);
4317 ENTER_V8; 4367 ENTER_V8(isolate);
4318 i::HandleScope scope(isolate); 4368 i::HandleScope scope(isolate);
4319 NeanderArray listeners(isolate->factory()->message_listeners()); 4369 NeanderArray listeners(isolate->factory()->message_listeners());
4320 for (int i = 0; i < listeners.length(); i++) { 4370 for (int i = 0; i < listeners.length(); i++) {
4321 if (listeners.get(i)->IsUndefined()) continue; // skip deleted ones 4371 if (listeners.get(i)->IsUndefined()) continue; // skip deleted ones
4322 4372
4323 NeanderObject listener(i::JSObject::cast(listeners.get(i))); 4373 NeanderObject listener(i::JSObject::cast(listeners.get(i)));
4324 i::Handle<i::Proxy> callback_obj(i::Proxy::cast(listener.get(0))); 4374 i::Handle<i::Proxy> callback_obj(i::Proxy::cast(listener.get(0)));
4325 if (callback_obj->proxy() == FUNCTION_ADDR(that)) { 4375 if (callback_obj->proxy() == FUNCTION_ADDR(that)) {
4326 listeners.set(i, HEAP->undefined_value()); 4376 listeners.set(i, HEAP->undefined_value());
4327 } 4377 }
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
4532 int V8::GetLogLines(int from_pos, char* dest_buf, int max_size) { 4582 int V8::GetLogLines(int from_pos, char* dest_buf, int max_size) {
4533 #ifdef ENABLE_LOGGING_AND_PROFILING 4583 #ifdef ENABLE_LOGGING_AND_PROFILING
4534 ASSERT(max_size >= kMinimumSizeForLogLinesBuffer); 4584 ASSERT(max_size >= kMinimumSizeForLogLinesBuffer);
4535 return LOGGER->GetLogLines(from_pos, dest_buf, max_size); 4585 return LOGGER->GetLogLines(from_pos, dest_buf, max_size);
4536 #endif 4586 #endif
4537 return 0; 4587 return 0;
4538 } 4588 }
4539 4589
4540 4590
4541 int V8::GetCurrentThreadId() { 4591 int V8::GetCurrentThreadId() {
4592 i::Isolate* isolate = i::Isolate::Current();
4542 API_ENTRY_CHECK("V8::GetCurrentThreadId()"); 4593 API_ENTRY_CHECK("V8::GetCurrentThreadId()");
4543 EnsureInitialized("V8::GetCurrentThreadId()"); 4594 EnsureInitializedForIsolate(isolate, "V8::GetCurrentThreadId()");
4544 return i::Isolate::Current()->thread_id(); 4595 return isolate->thread_id();
4545 } 4596 }
4546 4597
4547 4598
4548 void V8::TerminateExecution(int thread_id) { 4599 void V8::TerminateExecution(int thread_id) {
4549 if (!i::Isolate::Current()->IsInitialized()) return; 4600 i::Isolate* isolate = i::Isolate::Current();
4601 if (!isolate->IsInitialized()) return;
4550 API_ENTRY_CHECK("V8::GetCurrentThreadId()"); 4602 API_ENTRY_CHECK("V8::GetCurrentThreadId()");
4551 i::Isolate* isolate = i::Isolate::Current();
4552 // If the thread_id identifies the current thread just terminate 4603 // If the thread_id identifies the current thread just terminate
4553 // execution right away. Otherwise, ask the thread manager to 4604 // execution right away. Otherwise, ask the thread manager to
4554 // terminate the thread with the given id if any. 4605 // terminate the thread with the given id if any.
4555 if (thread_id == isolate->thread_id()) { 4606 if (thread_id == isolate->thread_id()) {
4556 isolate->stack_guard()->TerminateExecution(); 4607 isolate->stack_guard()->TerminateExecution();
4557 } else { 4608 } else {
4558 isolate->thread_manager()->TerminateExecution(thread_id); 4609 isolate->thread_manager()->TerminateExecution(thread_id);
4559 } 4610 }
4560 } 4611 }
4561 4612
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
4609 } 4660 }
4610 4661
4611 4662
4612 void Isolate::Exit() { 4663 void Isolate::Exit() {
4613 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); 4664 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
4614 isolate->Exit(); 4665 isolate->Exit();
4615 } 4666 }
4616 4667
4617 4668
4618 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) { 4669 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) {
4619 EnsureInitialized("v8::String::Utf8Value::Utf8Value()"); 4670 i::Isolate* isolate = i::Isolate::Current();
4671 if (IsDeadCheck(isolate, "v8::String::Utf8Value::Utf8Value()")) return;
4620 if (obj.IsEmpty()) { 4672 if (obj.IsEmpty()) {
4621 str_ = NULL; 4673 str_ = NULL;
4622 length_ = 0; 4674 length_ = 0;
4623 return; 4675 return;
4624 } 4676 }
4625 ENTER_V8; 4677 ENTER_V8(isolate);
4626 HandleScope scope; 4678 i::HandleScope scope(isolate);
4627 TryCatch try_catch; 4679 TryCatch try_catch;
4628 Handle<String> str = obj->ToString(); 4680 Handle<String> str = obj->ToString();
4629 if (str.IsEmpty()) { 4681 if (str.IsEmpty()) {
4630 str_ = NULL; 4682 str_ = NULL;
4631 length_ = 0; 4683 length_ = 0;
4632 } else { 4684 } else {
4633 length_ = str->Utf8Length(); 4685 length_ = str->Utf8Length();
4634 str_ = i::NewArray<char>(length_ + 1); 4686 str_ = i::NewArray<char>(length_ + 1);
4635 str->WriteUtf8(str_); 4687 str->WriteUtf8(str_);
4636 } 4688 }
4637 } 4689 }
4638 4690
4639 4691
4640 String::Utf8Value::~Utf8Value() { 4692 String::Utf8Value::~Utf8Value() {
4641 i::DeleteArray(str_); 4693 i::DeleteArray(str_);
4642 } 4694 }
4643 4695
4644 4696
4645 String::AsciiValue::AsciiValue(v8::Handle<v8::Value> obj) { 4697 String::AsciiValue::AsciiValue(v8::Handle<v8::Value> obj) {
4646 EnsureInitialized("v8::String::AsciiValue::AsciiValue()"); 4698 i::Isolate* isolate = i::Isolate::Current();
4699 if (IsDeadCheck(isolate, "v8::String::AsciiValue::AsciiValue()")) return;
4647 if (obj.IsEmpty()) { 4700 if (obj.IsEmpty()) {
4648 str_ = NULL; 4701 str_ = NULL;
4649 length_ = 0; 4702 length_ = 0;
4650 return; 4703 return;
4651 } 4704 }
4652 ENTER_V8; 4705 ENTER_V8(isolate);
4653 HandleScope scope; 4706 i::HandleScope scope(isolate);
4654 TryCatch try_catch; 4707 TryCatch try_catch;
4655 Handle<String> str = obj->ToString(); 4708 Handle<String> str = obj->ToString();
4656 if (str.IsEmpty()) { 4709 if (str.IsEmpty()) {
4657 str_ = NULL; 4710 str_ = NULL;
4658 length_ = 0; 4711 length_ = 0;
4659 } else { 4712 } else {
4660 length_ = str->Length(); 4713 length_ = str->Length();
4661 str_ = i::NewArray<char>(length_ + 1); 4714 str_ = i::NewArray<char>(length_ + 1);
4662 str->WriteAscii(str_); 4715 str->WriteAscii(str_);
4663 } 4716 }
4664 } 4717 }
4665 4718
4666 4719
4667 String::AsciiValue::~AsciiValue() { 4720 String::AsciiValue::~AsciiValue() {
4668 i::DeleteArray(str_); 4721 i::DeleteArray(str_);
4669 } 4722 }
4670 4723
4671 4724
4672 String::Value::Value(v8::Handle<v8::Value> obj) { 4725 String::Value::Value(v8::Handle<v8::Value> obj) {
4673 EnsureInitialized("v8::String::Value::Value()"); 4726 i::Isolate* isolate = i::Isolate::Current();
4727 if (IsDeadCheck(isolate, "v8::String::Value::Value()")) return;
4674 if (obj.IsEmpty()) { 4728 if (obj.IsEmpty()) {
4675 str_ = NULL; 4729 str_ = NULL;
4676 length_ = 0; 4730 length_ = 0;
4677 return; 4731 return;
4678 } 4732 }
4679 ENTER_V8; 4733 ENTER_V8(isolate);
4680 HandleScope scope; 4734 i::HandleScope scope(isolate);
4681 TryCatch try_catch; 4735 TryCatch try_catch;
4682 Handle<String> str = obj->ToString(); 4736 Handle<String> str = obj->ToString();
4683 if (str.IsEmpty()) { 4737 if (str.IsEmpty()) {
4684 str_ = NULL; 4738 str_ = NULL;
4685 length_ = 0; 4739 length_ = 0;
4686 } else { 4740 } else {
4687 length_ = str->Length(); 4741 length_ = str->Length();
4688 str_ = i::NewArray<uint16_t>(length_ + 1); 4742 str_ = i::NewArray<uint16_t>(length_ + 1);
4689 str->Write(str_); 4743 str->Write(str_);
4690 } 4744 }
4691 } 4745 }
4692 4746
4693 4747
4694 String::Value::~Value() { 4748 String::Value::~Value() {
4695 i::DeleteArray(str_); 4749 i::DeleteArray(str_);
4696 } 4750 }
4697 4751
4698 Local<Value> Exception::RangeError(v8::Handle<v8::String> raw_message) { 4752 Local<Value> Exception::RangeError(v8::Handle<v8::String> raw_message) {
4699 i::Isolate* isolate = i::Isolate::Current(); 4753 i::Isolate* isolate = i::Isolate::Current();
4700 LOG_API(isolate, "RangeError"); 4754 LOG_API(isolate, "RangeError");
4701 ON_BAILOUT(isolate, "v8::Exception::RangeError()", return Local<Value>()); 4755 ON_BAILOUT(isolate, "v8::Exception::RangeError()", return Local<Value>());
4702 ENTER_V8; 4756 ENTER_V8(isolate);
4703 i::Object* error; 4757 i::Object* error;
4704 { 4758 {
4705 i::HandleScope scope(isolate); 4759 i::HandleScope scope(isolate);
4706 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); 4760 i::Handle<i::String> message = Utils::OpenHandle(*raw_message);
4707 i::Handle<i::Object> result = FACTORY->NewRangeError(message); 4761 i::Handle<i::Object> result = FACTORY->NewRangeError(message);
4708 error = *result; 4762 error = *result;
4709 } 4763 }
4710 i::Handle<i::Object> result(error); 4764 i::Handle<i::Object> result(error);
4711 return Utils::ToLocal(result); 4765 return Utils::ToLocal(result);
4712 } 4766 }
4713 4767
4714 Local<Value> Exception::ReferenceError(v8::Handle<v8::String> raw_message) { 4768 Local<Value> Exception::ReferenceError(v8::Handle<v8::String> raw_message) {
4715 i::Isolate* isolate = i::Isolate::Current(); 4769 i::Isolate* isolate = i::Isolate::Current();
4716 LOG_API(isolate, "ReferenceError"); 4770 LOG_API(isolate, "ReferenceError");
4717 ON_BAILOUT(isolate, "v8::Exception::ReferenceError()", return Local<Value>()); 4771 ON_BAILOUT(isolate, "v8::Exception::ReferenceError()", return Local<Value>());
4718 ENTER_V8; 4772 ENTER_V8(isolate);
4719 i::Object* error; 4773 i::Object* error;
4720 { 4774 {
4721 i::HandleScope scope(isolate); 4775 i::HandleScope scope(isolate);
4722 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); 4776 i::Handle<i::String> message = Utils::OpenHandle(*raw_message);
4723 i::Handle<i::Object> result = FACTORY->NewReferenceError(message); 4777 i::Handle<i::Object> result = FACTORY->NewReferenceError(message);
4724 error = *result; 4778 error = *result;
4725 } 4779 }
4726 i::Handle<i::Object> result(error); 4780 i::Handle<i::Object> result(error);
4727 return Utils::ToLocal(result); 4781 return Utils::ToLocal(result);
4728 } 4782 }
4729 4783
4730 Local<Value> Exception::SyntaxError(v8::Handle<v8::String> raw_message) { 4784 Local<Value> Exception::SyntaxError(v8::Handle<v8::String> raw_message) {
4731 i::Isolate* isolate = i::Isolate::Current(); 4785 i::Isolate* isolate = i::Isolate::Current();
4732 LOG_API(isolate, "SyntaxError"); 4786 LOG_API(isolate, "SyntaxError");
4733 ON_BAILOUT(isolate, "v8::Exception::SyntaxError()", return Local<Value>()); 4787 ON_BAILOUT(isolate, "v8::Exception::SyntaxError()", return Local<Value>());
4734 ENTER_V8; 4788 ENTER_V8(isolate);
4735 i::Object* error; 4789 i::Object* error;
4736 { 4790 {
4737 i::HandleScope scope(isolate); 4791 i::HandleScope scope(isolate);
4738 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); 4792 i::Handle<i::String> message = Utils::OpenHandle(*raw_message);
4739 i::Handle<i::Object> result = FACTORY->NewSyntaxError(message); 4793 i::Handle<i::Object> result = FACTORY->NewSyntaxError(message);
4740 error = *result; 4794 error = *result;
4741 } 4795 }
4742 i::Handle<i::Object> result(error); 4796 i::Handle<i::Object> result(error);
4743 return Utils::ToLocal(result); 4797 return Utils::ToLocal(result);
4744 } 4798 }
4745 4799
4746 Local<Value> Exception::TypeError(v8::Handle<v8::String> raw_message) { 4800 Local<Value> Exception::TypeError(v8::Handle<v8::String> raw_message) {
4747 i::Isolate* isolate = i::Isolate::Current(); 4801 i::Isolate* isolate = i::Isolate::Current();
4748 LOG_API(isolate, "TypeError"); 4802 LOG_API(isolate, "TypeError");
4749 ON_BAILOUT(isolate, "v8::Exception::TypeError()", return Local<Value>()); 4803 ON_BAILOUT(isolate, "v8::Exception::TypeError()", return Local<Value>());
4750 ENTER_V8; 4804 ENTER_V8(isolate);
4751 i::Object* error; 4805 i::Object* error;
4752 { 4806 {
4753 i::HandleScope scope(isolate); 4807 i::HandleScope scope(isolate);
4754 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); 4808 i::Handle<i::String> message = Utils::OpenHandle(*raw_message);
4755 i::Handle<i::Object> result = FACTORY->NewTypeError(message); 4809 i::Handle<i::Object> result = FACTORY->NewTypeError(message);
4756 error = *result; 4810 error = *result;
4757 } 4811 }
4758 i::Handle<i::Object> result(error); 4812 i::Handle<i::Object> result(error);
4759 return Utils::ToLocal(result); 4813 return Utils::ToLocal(result);
4760 } 4814 }
4761 4815
4762 Local<Value> Exception::Error(v8::Handle<v8::String> raw_message) { 4816 Local<Value> Exception::Error(v8::Handle<v8::String> raw_message) {
4763 i::Isolate* isolate = i::Isolate::Current(); 4817 i::Isolate* isolate = i::Isolate::Current();
4764 LOG_API(isolate, "Error"); 4818 LOG_API(isolate, "Error");
4765 ON_BAILOUT(isolate, "v8::Exception::Error()", return Local<Value>()); 4819 ON_BAILOUT(isolate, "v8::Exception::Error()", return Local<Value>());
4766 ENTER_V8; 4820 ENTER_V8(isolate);
4767 i::Object* error; 4821 i::Object* error;
4768 { 4822 {
4769 i::HandleScope scope(isolate); 4823 i::HandleScope scope(isolate);
4770 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); 4824 i::Handle<i::String> message = Utils::OpenHandle(*raw_message);
4771 i::Handle<i::Object> result = FACTORY->NewError(message); 4825 i::Handle<i::Object> result = FACTORY->NewError(message);
4772 error = *result; 4826 error = *result;
4773 } 4827 }
4774 i::Handle<i::Object> result(error); 4828 i::Handle<i::Object> result(error);
4775 return Utils::ToLocal(result); 4829 return Utils::ToLocal(result);
4776 } 4830 }
(...skipping 11 matching lines...) Expand all
4788 event_details.GetEventData(), 4842 event_details.GetEventData(),
4789 event_details.GetCallbackData()); 4843 event_details.GetCallbackData());
4790 } 4844 }
4791 } 4845 }
4792 4846
4793 4847
4794 bool Debug::SetDebugEventListener(EventCallback that, Handle<Value> data) { 4848 bool Debug::SetDebugEventListener(EventCallback that, Handle<Value> data) {
4795 i::Isolate* isolate = i::Isolate::Current(); 4849 i::Isolate* isolate = i::Isolate::Current();
4796 EnsureInitializedForIsolate(isolate, "v8::Debug::SetDebugEventListener()"); 4850 EnsureInitializedForIsolate(isolate, "v8::Debug::SetDebugEventListener()");
4797 ON_BAILOUT(isolate, "v8::Debug::SetDebugEventListener()", return false); 4851 ON_BAILOUT(isolate, "v8::Debug::SetDebugEventListener()", return false);
4798 ENTER_V8; 4852 ENTER_V8(isolate);
4799 4853
4800 isolate->set_debug_event_callback(that); 4854 isolate->set_debug_event_callback(that);
4801 4855
4802 i::HandleScope scope(isolate); 4856 i::HandleScope scope(isolate);
4803 i::Handle<i::Object> proxy = isolate->factory()->undefined_value(); 4857 i::Handle<i::Object> proxy = isolate->factory()->undefined_value();
4804 if (that != NULL) { 4858 if (that != NULL) {
4805 proxy = isolate->factory()->NewProxy(FUNCTION_ADDR(EventCallbackWrapper)); 4859 proxy = isolate->factory()->NewProxy(FUNCTION_ADDR(EventCallbackWrapper));
4806 } 4860 }
4807 isolate->debugger()->SetEventListener(proxy, Utils::OpenHandle(*data)); 4861 isolate->debugger()->SetEventListener(proxy, Utils::OpenHandle(*data));
4808 return true; 4862 return true;
4809 } 4863 }
4810 4864
4811 4865
4812 bool Debug::SetDebugEventListener2(EventCallback2 that, Handle<Value> data) { 4866 bool Debug::SetDebugEventListener2(EventCallback2 that, Handle<Value> data) {
4813 i::Isolate* isolate = i::Isolate::Current(); 4867 i::Isolate* isolate = i::Isolate::Current();
4814 EnsureInitializedForIsolate(isolate, "v8::Debug::SetDebugEventListener2()"); 4868 EnsureInitializedForIsolate(isolate, "v8::Debug::SetDebugEventListener2()");
4815 ON_BAILOUT(isolate, "v8::Debug::SetDebugEventListener2()", return false); 4869 ON_BAILOUT(isolate, "v8::Debug::SetDebugEventListener2()", return false);
4816 ENTER_V8; 4870 ENTER_V8(isolate);
4817 i::HandleScope scope(isolate); 4871 i::HandleScope scope(isolate);
4818 i::Handle<i::Object> proxy = isolate->factory()->undefined_value(); 4872 i::Handle<i::Object> proxy = isolate->factory()->undefined_value();
4819 if (that != NULL) { 4873 if (that != NULL) {
4820 proxy = isolate->factory()->NewProxy(FUNCTION_ADDR(that)); 4874 proxy = isolate->factory()->NewProxy(FUNCTION_ADDR(that));
4821 } 4875 }
4822 isolate->debugger()->SetEventListener(proxy, 4876 isolate->debugger()->SetEventListener(proxy,
4823 Utils::OpenHandle(*data)); 4877 Utils::OpenHandle(*data));
4824 return true; 4878 return true;
4825 } 4879 }
4826 4880
4827 4881
4828 bool Debug::SetDebugEventListener(v8::Handle<v8::Object> that, 4882 bool Debug::SetDebugEventListener(v8::Handle<v8::Object> that,
4829 Handle<Value> data) { 4883 Handle<Value> data) {
4830 i::Isolate* isolate = i::Isolate::Current(); 4884 i::Isolate* isolate = i::Isolate::Current();
4831 ON_BAILOUT(isolate, "v8::Debug::SetDebugEventListener()", return false); 4885 ON_BAILOUT(isolate, "v8::Debug::SetDebugEventListener()", return false);
4832 ENTER_V8; 4886 ENTER_V8(isolate);
4833 isolate->debugger()->SetEventListener(Utils::OpenHandle(*that), 4887 isolate->debugger()->SetEventListener(Utils::OpenHandle(*that),
4834 Utils::OpenHandle(*data)); 4888 Utils::OpenHandle(*data));
4835 return true; 4889 return true;
4836 } 4890 }
4837 4891
4838 4892
4839 void Debug::DebugBreak(Isolate* isolate) { 4893 void Debug::DebugBreak(Isolate* isolate) {
4840 // If no isolate is supplied, use the default isolate. 4894 // If no isolate is supplied, use the default isolate.
4841 if (isolate != NULL) { 4895 if (isolate != NULL) {
4842 reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->DebugBreak(); 4896 reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->DebugBreak();
(...skipping 29 matching lines...) Expand all
4872 i::Isolate* isolate = i::Isolate::Current(); 4926 i::Isolate* isolate = i::Isolate::Current();
4873 if (isolate->message_handler()) { 4927 if (isolate->message_handler()) {
4874 v8::String::Value json(message.GetJSON()); 4928 v8::String::Value json(message.GetJSON());
4875 (isolate->message_handler())(*json, json.length(), message.GetClientData()); 4929 (isolate->message_handler())(*json, json.length(), message.GetClientData());
4876 } 4930 }
4877 } 4931 }
4878 4932
4879 4933
4880 void Debug::SetMessageHandler(v8::Debug::MessageHandler handler, 4934 void Debug::SetMessageHandler(v8::Debug::MessageHandler handler,
4881 bool message_handler_thread) { 4935 bool message_handler_thread) {
4882 EnsureInitialized("v8::Debug::SetMessageHandler");
4883 ENTER_V8;
4884 i::Isolate* isolate = i::Isolate::Current(); 4936 i::Isolate* isolate = i::Isolate::Current();
4937 EnsureInitializedForIsolate(isolate, "v8::Debug::SetMessageHandler");
4938 ENTER_V8(isolate);
4939
4885 // Message handler thread not supported any more. Parameter temporally left in 4940 // Message handler thread not supported any more. Parameter temporally left in
4886 // the API for client compatability reasons. 4941 // the API for client compatibility reasons.
4887 CHECK(!message_handler_thread); 4942 CHECK(!message_handler_thread);
4888 4943
4889 // TODO(sgjesse) support the old message handler API through a simple wrapper. 4944 // TODO(sgjesse) support the old message handler API through a simple wrapper.
4890 isolate->set_message_handler(handler); 4945 isolate->set_message_handler(handler);
4891 if (handler != NULL) { 4946 if (handler != NULL) {
4892 i::Isolate::Current()->debugger()->SetMessageHandler(MessageHandlerWrapper); 4947 i::Isolate::Current()->debugger()->SetMessageHandler(MessageHandlerWrapper);
4893 } else { 4948 } else {
4894 i::Isolate::Current()->debugger()->SetMessageHandler(NULL); 4949 i::Isolate::Current()->debugger()->SetMessageHandler(NULL);
4895 } 4950 }
4896 } 4951 }
4897 4952
4898 4953
4899 void Debug::SetMessageHandler2(v8::Debug::MessageHandler2 handler) { 4954 void Debug::SetMessageHandler2(v8::Debug::MessageHandler2 handler) {
4900 EnsureInitialized("v8::Debug::SetMessageHandler"); 4955 i::Isolate* isolate = i::Isolate::Current();
4901 ENTER_V8; 4956 EnsureInitializedForIsolate(isolate, "v8::Debug::SetMessageHandler");
4902 i::Isolate::Current()->debugger()->SetMessageHandler(handler); 4957 ENTER_V8(isolate);
4958 isolate->debugger()->SetMessageHandler(handler);
4903 } 4959 }
4904 4960
4905 4961
4906 void Debug::SendCommand(const uint16_t* command, int length, 4962 void Debug::SendCommand(const uint16_t* command, int length,
4907 ClientData* client_data, 4963 ClientData* client_data,
4908 Isolate* isolate) { 4964 Isolate* isolate) {
4909 // If no isolate is supplied, use the default isolate. 4965 // If no isolate is supplied, use the default isolate.
4910 if (isolate != NULL) { 4966 if (isolate != NULL) {
4911 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); 4967 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
4912 internal_isolate->debugger()->ProcessCommand( 4968 internal_isolate->debugger()->ProcessCommand(
4913 i::Vector<const uint16_t>(command, length), client_data); 4969 i::Vector<const uint16_t>(command, length), client_data);
4914 } else { 4970 } else {
4915 i::Isolate::GetDefaultIsolateDebugger()->ProcessCommand( 4971 i::Isolate::GetDefaultIsolateDebugger()->ProcessCommand(
4916 i::Vector<const uint16_t>(command, length), client_data); 4972 i::Vector<const uint16_t>(command, length), client_data);
4917 } 4973 }
4918 } 4974 }
4919 4975
4920 4976
4921 void Debug::SetHostDispatchHandler(HostDispatchHandler handler, 4977 void Debug::SetHostDispatchHandler(HostDispatchHandler handler,
4922 int period) { 4978 int period) {
4923 EnsureInitialized("v8::Debug::SetHostDispatchHandler"); 4979 i::Isolate* isolate = i::Isolate::Current();
4924 ENTER_V8; 4980 EnsureInitializedForIsolate(isolate, "v8::Debug::SetHostDispatchHandler");
4925 i::Isolate::Current()->debugger()->SetHostDispatchHandler(handler, period); 4981 ENTER_V8(isolate);
4982 isolate->debugger()->SetHostDispatchHandler(handler, period);
4926 } 4983 }
4927 4984
4928 4985
4929 void Debug::SetDebugMessageDispatchHandler( 4986 void Debug::SetDebugMessageDispatchHandler(
4930 DebugMessageDispatchHandler handler, bool provide_locker) { 4987 DebugMessageDispatchHandler handler, bool provide_locker) {
4931 EnsureInitialized("v8::Debug::SetDebugMessageDispatchHandler"); 4988 i::Isolate* isolate = i::Isolate::Current();
4932 ENTER_V8; 4989 EnsureInitializedForIsolate(isolate,
4933 i::Isolate::Current()->debugger()->SetDebugMessageDispatchHandler( 4990 "v8::Debug::SetDebugMessageDispatchHandler");
4991 ENTER_V8(isolate);
4992 isolate->debugger()->SetDebugMessageDispatchHandler(
4934 handler, provide_locker); 4993 handler, provide_locker);
4935 } 4994 }
4936 4995
4937 4996
4938 Local<Value> Debug::Call(v8::Handle<v8::Function> fun, 4997 Local<Value> Debug::Call(v8::Handle<v8::Function> fun,
4939 v8::Handle<v8::Value> data) { 4998 v8::Handle<v8::Value> data) {
4940 i::Isolate* isolate = i::Isolate::Current(); 4999 i::Isolate* isolate = i::Isolate::Current();
4941 if (!isolate->IsInitialized()) return Local<Value>(); 5000 if (!isolate->IsInitialized()) return Local<Value>();
4942 ON_BAILOUT(isolate, "v8::Debug::Call()", return Local<Value>()); 5001 ON_BAILOUT(isolate, "v8::Debug::Call()", return Local<Value>());
4943 ENTER_V8; 5002 ENTER_V8(isolate);
4944 i::Handle<i::Object> result; 5003 i::Handle<i::Object> result;
4945 EXCEPTION_PREAMBLE(); 5004 EXCEPTION_PREAMBLE(isolate);
4946 if (data.IsEmpty()) { 5005 if (data.IsEmpty()) {
4947 result = 5006 result =
4948 i::Isolate::Current()->debugger()->Call(Utils::OpenHandle(*fun), 5007 isolate->debugger()->Call(Utils::OpenHandle(*fun),
4949 FACTORY->undefined_value(), 5008 isolate->factory()->undefined_value(),
4950 &has_pending_exception); 5009 &has_pending_exception);
4951 } else { 5010 } else {
4952 result = i::Isolate::Current()->debugger()->Call(Utils::OpenHandle(*fun), 5011 result = isolate->debugger()->Call(Utils::OpenHandle(*fun),
4953 Utils::OpenHandle(*data), 5012 Utils::OpenHandle(*data),
4954 &has_pending_exception); 5013 &has_pending_exception);
4955 } 5014 }
4956 EXCEPTION_BAILOUT_CHECK(Local<Value>()); 5015 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
4957 return Utils::ToLocal(result); 5016 return Utils::ToLocal(result);
4958 } 5017 }
4959 5018
4960 5019
4961 Local<Value> Debug::GetMirror(v8::Handle<v8::Value> obj) { 5020 Local<Value> Debug::GetMirror(v8::Handle<v8::Value> obj) {
4962 i::Isolate* isolate = i::Isolate::Current(); 5021 i::Isolate* isolate = i::Isolate::Current();
4963 if (!isolate->IsInitialized()) return Local<Value>(); 5022 if (!isolate->IsInitialized()) return Local<Value>();
4964 ON_BAILOUT(isolate, "v8::Debug::GetMirror()", return Local<Value>()); 5023 ON_BAILOUT(isolate, "v8::Debug::GetMirror()", return Local<Value>());
4965 ENTER_V8; 5024 ENTER_V8(isolate);
4966 v8::HandleScope scope; 5025 v8::HandleScope scope;
4967 i::Debug* isolate_debug = i::Isolate::Current()->debug(); 5026 i::Debug* isolate_debug = isolate->debug();
4968 isolate_debug->Load(); 5027 isolate_debug->Load();
4969 i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global()); 5028 i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global());
4970 i::Handle<i::String> name = FACTORY->LookupAsciiSymbol("MakeMirror"); 5029 i::Handle<i::String> name = FACTORY->LookupAsciiSymbol("MakeMirror");
4971 i::Handle<i::Object> fun_obj = i::GetProperty(debug, name); 5030 i::Handle<i::Object> fun_obj = i::GetProperty(debug, name);
4972 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(fun_obj); 5031 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(fun_obj);
4973 v8::Handle<v8::Function> v8_fun = Utils::ToLocal(fun); 5032 v8::Handle<v8::Function> v8_fun = Utils::ToLocal(fun);
4974 const int kArgc = 1; 5033 const int kArgc = 1;
4975 v8::Handle<v8::Value> argv[kArgc] = { obj }; 5034 v8::Handle<v8::Value> argv[kArgc] = { obj };
4976 EXCEPTION_PREAMBLE(); 5035 EXCEPTION_PREAMBLE(isolate);
4977 v8::Handle<v8::Value> result = v8_fun->Call(Utils::ToLocal(debug), 5036 v8::Handle<v8::Value> result = v8_fun->Call(Utils::ToLocal(debug),
4978 kArgc, 5037 kArgc,
4979 argv); 5038 argv);
4980 EXCEPTION_BAILOUT_CHECK(Local<Value>()); 5039 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
4981 return scope.Close(result); 5040 return scope.Close(result);
4982 } 5041 }
4983 5042
4984 5043
4985 bool Debug::EnableAgent(const char* name, int port, bool wait_for_connection) { 5044 bool Debug::EnableAgent(const char* name, int port, bool wait_for_connection) {
4986 return i::Isolate::Current()->debugger()->StartAgent(name, port, 5045 return i::Isolate::Current()->debugger()->StartAgent(name, port,
4987 wait_for_connection); 5046 wait_for_connection);
4988 } 5047 }
4989 5048
4990 void Debug::ProcessDebugMessages() { 5049 void Debug::ProcessDebugMessages() {
4991 i::Execution::ProcessDebugMesssages(true); 5050 i::Execution::ProcessDebugMesssages(true);
4992 } 5051 }
4993 5052
4994 Local<Context> Debug::GetDebugContext() { 5053 Local<Context> Debug::GetDebugContext() {
4995 EnsureInitialized("v8::Debug::GetDebugContext()"); 5054 i::Isolate* isolate = i::Isolate::Current();
4996 ENTER_V8; 5055 EnsureInitializedForIsolate(isolate, "v8::Debug::GetDebugContext()");
5056 ENTER_V8(isolate);
4997 return Utils::ToLocal(i::Isolate::Current()->debugger()->GetDebugContext()); 5057 return Utils::ToLocal(i::Isolate::Current()->debugger()->GetDebugContext());
4998 } 5058 }
4999 5059
5000 #endif // ENABLE_DEBUGGER_SUPPORT 5060 #endif // ENABLE_DEBUGGER_SUPPORT
5001 5061
5002 5062
5003 #ifdef ENABLE_LOGGING_AND_PROFILING 5063 #ifdef ENABLE_LOGGING_AND_PROFILING
5004 5064
5005 Handle<String> CpuProfileNode::GetFunctionName() const { 5065 Handle<String> CpuProfileNode::GetFunctionName() const {
5006 i::Isolate* isolate = i::Isolate::Current(); 5066 i::Isolate* isolate = i::Isolate::Current();
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
5654 5714
5655 5715
5656 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 5716 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
5657 HandleScopeImplementer* thread_local = 5717 HandleScopeImplementer* thread_local =
5658 reinterpret_cast<HandleScopeImplementer*>(storage); 5718 reinterpret_cast<HandleScopeImplementer*>(storage);
5659 thread_local->IterateThis(v); 5719 thread_local->IterateThis(v);
5660 return storage + ArchiveSpacePerThread(); 5720 return storage + ArchiveSpacePerThread();
5661 } 5721 }
5662 5722
5663 } } // namespace v8::internal 5723 } } // 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