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

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