v8  3.11.10(node0.8.26)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
api.cc
Go to the documentation of this file.
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 #include "api.h"
29 
30 #include <math.h> // For isnan.
31 #include <string.h> // For memcpy, strlen.
32 #include "../include/v8-debug.h"
33 #include "../include/v8-profiler.h"
34 #include "../include/v8-testing.h"
35 #include "bootstrapper.h"
36 #include "compiler.h"
37 #include "conversions-inl.h"
38 #include "counters.h"
39 #include "debug.h"
40 #include "deoptimizer.h"
41 #include "execution.h"
42 #include "global-handles.h"
43 #include "heap-profiler.h"
44 #include "messages.h"
45 #ifdef COMPRESS_STARTUP_DATA_BZ2
46 #include "natives.h"
47 #endif
48 #include "parser.h"
49 #include "platform.h"
50 #include "profile-generator-inl.h"
51 #include "property-details.h"
52 #include "property.h"
53 #include "runtime-profiler.h"
55 #include "snapshot.h"
56 #include "unicode-inl.h"
57 #include "v8threads.h"
58 #include "version.h"
59 #include "vm-state-inl.h"
60 
61 
62 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr))
63 
64 #define ENTER_V8(isolate) \
65  ASSERT((isolate)->IsInitialized()); \
66  i::VMState __state__((isolate), i::OTHER)
67 #define LEAVE_V8(isolate) \
68  i::VMState __state__((isolate), i::EXTERNAL)
69 
70 namespace v8 {
71 
72 #define ON_BAILOUT(isolate, location, code) \
73  if (IsDeadCheck(isolate, location) || \
74  IsExecutionTerminatingCheck(isolate)) { \
75  code; \
76  UNREACHABLE(); \
77  }
78 
79 
80 #define EXCEPTION_PREAMBLE(isolate) \
81  (isolate)->handle_scope_implementer()->IncrementCallDepth(); \
82  ASSERT(!(isolate)->external_caught_exception()); \
83  bool has_pending_exception = false
84 
85 
86 #define EXCEPTION_BAILOUT_CHECK_GENERIC(isolate, value, do_callback) \
87  do { \
88  i::HandleScopeImplementer* handle_scope_implementer = \
89  (isolate)->handle_scope_implementer(); \
90  handle_scope_implementer->DecrementCallDepth(); \
91  if (has_pending_exception) { \
92  if (handle_scope_implementer->CallDepthIsZero() && \
93  (isolate)->is_out_of_memory()) { \
94  if (!(isolate)->ignore_out_of_memory()) \
95  i::V8::FatalProcessOutOfMemory(NULL); \
96  } \
97  bool call_depth_is_zero = handle_scope_implementer->CallDepthIsZero(); \
98  (isolate)->OptionalRescheduleException(call_depth_is_zero); \
99  do_callback \
100  return value; \
101  } \
102  do_callback \
103  } while (false)
104 
105 
106 #define EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, value) \
107  EXCEPTION_BAILOUT_CHECK_GENERIC( \
108  isolate, value, i::V8::FireCallCompletedCallback(isolate);)
109 
110 
111 #define EXCEPTION_BAILOUT_CHECK(isolate, value) \
112  EXCEPTION_BAILOUT_CHECK_GENERIC(isolate, value, ;)
113 
114 
115 #define API_ENTRY_CHECK(isolate, msg) \
116  do { \
117  if (v8::Locker::IsActive()) { \
118  ApiCheck(isolate->thread_manager()->IsLockedByCurrentThread(), \
119  msg, \
120  "Entering the V8 API without proper locking in place"); \
121  } \
122  } while (false)
123 
124 
125 // --- E x c e p t i o n B e h a v i o r ---
126 
127 
128 static void DefaultFatalErrorHandler(const char* location,
129  const char* message) {
130  i::VMState __state__(i::Isolate::Current(), i::OTHER);
131  API_Fatal(location, message);
132 }
133 
134 
135 static FatalErrorCallback GetFatalErrorHandler() {
136  i::Isolate* isolate = i::Isolate::Current();
137  if (isolate->exception_behavior() == NULL) {
138  isolate->set_exception_behavior(DefaultFatalErrorHandler);
139  }
140  return isolate->exception_behavior();
141 }
142 
143 
144 void i::FatalProcessOutOfMemory(const char* location) {
145  i::V8::FatalProcessOutOfMemory(location, false);
146 }
147 
148 
149 // When V8 cannot allocated memory FatalProcessOutOfMemory is called.
150 // The default fatal error handler is called and execution is stopped.
151 void i::V8::FatalProcessOutOfMemory(const char* location, bool take_snapshot) {
152  i::HeapStats heap_stats;
153  int start_marker;
154  heap_stats.start_marker = &start_marker;
155  int new_space_size;
156  heap_stats.new_space_size = &new_space_size;
157  int new_space_capacity;
158  heap_stats.new_space_capacity = &new_space_capacity;
159  intptr_t old_pointer_space_size;
160  heap_stats.old_pointer_space_size = &old_pointer_space_size;
161  intptr_t old_pointer_space_capacity;
162  heap_stats.old_pointer_space_capacity = &old_pointer_space_capacity;
163  intptr_t old_data_space_size;
164  heap_stats.old_data_space_size = &old_data_space_size;
165  intptr_t old_data_space_capacity;
166  heap_stats.old_data_space_capacity = &old_data_space_capacity;
167  intptr_t code_space_size;
168  heap_stats.code_space_size = &code_space_size;
169  intptr_t code_space_capacity;
170  heap_stats.code_space_capacity = &code_space_capacity;
171  intptr_t map_space_size;
172  heap_stats.map_space_size = &map_space_size;
173  intptr_t map_space_capacity;
174  heap_stats.map_space_capacity = &map_space_capacity;
175  intptr_t cell_space_size;
176  heap_stats.cell_space_size = &cell_space_size;
177  intptr_t cell_space_capacity;
178  heap_stats.cell_space_capacity = &cell_space_capacity;
179  intptr_t lo_space_size;
180  heap_stats.lo_space_size = &lo_space_size;
181  int global_handle_count;
182  heap_stats.global_handle_count = &global_handle_count;
183  int weak_global_handle_count;
184  heap_stats.weak_global_handle_count = &weak_global_handle_count;
185  int pending_global_handle_count;
186  heap_stats.pending_global_handle_count = &pending_global_handle_count;
187  int near_death_global_handle_count;
188  heap_stats.near_death_global_handle_count = &near_death_global_handle_count;
189  int free_global_handle_count;
190  heap_stats.free_global_handle_count = &free_global_handle_count;
191  intptr_t memory_allocator_size;
192  heap_stats.memory_allocator_size = &memory_allocator_size;
193  intptr_t memory_allocator_capacity;
194  heap_stats.memory_allocator_capacity = &memory_allocator_capacity;
195  int objects_per_type[LAST_TYPE + 1] = {0};
196  heap_stats.objects_per_type = objects_per_type;
197  int size_per_type[LAST_TYPE + 1] = {0};
198  heap_stats.size_per_type = size_per_type;
199  int os_error;
200  heap_stats.os_error = &os_error;
201  int end_marker;
202  heap_stats.end_marker = &end_marker;
203  i::Isolate* isolate = i::Isolate::Current();
204  // BUG(1718):
205  // Don't use the take_snapshot since we don't support HeapIterator here
206  // without doing a special GC.
207  isolate->heap()->RecordStats(&heap_stats, false);
209  FatalErrorCallback callback = GetFatalErrorHandler();
210  {
211  LEAVE_V8(isolate);
212  callback(location, "Allocation failed - process out of memory");
213  }
214  // If the callback returns, we stop execution.
215  UNREACHABLE();
216 }
217 
218 
219 bool Utils::ReportApiFailure(const char* location, const char* message) {
220  FatalErrorCallback callback = GetFatalErrorHandler();
221  callback(location, message);
223  return false;
224 }
225 
226 
227 bool V8::IsDead() {
228  return i::V8::IsDead();
229 }
230 
231 
232 static inline bool ApiCheck(bool condition,
233  const char* location,
234  const char* message) {
235  return condition ? true : Utils::ReportApiFailure(location, message);
236 }
237 
238 
239 static bool ReportV8Dead(const char* location) {
240  FatalErrorCallback callback = GetFatalErrorHandler();
241  callback(location, "V8 is no longer usable");
242  return true;
243 }
244 
245 
246 static bool ReportEmptyHandle(const char* location) {
247  FatalErrorCallback callback = GetFatalErrorHandler();
248  callback(location, "Reading from empty handle");
249  return true;
250 }
251 
252 
265 static inline bool IsDeadCheck(i::Isolate* isolate, const char* location) {
266  return !isolate->IsInitialized()
267  && i::V8::IsDead() ? ReportV8Dead(location) : false;
268 }
269 
270 
271 static inline bool IsExecutionTerminatingCheck(i::Isolate* isolate) {
272  if (!isolate->IsInitialized()) return false;
273  if (isolate->has_scheduled_exception()) {
274  return isolate->scheduled_exception() ==
275  isolate->heap()->termination_exception();
276  }
277  return false;
278 }
279 
280 
281 static inline bool EmptyCheck(const char* location, v8::Handle<v8::Data> obj) {
282  return obj.IsEmpty() ? ReportEmptyHandle(location) : false;
283 }
284 
285 
286 static inline bool EmptyCheck(const char* location, const v8::Data* obj) {
287  return (obj == 0) ? ReportEmptyHandle(location) : false;
288 }
289 
290 // --- S t a t i c s ---
291 
292 
293 static bool InitializeHelper() {
294  if (i::Snapshot::Initialize()) return true;
295  return i::V8::Initialize(NULL);
296 }
297 
298 
299 static inline bool EnsureInitializedForIsolate(i::Isolate* isolate,
300  const char* location) {
301  if (IsDeadCheck(isolate, location)) return false;
302  if (isolate != NULL) {
303  if (isolate->IsInitialized()) return true;
304  }
305  ASSERT(isolate == i::Isolate::Current());
306  return ApiCheck(InitializeHelper(), location, "Error initializing V8");
307 }
308 
309 // Some initializing API functions are called early and may be
310 // called on a thread different from static initializer thread.
311 // If Isolate API is used, Isolate::Enter() will initialize TLS so
312 // Isolate::Current() works. If it's a legacy case, then the thread
313 // may not have TLS initialized yet. However, in initializing APIs it
314 // may be too early to call EnsureInitialized() - some pre-init
315 // parameters still have to be configured.
316 static inline i::Isolate* EnterIsolateIfNeeded() {
317  i::Isolate* isolate = i::Isolate::UncheckedCurrent();
318  if (isolate != NULL)
319  return isolate;
320 
322  isolate = i::Isolate::Current();
323  return isolate;
324 }
325 
326 
328  : raw_data(i::NewArray<char*>(V8::GetCompressedStartupDataCount())) {
329  for (int i = 0; i < V8::GetCompressedStartupDataCount(); ++i) {
330  raw_data[i] = NULL;
331  }
332 }
333 
334 
336  for (int i = 0; i < V8::GetCompressedStartupDataCount(); ++i) {
337  i::DeleteArray(raw_data[i]);
338  }
339  i::DeleteArray(raw_data);
340 }
341 
342 
344  int compressed_data_count = V8::GetCompressedStartupDataCount();
345  StartupData* compressed_data =
346  i::NewArray<StartupData>(compressed_data_count);
347  V8::GetCompressedStartupData(compressed_data);
348  for (int i = 0; i < compressed_data_count; ++i) {
349  char* decompressed = raw_data[i] =
350  i::NewArray<char>(compressed_data[i].raw_size);
351  if (compressed_data[i].compressed_size != 0) {
352  int result = DecompressData(decompressed,
353  &compressed_data[i].raw_size,
354  compressed_data[i].data,
355  compressed_data[i].compressed_size);
356  if (result != 0) return result;
357  } else {
358  ASSERT_EQ(0, compressed_data[i].raw_size);
359  }
360  compressed_data[i].data = decompressed;
361  }
362  V8::SetDecompressedStartupData(compressed_data);
363  i::DeleteArray(compressed_data);
364  return 0;
365 }
366 
367 
369 #ifdef COMPRESS_STARTUP_DATA_BZ2
370  return StartupData::kBZip2;
371 #else
373 #endif
374 }
375 
376 
383 };
384 
386 #ifdef COMPRESS_STARTUP_DATA_BZ2
388 #else
389  return 0;
390 #endif
391 }
392 
393 
395 #ifdef COMPRESS_STARTUP_DATA_BZ2
396  compressed_data[kSnapshot].data =
397  reinterpret_cast<const char*>(i::Snapshot::data());
398  compressed_data[kSnapshot].compressed_size = i::Snapshot::size();
399  compressed_data[kSnapshot].raw_size = i::Snapshot::raw_size();
400 
401  compressed_data[kSnapshotContext].data =
402  reinterpret_cast<const char*>(i::Snapshot::context_data());
403  compressed_data[kSnapshotContext].compressed_size =
406 
408  compressed_data[kLibraries].data =
409  reinterpret_cast<const char*>(libraries_source.start());
410  compressed_data[kLibraries].compressed_size = libraries_source.length();
412 
413  i::Vector<const i::byte> exp_libraries_source =
415  compressed_data[kExperimentalLibraries].data =
416  reinterpret_cast<const char*>(exp_libraries_source.start());
417  compressed_data[kExperimentalLibraries].compressed_size =
418  exp_libraries_source.length();
419  compressed_data[kExperimentalLibraries].raw_size =
421 #endif
422 }
423 
424 
425 void V8::SetDecompressedStartupData(StartupData* decompressed_data) {
426 #ifdef COMPRESS_STARTUP_DATA_BZ2
427  ASSERT_EQ(i::Snapshot::raw_size(), decompressed_data[kSnapshot].raw_size);
429  reinterpret_cast<const i::byte*>(decompressed_data[kSnapshot].data));
430 
432  decompressed_data[kSnapshotContext].raw_size);
434  reinterpret_cast<const i::byte*>(
435  decompressed_data[kSnapshotContext].data));
436 
438  decompressed_data[kLibraries].raw_size);
439  i::Vector<const char> libraries_source(
440  decompressed_data[kLibraries].data,
441  decompressed_data[kLibraries].raw_size);
442  i::Natives::SetRawScriptsSource(libraries_source);
443 
445  decompressed_data[kExperimentalLibraries].raw_size);
446  i::Vector<const char> exp_libraries_source(
447  decompressed_data[kExperimentalLibraries].data,
448  decompressed_data[kExperimentalLibraries].raw_size);
449  i::ExperimentalNatives::SetRawScriptsSource(exp_libraries_source);
450 #endif
451 }
452 
453 
455  i::Isolate* isolate = EnterIsolateIfNeeded();
456  isolate->set_exception_behavior(that);
457 }
458 
459 
462  i::Isolate* isolate = EnterIsolateIfNeeded();
463  isolate->set_allow_code_gen_callback(callback);
464 }
465 
466 
467 #ifdef DEBUG
468 void ImplementationUtilities::ZapHandleRange(i::Object** begin,
469  i::Object** end) {
470  i::HandleScope::ZapRange(begin, end);
471 }
472 #endif
473 
474 
475 void V8::SetFlagsFromString(const char* str, int length) {
476  i::FlagList::SetFlagsFromString(str, length);
477 }
478 
479 
480 void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) {
481  i::FlagList::SetFlagsFromCommandLine(argc, argv, remove_flags);
482 }
483 
484 
486  i::Isolate* isolate = i::Isolate::Current();
487  if (IsDeadCheck(isolate, "v8::ThrowException()")) {
488  return v8::Handle<Value>();
489  }
490  ENTER_V8(isolate);
491  // If we're passed an empty handle, we throw an undefined exception
492  // to deal more gracefully with out of memory situations.
493  if (value.IsEmpty()) {
494  isolate->ScheduleThrow(isolate->heap()->undefined_value());
495  } else {
496  isolate->ScheduleThrow(*Utils::OpenHandle(*value));
497  }
498  return v8::Undefined();
499 }
500 
501 
502 RegisteredExtension* RegisteredExtension::first_extension_ = NULL;
503 
504 
506  : extension_(extension) { }
507 
508 
510  that->next_ = first_extension_;
511  first_extension_ = that;
512 }
513 
514 
516  RegisteredExtension* re = first_extension_;
517  while (re != NULL) {
518  RegisteredExtension* next = re->next();
519  delete re;
520  re = next;
521  }
522 }
523 
524 
526  RegisteredExtension* extension = new RegisteredExtension(that);
528 }
529 
530 
532  const char* source,
533  int dep_count,
534  const char** deps,
535  int source_length)
536  : name_(name),
537  source_length_(source_length >= 0 ?
538  source_length :
539  (source ? static_cast<int>(strlen(source)) : 0)),
540  source_(source, source_length_),
541  dep_count_(dep_count),
542  deps_(deps),
543  auto_enable_(false) { }
544 
545 
547  i::Isolate* isolate = i::Isolate::Current();
548  if (!EnsureInitializedForIsolate(isolate, "v8::Undefined()")) {
549  return v8::Handle<v8::Primitive>();
550  }
551  return v8::Handle<Primitive>(ToApi<Primitive>(
552  isolate->factory()->undefined_value()));
553 }
554 
555 
557  i::Isolate* isolate = i::Isolate::Current();
558  if (!EnsureInitializedForIsolate(isolate, "v8::Null()")) {
559  return v8::Handle<v8::Primitive>();
560  }
561  return v8::Handle<Primitive>(
562  ToApi<Primitive>(isolate->factory()->null_value()));
563 }
564 
565 
567  i::Isolate* isolate = i::Isolate::Current();
568  if (!EnsureInitializedForIsolate(isolate, "v8::True()")) {
569  return v8::Handle<Boolean>();
570  }
571  return v8::Handle<Boolean>(
572  ToApi<Boolean>(isolate->factory()->true_value()));
573 }
574 
575 
577  i::Isolate* isolate = i::Isolate::Current();
578  if (!EnsureInitializedForIsolate(isolate, "v8::False()")) {
579  return v8::Handle<Boolean>();
580  }
581  return v8::Handle<Boolean>(
582  ToApi<Boolean>(isolate->factory()->false_value()));
583 }
584 
585 
587  : max_young_space_size_(0),
588  max_old_space_size_(0),
589  max_executable_size_(0),
590  stack_limit_(NULL) { }
591 
592 
594  i::Isolate* isolate = EnterIsolateIfNeeded();
595 
596  int young_space_size = constraints->max_young_space_size();
597  int old_gen_size = constraints->max_old_space_size();
598  int max_executable_size = constraints->max_executable_size();
599  if (young_space_size != 0 || old_gen_size != 0 || max_executable_size != 0) {
600  // After initialization it's too late to change Heap constraints.
601  ASSERT(!isolate->IsInitialized());
602  bool result = isolate->heap()->ConfigureHeap(young_space_size / 2,
603  old_gen_size,
604  max_executable_size);
605  if (!result) return false;
606  }
607  if (constraints->stack_limit() != NULL) {
608  uintptr_t limit = reinterpret_cast<uintptr_t>(constraints->stack_limit());
609  isolate->stack_guard()->SetStackLimit(limit);
610  }
611  return true;
612 }
613 
614 
615 i::Object** V8::GlobalizeReference(i::Object** obj) {
616  i::Isolate* isolate = i::Isolate::Current();
617  if (IsDeadCheck(isolate, "V8::Persistent::New")) return NULL;
618  LOG_API(isolate, "Persistent::New");
619  i::Handle<i::Object> result =
620  isolate->global_handles()->Create(*obj);
621  return result.location();
622 }
623 
624 
625 void V8::MakeWeak(i::Object** object, void* parameters,
626  WeakReferenceCallback callback) {
627  i::Isolate* isolate = i::Isolate::Current();
628  LOG_API(isolate, "MakeWeak");
629  isolate->global_handles()->MakeWeak(object, parameters,
630  callback);
631 }
632 
633 
634 void V8::ClearWeak(i::Object** obj) {
635  i::Isolate* isolate = i::Isolate::Current();
636  LOG_API(isolate, "ClearWeak");
637  isolate->global_handles()->ClearWeakness(obj);
638 }
639 
640 
641 void V8::MarkIndependent(i::Object** object) {
642  i::Isolate* isolate = i::Isolate::Current();
643  LOG_API(isolate, "MakeIndependent");
644  isolate->global_handles()->MarkIndependent(object);
645 }
646 
647 
648 bool V8::IsGlobalNearDeath(i::Object** obj) {
649  i::Isolate* isolate = i::Isolate::Current();
650  LOG_API(isolate, "IsGlobalNearDeath");
651  if (!isolate->IsInitialized()) return false;
652  return i::GlobalHandles::IsNearDeath(obj);
653 }
654 
655 
656 bool V8::IsGlobalWeak(i::Object** obj) {
657  i::Isolate* isolate = i::Isolate::Current();
658  LOG_API(isolate, "IsGlobalWeak");
659  if (!isolate->IsInitialized()) return false;
660  return i::GlobalHandles::IsWeak(obj);
661 }
662 
663 
664 void V8::DisposeGlobal(i::Object** obj) {
665  i::Isolate* isolate = i::Isolate::Current();
666  LOG_API(isolate, "DisposeGlobal");
667  if (!isolate->IsInitialized()) return;
668  isolate->global_handles()->Destroy(obj);
669 }
670 
671 // --- H a n d l e s ---
672 
673 
675  i::Isolate* isolate = i::Isolate::Current();
676  API_ENTRY_CHECK(isolate, "HandleScope::HandleScope");
678  isolate->handle_scope_data();
679  isolate_ = isolate;
680  prev_next_ = current->next;
681  prev_limit_ = current->limit;
682  is_closed_ = false;
683  current->level++;
684 }
685 
686 
688  if (!is_closed_) {
689  Leave();
690  }
691 }
692 
693 
694 void HandleScope::Leave() {
695  ASSERT(isolate_ == i::Isolate::Current());
697  isolate_->handle_scope_data();
698  current->level--;
699  ASSERT(current->level >= 0);
700  current->next = prev_next_;
701  if (current->limit != prev_limit_) {
702  current->limit = prev_limit_;
704  }
705 
706 #ifdef DEBUG
707  i::HandleScope::ZapRange(prev_next_, prev_limit_);
708 #endif
709 }
710 
711 
713  EnsureInitializedForIsolate(
714  i::Isolate::Current(), "HandleScope::NumberOfHandles");
716 }
717 
718 
720  return i::HandleScope::CreateHandle(value, i::Isolate::Current());
721 }
722 
723 
725  ASSERT(value->IsHeapObject());
726  return reinterpret_cast<i::Object**>(
727  i::HandleScope::CreateHandle(value, value->GetIsolate()));
728 }
729 
730 
733  i::Isolate* isolate = env->GetIsolate();
734  if (IsDeadCheck(isolate, "v8::Context::Enter()")) return;
735  ENTER_V8(isolate);
736 
737  isolate->handle_scope_implementer()->EnterContext(env);
738 
739  isolate->handle_scope_implementer()->SaveContext(isolate->context());
740  isolate->set_context(*env);
741 }
742 
743 
745  // Exit is essentially a static function and doesn't use the
746  // receiver, so we have to get the current isolate from the thread
747  // local.
748  i::Isolate* isolate = i::Isolate::Current();
749  if (!isolate->IsInitialized()) return;
750 
751  if (!ApiCheck(isolate->handle_scope_implementer()->LeaveLastContext(),
752  "v8::Context::Exit()",
753  "Cannot exit non-entered context")) {
754  return;
755  }
756 
757  // Content of 'last_context' could be NULL.
758  i::Context* last_context =
760  isolate->set_context(last_context);
761  isolate->set_context_exit_happened(true);
762 }
763 
764 
767  i::Isolate* isolate = env->GetIsolate();
768  if (IsDeadCheck(isolate, "v8::Context::SetData()")) return;
769  i::Handle<i::Object> raw_data = Utils::OpenHandle(*data);
770  ASSERT(env->IsGlobalContext());
771  if (env->IsGlobalContext()) {
772  env->set_data(*raw_data);
773  }
774 }
775 
776 
779  i::Isolate* isolate = env->GetIsolate();
780  if (IsDeadCheck(isolate, "v8::Context::GetData()")) {
781  return v8::Local<Value>();
782  }
783  i::Object* raw_result = NULL;
784  ASSERT(env->IsGlobalContext());
785  if (env->IsGlobalContext()) {
786  raw_result = env->data();
787  } else {
788  return Local<Value>();
789  }
790  i::Handle<i::Object> result(raw_result, isolate);
791  return Utils::ToLocal(result);
792 }
793 
794 
795 i::Object** v8::HandleScope::RawClose(i::Object** value) {
796  if (!ApiCheck(!is_closed_,
797  "v8::HandleScope::Close()",
798  "Local scope has already been closed")) {
799  return 0;
800  }
801  LOG_API(isolate_, "CloseHandleScope");
802 
803  // Read the result before popping the handle block.
804  i::Object* result = NULL;
805  if (value != NULL) {
806  result = *value;
807  }
808  is_closed_ = true;
809  Leave();
810 
811  if (value == NULL) {
812  return NULL;
813  }
814 
815  // Allocate a new handle on the previous handle block.
816  i::Handle<i::Object> handle(result);
817  return handle.location();
818 }
819 
820 
821 // --- N e a n d e r ---
822 
823 
824 // A constructor cannot easily return an error value, therefore it is necessary
825 // to check for a dead VM with ON_BAILOUT before constructing any Neander
826 // objects. To remind you about this there is no HandleScope in the
827 // NeanderObject constructor. When you add one to the site calling the
828 // constructor you should check that you ensured the VM was not dead first.
830  i::Isolate* isolate = i::Isolate::Current();
831  EnsureInitializedForIsolate(isolate, "v8::Nowhere");
832  ENTER_V8(isolate);
833  value_ = isolate->factory()->NewNeanderObject();
834  i::Handle<i::FixedArray> elements = isolate->factory()->NewFixedArray(size);
835  value_->set_elements(*elements);
836 }
837 
838 
840  return i::FixedArray::cast(value_->elements())->length();
841 }
842 
843 
845  obj_.set(0, i::Smi::FromInt(0));
846 }
847 
848 
850  return i::Smi::cast(obj_.get(0))->value();
851 }
852 
853 
855  ASSERT(0 <= offset);
856  ASSERT(offset < length());
857  return obj_.get(offset + 1);
858 }
859 
860 
861 // This method cannot easily return an error value, therefore it is necessary
862 // to check for a dead VM with ON_BAILOUT before calling it. To remind you
863 // about this there is no HandleScope in this method. When you add one to the
864 // site calling this method you should check that you ensured the VM was not
865 // dead first.
867  int length = this->length();
868  int size = obj_.size();
869  if (length == size - 1) {
870  i::Handle<i::FixedArray> new_elms = FACTORY->NewFixedArray(2 * size);
871  for (int i = 0; i < length; i++)
872  new_elms->set(i + 1, get(i));
873  obj_.value()->set_elements(*new_elms);
874  }
875  obj_.set(length + 1, *value);
876  obj_.set(0, i::Smi::FromInt(length + 1));
877 }
878 
879 
880 void NeanderArray::set(int index, i::Object* value) {
881  if (index < 0 || index >= this->length()) return;
882  obj_.set(index + 1, value);
883 }
884 
885 
886 // --- T e m p l a t e ---
887 
888 
889 static void InitializeTemplate(i::Handle<i::TemplateInfo> that, int type) {
890  that->set_tag(i::Smi::FromInt(type));
891 }
892 
893 
895  v8::PropertyAttribute attribute) {
896  i::Isolate* isolate = i::Isolate::Current();
897  if (IsDeadCheck(isolate, "v8::Template::Set()")) return;
898  ENTER_V8(isolate);
899  i::HandleScope scope(isolate);
900  i::Handle<i::Object> list(Utils::OpenHandle(this)->property_list());
901  if (list->IsUndefined()) {
902  list = NeanderArray().value();
903  Utils::OpenHandle(this)->set_property_list(*list);
904  }
905  NeanderArray array(list);
906  array.add(Utils::OpenHandle(*name));
907  array.add(Utils::OpenHandle(*value));
908  array.add(Utils::OpenHandle(*v8::Integer::New(attribute)));
909 }
910 
911 
912 // --- F u n c t i o n T e m p l a t e ---
913 static void InitializeFunctionTemplate(
916  info->set_flag(0);
917 }
918 
919 
921  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
922  if (IsDeadCheck(isolate, "v8::FunctionTemplate::PrototypeTemplate()")) {
923  return Local<ObjectTemplate>();
924  }
925  ENTER_V8(isolate);
926  i::Handle<i::Object> result(Utils::OpenHandle(this)->prototype_template());
927  if (result->IsUndefined()) {
929  Utils::OpenHandle(this)->set_prototype_template(*result);
930  }
931  return Local<ObjectTemplate>(ToApi<ObjectTemplate>(result));
932 }
933 
934 
936  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
937  if (IsDeadCheck(isolate, "v8::FunctionTemplate::Inherit()")) return;
938  ENTER_V8(isolate);
939  Utils::OpenHandle(this)->set_parent_template(*Utils::OpenHandle(*value));
940 }
941 
942 
944  v8::Handle<Value> data, v8::Handle<Signature> signature) {
945  i::Isolate* isolate = i::Isolate::Current();
946  EnsureInitializedForIsolate(isolate, "v8::FunctionTemplate::New()");
947  LOG_API(isolate, "FunctionTemplate::New");
948  ENTER_V8(isolate);
949  i::Handle<i::Struct> struct_obj =
953  InitializeFunctionTemplate(obj);
954  int next_serial_number = isolate->next_serial_number();
955  isolate->set_next_serial_number(next_serial_number + 1);
956  obj->set_serial_number(i::Smi::FromInt(next_serial_number));
957  if (callback != 0) {
958  if (data.IsEmpty()) data = v8::Undefined();
959  Utils::ToLocal(obj)->SetCallHandler(callback, data);
960  }
961  obj->set_undetectable(false);
962  obj->set_needs_access_check(false);
963 
964  if (!signature.IsEmpty())
965  obj->set_signature(*Utils::OpenHandle(*signature));
966  return Utils::ToLocal(obj);
967 }
968 
969 
971  int argc, Handle<FunctionTemplate> argv[]) {
972  i::Isolate* isolate = i::Isolate::Current();
973  EnsureInitializedForIsolate(isolate, "v8::Signature::New()");
974  LOG_API(isolate, "Signature::New");
975  ENTER_V8(isolate);
976  i::Handle<i::Struct> struct_obj =
980  if (!receiver.IsEmpty()) obj->set_receiver(*Utils::OpenHandle(*receiver));
981  if (argc > 0) {
982  i::Handle<i::FixedArray> args = isolate->factory()->NewFixedArray(argc);
983  for (int i = 0; i < argc; i++) {
984  if (!argv[i].IsEmpty())
985  args->set(i, *Utils::OpenHandle(*argv[i]));
986  }
987  obj->set_args(*args);
988  }
989  return Utils::ToLocal(obj);
990 }
991 
992 
994  Handle<FunctionTemplate> receiver) {
996 }
997 
998 
1000  Handle<FunctionTemplate> types[1] = { type };
1001  return TypeSwitch::New(1, types);
1002 }
1003 
1004 
1006  i::Isolate* isolate = i::Isolate::Current();
1007  EnsureInitializedForIsolate(isolate, "v8::TypeSwitch::New()");
1008  LOG_API(isolate, "TypeSwitch::New");
1009  ENTER_V8(isolate);
1010  i::Handle<i::FixedArray> vector = isolate->factory()->NewFixedArray(argc);
1011  for (int i = 0; i < argc; i++)
1012  vector->set(i, *Utils::OpenHandle(*types[i]));
1013  i::Handle<i::Struct> struct_obj =
1017  obj->set_types(*vector);
1018  return Utils::ToLocal(obj);
1019 }
1020 
1021 
1023  i::Isolate* isolate = i::Isolate::Current();
1024  LOG_API(isolate, "TypeSwitch::match");
1025  USE(isolate);
1028  i::FixedArray* types = i::FixedArray::cast(info->types());
1029  for (int i = 0; i < types->length(); i++) {
1030  if (obj->IsInstanceOf(i::FunctionTemplateInfo::cast(types->get(i))))
1031  return i + 1;
1032  }
1033  return 0;
1034 }
1035 
1036 
1037 #define SET_FIELD_WRAPPED(obj, setter, cdata) do { \
1038  i::Handle<i::Object> foreign = FromCData(cdata); \
1039  (obj)->setter(*foreign); \
1040  } while (false)
1041 
1042 
1044  v8::Handle<Value> data) {
1045  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1046  if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetCallHandler()")) return;
1047  ENTER_V8(isolate);
1048  i::HandleScope scope(isolate);
1049  i::Handle<i::Struct> struct_obj =
1053  SET_FIELD_WRAPPED(obj, set_callback, callback);
1054  if (data.IsEmpty()) data = v8::Undefined();
1055  obj->set_data(*Utils::OpenHandle(*data));
1056  Utils::OpenHandle(this)->set_call_code(*obj);
1057 }
1058 
1059 
1060 static i::Handle<i::AccessorInfo> MakeAccessorInfo(
1062  AccessorGetter getter,
1063  AccessorSetter setter,
1064  v8::Handle<Value> data,
1065  v8::AccessControl settings,
1066  v8::PropertyAttribute attributes,
1067  v8::Handle<AccessorSignature> signature) {
1068  i::Handle<i::AccessorInfo> obj = FACTORY->NewAccessorInfo();
1069  ASSERT(getter != NULL);
1070  SET_FIELD_WRAPPED(obj, set_getter, getter);
1071  SET_FIELD_WRAPPED(obj, set_setter, setter);
1072  if (data.IsEmpty()) data = v8::Undefined();
1073  obj->set_data(*Utils::OpenHandle(*data));
1074  obj->set_name(*Utils::OpenHandle(*name));
1075  if (settings & ALL_CAN_READ) obj->set_all_can_read(true);
1076  if (settings & ALL_CAN_WRITE) obj->set_all_can_write(true);
1077  if (settings & PROHIBITS_OVERWRITING) obj->set_prohibits_overwriting(true);
1078  obj->set_property_attributes(static_cast<PropertyAttributes>(attributes));
1079  if (!signature.IsEmpty()) {
1080  obj->set_expected_receiver_type(*Utils::OpenHandle(*signature));
1081  }
1082  return obj;
1083 }
1084 
1085 
1086 void FunctionTemplate::AddInstancePropertyAccessor(
1087  v8::Handle<String> name,
1088  AccessorGetter getter,
1089  AccessorSetter setter,
1090  v8::Handle<Value> data,
1091  v8::AccessControl settings,
1092  v8::PropertyAttribute attributes,
1093  v8::Handle<AccessorSignature> signature) {
1094  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1095  if (IsDeadCheck(isolate,
1096  "v8::FunctionTemplate::AddInstancePropertyAccessor()")) {
1097  return;
1098  }
1099  ENTER_V8(isolate);
1100  i::HandleScope scope(isolate);
1101 
1102  i::Handle<i::AccessorInfo> obj = MakeAccessorInfo(name, getter, setter, data,
1103  settings, attributes,
1104  signature);
1106  if (list->IsUndefined()) {
1107  list = NeanderArray().value();
1108  Utils::OpenHandle(this)->set_property_accessors(*list);
1109  }
1110  NeanderArray array(list);
1111  array.add(obj);
1112 }
1113 
1114 
1116  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1117  if (IsDeadCheck(isolate, "v8::FunctionTemplate::InstanceTemplate()")
1118  || EmptyCheck("v8::FunctionTemplate::InstanceTemplate()", this))
1119  return Local<ObjectTemplate>();
1120  ENTER_V8(isolate);
1121  if (Utils::OpenHandle(this)->instance_template()->IsUndefined()) {
1122  Local<ObjectTemplate> templ =
1124  Utils::OpenHandle(this)->set_instance_template(*Utils::OpenHandle(*templ));
1125  }
1128  return Utils::ToLocal(result);
1129 }
1130 
1131 
1133  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1134  if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetClassName()")) return;
1135  ENTER_V8(isolate);
1136  Utils::OpenHandle(this)->set_class_name(*Utils::OpenHandle(*name));
1137 }
1138 
1139 
1141  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1142  if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetHiddenPrototype()")) {
1143  return;
1144  }
1145  ENTER_V8(isolate);
1146  Utils::OpenHandle(this)->set_hidden_prototype(value);
1147 }
1148 
1149 
1151  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1152  if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetPrototypeAttributes()")) {
1153  return;
1154  }
1155  ENTER_V8(isolate);
1156  Utils::OpenHandle(this)->set_read_only_prototype(true);
1157 }
1158 
1159 
1160 void FunctionTemplate::SetNamedInstancePropertyHandler(
1161  NamedPropertyGetter getter,
1162  NamedPropertySetter setter,
1163  NamedPropertyQuery query,
1164  NamedPropertyDeleter remover,
1165  NamedPropertyEnumerator enumerator,
1166  Handle<Value> data) {
1167  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1168  if (IsDeadCheck(isolate,
1169  "v8::FunctionTemplate::SetNamedInstancePropertyHandler()")) {
1170  return;
1171  }
1172  ENTER_V8(isolate);
1173  i::HandleScope scope(isolate);
1174  i::Handle<i::Struct> struct_obj =
1178 
1179  if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter);
1180  if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter);
1181  if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query);
1182  if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover);
1183  if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator);
1184 
1185  if (data.IsEmpty()) data = v8::Undefined();
1186  obj->set_data(*Utils::OpenHandle(*data));
1187  Utils::OpenHandle(this)->set_named_property_handler(*obj);
1188 }
1189 
1190 
1191 void FunctionTemplate::SetIndexedInstancePropertyHandler(
1192  IndexedPropertyGetter getter,
1193  IndexedPropertySetter setter,
1194  IndexedPropertyQuery query,
1195  IndexedPropertyDeleter remover,
1196  IndexedPropertyEnumerator enumerator,
1197  Handle<Value> data) {
1198  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1199  if (IsDeadCheck(isolate,
1200  "v8::FunctionTemplate::SetIndexedInstancePropertyHandler()")) {
1201  return;
1202  }
1203  ENTER_V8(isolate);
1204  i::HandleScope scope(isolate);
1205  i::Handle<i::Struct> struct_obj =
1209 
1210  if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter);
1211  if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter);
1212  if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query);
1213  if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover);
1214  if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator);
1215 
1216  if (data.IsEmpty()) data = v8::Undefined();
1217  obj->set_data(*Utils::OpenHandle(*data));
1218  Utils::OpenHandle(this)->set_indexed_property_handler(*obj);
1219 }
1220 
1221 
1222 void FunctionTemplate::SetInstanceCallAsFunctionHandler(
1223  InvocationCallback callback,
1224  Handle<Value> data) {
1225  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1226  if (IsDeadCheck(isolate,
1227  "v8::FunctionTemplate::SetInstanceCallAsFunctionHandler()")) {
1228  return;
1229  }
1230  ENTER_V8(isolate);
1231  i::HandleScope scope(isolate);
1232  i::Handle<i::Struct> struct_obj =
1236  SET_FIELD_WRAPPED(obj, set_callback, callback);
1237  if (data.IsEmpty()) data = v8::Undefined();
1238  obj->set_data(*Utils::OpenHandle(*data));
1239  Utils::OpenHandle(this)->set_instance_call_handler(*obj);
1240 }
1241 
1242 
1243 // --- O b j e c t T e m p l a t e ---
1244 
1245 
1247  return New(Local<FunctionTemplate>());
1248 }
1249 
1250 
1252  v8::Handle<FunctionTemplate> constructor) {
1253  i::Isolate* isolate = i::Isolate::Current();
1254  if (IsDeadCheck(isolate, "v8::ObjectTemplate::New()")) {
1255  return Local<ObjectTemplate>();
1256  }
1257  EnsureInitializedForIsolate(isolate, "v8::ObjectTemplate::New()");
1258  LOG_API(isolate, "ObjectTemplate::New");
1259  ENTER_V8(isolate);
1260  i::Handle<i::Struct> struct_obj =
1264  InitializeTemplate(obj, Consts::OBJECT_TEMPLATE);
1265  if (!constructor.IsEmpty())
1266  obj->set_constructor(*Utils::OpenHandle(*constructor));
1267  obj->set_internal_field_count(i::Smi::FromInt(0));
1268  return Utils::ToLocal(obj);
1269 }
1270 
1271 
1272 // Ensure that the object template has a constructor. If no
1273 // constructor is available we create one.
1274 static void EnsureConstructor(ObjectTemplate* object_template) {
1275  if (Utils::OpenHandle(object_template)->constructor()->IsUndefined()) {
1276  Local<FunctionTemplate> templ = FunctionTemplate::New();
1278  constructor->set_instance_template(*Utils::OpenHandle(object_template));
1279  Utils::OpenHandle(object_template)->set_constructor(*constructor);
1280  }
1281 }
1282 
1283 
1285  AccessorGetter getter,
1286  AccessorSetter setter,
1287  v8::Handle<Value> data,
1288  AccessControl settings,
1289  PropertyAttribute attribute,
1290  v8::Handle<AccessorSignature> signature) {
1291  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1292  if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetAccessor()")) return;
1293  ENTER_V8(isolate);
1294  i::HandleScope scope(isolate);
1295  EnsureConstructor(this);
1296  i::FunctionTemplateInfo* constructor =
1297  i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor());
1298  i::Handle<i::FunctionTemplateInfo> cons(constructor);
1299  Utils::ToLocal(cons)->AddInstancePropertyAccessor(name,
1300  getter,
1301  setter,
1302  data,
1303  settings,
1304  attribute,
1305  signature);
1306 }
1307 
1308 
1310  NamedPropertySetter setter,
1311  NamedPropertyQuery query,
1312  NamedPropertyDeleter remover,
1313  NamedPropertyEnumerator enumerator,
1314  Handle<Value> data) {
1315  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1316  if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetNamedPropertyHandler()")) {
1317  return;
1318  }
1319  ENTER_V8(isolate);
1320  i::HandleScope scope(isolate);
1321  EnsureConstructor(this);
1322  i::FunctionTemplateInfo* constructor =
1323  i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor());
1324  i::Handle<i::FunctionTemplateInfo> cons(constructor);
1325  Utils::ToLocal(cons)->SetNamedInstancePropertyHandler(getter,
1326  setter,
1327  query,
1328  remover,
1329  enumerator,
1330  data);
1331 }
1332 
1333 
1335  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1336  if (IsDeadCheck(isolate, "v8::ObjectTemplate::MarkAsUndetectable()")) return;
1337  ENTER_V8(isolate);
1338  i::HandleScope scope(isolate);
1339  EnsureConstructor(this);
1340  i::FunctionTemplateInfo* constructor =
1341  i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor());
1342  i::Handle<i::FunctionTemplateInfo> cons(constructor);
1343  cons->set_undetectable(true);
1344 }
1345 
1346 
1348  NamedSecurityCallback named_callback,
1349  IndexedSecurityCallback indexed_callback,
1350  Handle<Value> data,
1351  bool turned_on_by_default) {
1352  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1353  if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetAccessCheckCallbacks()")) {
1354  return;
1355  }
1356  ENTER_V8(isolate);
1357  i::HandleScope scope(isolate);
1358  EnsureConstructor(this);
1359 
1360  i::Handle<i::Struct> struct_info =
1364 
1365  SET_FIELD_WRAPPED(info, set_named_callback, named_callback);
1366  SET_FIELD_WRAPPED(info, set_indexed_callback, indexed_callback);
1367 
1368  if (data.IsEmpty()) data = v8::Undefined();
1369  info->set_data(*Utils::OpenHandle(*data));
1370 
1371  i::FunctionTemplateInfo* constructor =
1372  i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor());
1373  i::Handle<i::FunctionTemplateInfo> cons(constructor);
1374  cons->set_access_check_info(*info);
1375  cons->set_needs_access_check(turned_on_by_default);
1376 }
1377 
1378 
1380  IndexedPropertyGetter getter,
1381  IndexedPropertySetter setter,
1382  IndexedPropertyQuery query,
1383  IndexedPropertyDeleter remover,
1384  IndexedPropertyEnumerator enumerator,
1385  Handle<Value> data) {
1386  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1387  if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetIndexedPropertyHandler()")) {
1388  return;
1389  }
1390  ENTER_V8(isolate);
1391  i::HandleScope scope(isolate);
1392  EnsureConstructor(this);
1393  i::FunctionTemplateInfo* constructor =
1394  i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor());
1395  i::Handle<i::FunctionTemplateInfo> cons(constructor);
1396  Utils::ToLocal(cons)->SetIndexedInstancePropertyHandler(getter,
1397  setter,
1398  query,
1399  remover,
1400  enumerator,
1401  data);
1402 }
1403 
1404 
1406  Handle<Value> data) {
1407  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1408  if (IsDeadCheck(isolate,
1409  "v8::ObjectTemplate::SetCallAsFunctionHandler()")) {
1410  return;
1411  }
1412  ENTER_V8(isolate);
1413  i::HandleScope scope(isolate);
1414  EnsureConstructor(this);
1415  i::FunctionTemplateInfo* constructor =
1416  i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor());
1417  i::Handle<i::FunctionTemplateInfo> cons(constructor);
1418  Utils::ToLocal(cons)->SetInstanceCallAsFunctionHandler(callback, data);
1419 }
1420 
1421 
1423  if (IsDeadCheck(Utils::OpenHandle(this)->GetIsolate(),
1424  "v8::ObjectTemplate::InternalFieldCount()")) {
1425  return 0;
1426  }
1427  return i::Smi::cast(Utils::OpenHandle(this)->internal_field_count())->value();
1428 }
1429 
1430 
1432  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1433  if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetInternalFieldCount()")) {
1434  return;
1435  }
1436  if (!ApiCheck(i::Smi::IsValid(value),
1437  "v8::ObjectTemplate::SetInternalFieldCount()",
1438  "Invalid internal field count")) {
1439  return;
1440  }
1441  ENTER_V8(isolate);
1442  if (value > 0) {
1443  // The internal field count is set by the constructor function's
1444  // construct code, so we ensure that there is a constructor
1445  // function to do the setting.
1446  EnsureConstructor(this);
1447  }
1448  Utils::OpenHandle(this)->set_internal_field_count(i::Smi::FromInt(value));
1449 }
1450 
1451 
1452 // --- S c r i p t D a t a ---
1453 
1454 
1455 ScriptData* ScriptData::PreCompile(const char* input, int length) {
1457  reinterpret_cast<const unsigned char*>(input), length);
1458  return i::ParserApi::PreParse(&stream, NULL, i::FLAG_harmony_scoping);
1459 }
1460 
1461 
1463  i::Handle<i::String> str = Utils::OpenHandle(*source);
1464  if (str->IsExternalTwoByteString()) {
1466  i::Handle<i::ExternalTwoByteString>::cast(str), 0, str->length());
1467  return i::ParserApi::PreParse(&stream, NULL, i::FLAG_harmony_scoping);
1468  } else {
1469  i::GenericStringUtf16CharacterStream stream(str, 0, str->length());
1470  return i::ParserApi::PreParse(&stream, NULL, i::FLAG_harmony_scoping);
1471  }
1472 }
1473 
1474 
1475 ScriptData* ScriptData::New(const char* data, int length) {
1476  // Return an empty ScriptData if the length is obviously invalid.
1477  if (length % sizeof(unsigned) != 0) {
1478  return new i::ScriptDataImpl();
1479  }
1480 
1481  // Copy the data to ensure it is properly aligned.
1482  int deserialized_data_length = length / sizeof(unsigned);
1483  // If aligned, don't create a copy of the data.
1484  if (reinterpret_cast<intptr_t>(data) % sizeof(unsigned) == 0) {
1485  return new i::ScriptDataImpl(data, length);
1486  }
1487  // Copy the data to align it.
1488  unsigned* deserialized_data = i::NewArray<unsigned>(deserialized_data_length);
1489  i::OS::MemCopy(deserialized_data, data, length);
1490 
1491  return new i::ScriptDataImpl(
1492  i::Vector<unsigned>(deserialized_data, deserialized_data_length));
1493 }
1494 
1495 
1496 // --- S c r i p t ---
1497 
1498 
1500  v8::ScriptOrigin* origin,
1501  v8::ScriptData* pre_data,
1502  v8::Handle<String> script_data) {
1503  i::Isolate* isolate = i::Isolate::Current();
1504  ON_BAILOUT(isolate, "v8::Script::New()", return Local<Script>());
1505  LOG_API(isolate, "Script::New");
1506  ENTER_V8(isolate);
1507  i::SharedFunctionInfo* raw_result = NULL;
1508  { i::HandleScope scope(isolate);
1509  i::Handle<i::String> str = Utils::OpenHandle(*source);
1510  i::Handle<i::Object> name_obj;
1511  int line_offset = 0;
1512  int column_offset = 0;
1513  if (origin != NULL) {
1514  if (!origin->ResourceName().IsEmpty()) {
1515  name_obj = Utils::OpenHandle(*origin->ResourceName());
1516  }
1517  if (!origin->ResourceLineOffset().IsEmpty()) {
1518  line_offset = static_cast<int>(origin->ResourceLineOffset()->Value());
1519  }
1520  if (!origin->ResourceColumnOffset().IsEmpty()) {
1521  column_offset =
1522  static_cast<int>(origin->ResourceColumnOffset()->Value());
1523  }
1524  }
1525  EXCEPTION_PREAMBLE(isolate);
1526  i::ScriptDataImpl* pre_data_impl =
1527  static_cast<i::ScriptDataImpl*>(pre_data);
1528  // We assert that the pre-data is sane, even though we can actually
1529  // handle it if it turns out not to be in release mode.
1530  ASSERT(pre_data_impl == NULL || pre_data_impl->SanityCheck());
1531  // If the pre-data isn't sane we simply ignore it
1532  if (pre_data_impl != NULL && !pre_data_impl->SanityCheck()) {
1533  pre_data_impl = NULL;
1534  }
1537  name_obj,
1538  line_offset,
1539  column_offset,
1540  NULL,
1541  pre_data_impl,
1542  Utils::OpenHandle(*script_data),
1544  has_pending_exception = result.is_null();
1546  raw_result = *result;
1547  }
1548  i::Handle<i::SharedFunctionInfo> result(raw_result, isolate);
1549  return Local<Script>(ToApi<Script>(result));
1550 }
1551 
1552 
1554  v8::Handle<Value> file_name) {
1555  ScriptOrigin origin(file_name);
1556  return New(source, &origin);
1557 }
1558 
1559 
1561  v8::ScriptOrigin* origin,
1562  v8::ScriptData* pre_data,
1563  v8::Handle<String> script_data) {
1564  i::Isolate* isolate = i::Isolate::Current();
1565  ON_BAILOUT(isolate, "v8::Script::Compile()", return Local<Script>());
1566  LOG_API(isolate, "Script::Compile");
1567  ENTER_V8(isolate);
1568  Local<Script> generic = New(source, origin, pre_data, script_data);
1569  if (generic.IsEmpty())
1570  return generic;
1571  i::Handle<i::Object> obj = Utils::OpenHandle(*generic);
1574  i::Handle<i::JSFunction> result =
1576  function,
1577  isolate->global_context());
1578  return Local<Script>(ToApi<Script>(result));
1579 }
1580 
1581 
1583  v8::Handle<Value> file_name,
1584  v8::Handle<String> script_data) {
1585  ScriptOrigin origin(file_name);
1586  return Compile(source, &origin, 0, script_data);
1587 }
1588 
1589 
1591  i::Isolate* isolate = i::Isolate::Current();
1592  ON_BAILOUT(isolate, "v8::Script::Run()", return Local<Value>());
1593  LOG_API(isolate, "Script::Run");
1594  ENTER_V8(isolate);
1595  i::Object* raw_result = NULL;
1596  {
1597  i::HandleScope scope(isolate);
1600  if (obj->IsSharedFunctionInfo()) {
1602  function_info(i::SharedFunctionInfo::cast(*obj), isolate);
1603  fun = isolate->factory()->NewFunctionFromSharedFunctionInfo(
1604  function_info, isolate->global_context());
1605  } else {
1606  fun = i::Handle<i::JSFunction>(i::JSFunction::cast(*obj), isolate);
1607  }
1608  EXCEPTION_PREAMBLE(isolate);
1609  i::Handle<i::Object> receiver(
1610  isolate->context()->global_proxy(), isolate);
1611  i::Handle<i::Object> result =
1612  i::Execution::Call(fun, receiver, 0, NULL, &has_pending_exception);
1614  raw_result = *result;
1615  }
1616  i::Handle<i::Object> result(raw_result, isolate);
1617  return Utils::ToLocal(result);
1618 }
1619 
1620 
1621 static i::Handle<i::SharedFunctionInfo> OpenScript(Script* script) {
1624  if (obj->IsSharedFunctionInfo()) {
1625  result =
1627  } else {
1628  result =
1630  }
1631  return result;
1632 }
1633 
1634 
1636  i::Isolate* isolate = i::Isolate::Current();
1637  ON_BAILOUT(isolate, "v8::Script::Id()", return Local<Value>());
1638  LOG_API(isolate, "Script::Id");
1639  i::Object* raw_id = NULL;
1640  {
1641  i::HandleScope scope(isolate);
1642  i::Handle<i::SharedFunctionInfo> function_info = OpenScript(this);
1643  i::Handle<i::Script> script(i::Script::cast(function_info->script()));
1644  i::Handle<i::Object> id(script->id());
1645  raw_id = *id;
1646  }
1647  i::Handle<i::Object> id(raw_id);
1648  return Utils::ToLocal(id);
1649 }
1650 
1651 
1653  i::Isolate* isolate = i::Isolate::Current();
1654  ON_BAILOUT(isolate, "v8::Script::SetData()", return);
1655  LOG_API(isolate, "Script::SetData");
1656  {
1657  i::HandleScope scope(isolate);
1658  i::Handle<i::SharedFunctionInfo> function_info = OpenScript(this);
1659  i::Handle<i::Object> raw_data = Utils::OpenHandle(*data);
1660  i::Handle<i::Script> script(i::Script::cast(function_info->script()));
1661  script->set_data(*raw_data);
1662  }
1663 }
1664 
1665 
1666 // --- E x c e p t i o n s ---
1667 
1668 
1670  : isolate_(i::Isolate::Current()),
1671  next_(isolate_->try_catch_handler_address()),
1672  exception_(isolate_->heap()->the_hole_value()),
1673  message_(i::Smi::FromInt(0)),
1674  is_verbose_(false),
1675  can_continue_(true),
1676  capture_message_(true),
1677  rethrow_(false) {
1678  isolate_->RegisterTryCatchHandler(this);
1679 }
1680 
1681 
1683  ASSERT(isolate_ == i::Isolate::Current());
1684  if (rethrow_) {
1685  v8::HandleScope scope;
1687  isolate_->UnregisterTryCatchHandler(this);
1688  v8::ThrowException(exc);
1689  } else {
1690  isolate_->UnregisterTryCatchHandler(this);
1691  }
1692 }
1693 
1694 
1696  return !reinterpret_cast<i::Object*>(exception_)->IsTheHole();
1697 }
1698 
1699 
1701  return can_continue_;
1702 }
1703 
1704 
1706  if (!HasCaught()) return v8::Local<v8::Value>();
1707  rethrow_ = true;
1708  return v8::Undefined();
1709 }
1710 
1711 
1713  ASSERT(isolate_ == i::Isolate::Current());
1714  if (HasCaught()) {
1715  // Check for out of memory exception.
1716  i::Object* exception = reinterpret_cast<i::Object*>(exception_);
1717  return v8::Utils::ToLocal(i::Handle<i::Object>(exception, isolate_));
1718  } else {
1719  return v8::Local<Value>();
1720  }
1721 }
1722 
1723 
1725  ASSERT(isolate_ == i::Isolate::Current());
1726  if (HasCaught()) {
1727  i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_);
1728  if (!raw_obj->IsJSObject()) return v8::Local<Value>();
1729  i::HandleScope scope(isolate_);
1730  i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj), isolate_);
1731  i::Handle<i::String> name = isolate_->factory()->LookupAsciiSymbol("stack");
1732  if (!obj->HasProperty(*name)) return v8::Local<Value>();
1733  i::Handle<i::Object> value = i::GetProperty(obj, name);
1734  if (value.is_null()) return v8::Local<Value>();
1735  return v8::Utils::ToLocal(scope.CloseAndEscape(value));
1736  } else {
1737  return v8::Local<Value>();
1738  }
1739 }
1740 
1741 
1743  ASSERT(isolate_ == i::Isolate::Current());
1744  if (HasCaught() && message_ != i::Smi::FromInt(0)) {
1745  i::Object* message = reinterpret_cast<i::Object*>(message_);
1746  return v8::Utils::MessageToLocal(i::Handle<i::Object>(message, isolate_));
1747  } else {
1748  return v8::Local<v8::Message>();
1749  }
1750 }
1751 
1752 
1754  ASSERT(isolate_ == i::Isolate::Current());
1755  exception_ = isolate_->heap()->the_hole_value();
1756  message_ = i::Smi::FromInt(0);
1757 }
1758 
1759 
1760 void v8::TryCatch::SetVerbose(bool value) {
1761  is_verbose_ = value;
1762 }
1763 
1764 
1766  capture_message_ = value;
1767 }
1768 
1769 
1770 // --- M e s s a g e ---
1771 
1772 
1774  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1775  ON_BAILOUT(isolate, "v8::Message::Get()", return Local<String>());
1776  ENTER_V8(isolate);
1777  HandleScope scope;
1780  Local<String> result = Utils::ToLocal(raw_result);
1781  return scope.Close(result);
1782 }
1783 
1784 
1786  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1787  if (IsDeadCheck(isolate, "v8::Message::GetScriptResourceName()")) {
1788  return Local<String>();
1789  }
1790  ENTER_V8(isolate);
1791  HandleScope scope;
1794  // Return this.script.name.
1795  i::Handle<i::JSValue> script =
1797  i::Handle<i::Object> resource_name(i::Script::cast(script->value())->name());
1798  return scope.Close(Utils::ToLocal(resource_name));
1799 }
1800 
1801 
1803  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1804  if (IsDeadCheck(isolate, "v8::Message::GetScriptResourceData()")) {
1805  return Local<Value>();
1806  }
1807  ENTER_V8(isolate);
1808  HandleScope scope;
1811  // Return this.script.data.
1812  i::Handle<i::JSValue> script =
1814  i::Handle<i::Object> data(i::Script::cast(script->value())->data());
1815  return scope.Close(Utils::ToLocal(data));
1816 }
1817 
1818 
1820  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1821  if (IsDeadCheck(isolate, "v8::Message::GetStackTrace()")) {
1822  return Local<v8::StackTrace>();
1823  }
1824  ENTER_V8(isolate);
1825  HandleScope scope;
1828  i::Handle<i::Object> stackFramesObj(message->stack_frames());
1829  if (!stackFramesObj->IsJSArray()) return v8::Handle<v8::StackTrace>();
1830  i::Handle<i::JSArray> stackTrace =
1831  i::Handle<i::JSArray>::cast(stackFramesObj);
1832  return scope.Close(Utils::StackTraceToLocal(stackTrace));
1833 }
1834 
1835 
1836 static i::Handle<i::Object> CallV8HeapFunction(const char* name,
1837  i::Handle<i::Object> recv,
1838  int argc,
1839  i::Handle<i::Object> argv[],
1840  bool* has_pending_exception) {
1841  i::Isolate* isolate = i::Isolate::Current();
1842  i::Handle<i::String> fmt_str = isolate->factory()->LookupAsciiSymbol(name);
1843  i::Object* object_fun =
1844  isolate->js_builtins_object()->GetPropertyNoExceptionThrown(*fmt_str);
1847  i::Handle<i::Object> value =
1848  i::Execution::Call(fun, recv, argc, argv, has_pending_exception);
1849  return value;
1850 }
1851 
1852 
1853 static i::Handle<i::Object> CallV8HeapFunction(const char* name,
1854  i::Handle<i::Object> data,
1855  bool* has_pending_exception) {
1856  i::Handle<i::Object> argv[] = { data };
1857  return CallV8HeapFunction(name,
1858  i::Isolate::Current()->js_builtins_object(),
1859  ARRAY_SIZE(argv),
1860  argv,
1861  has_pending_exception);
1862 }
1863 
1864 
1866  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1867  ON_BAILOUT(isolate, "v8::Message::GetLineNumber()", return kNoLineNumberInfo);
1868  ENTER_V8(isolate);
1869  i::HandleScope scope(isolate);
1870 
1871  EXCEPTION_PREAMBLE(isolate);
1872  i::Handle<i::Object> result = CallV8HeapFunction("GetLineNumber",
1873  Utils::OpenHandle(this),
1874  &has_pending_exception);
1875  EXCEPTION_BAILOUT_CHECK(isolate, 0);
1876  return static_cast<int>(result->Number());
1877 }
1878 
1879 
1881  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1882  if (IsDeadCheck(isolate, "v8::Message::GetStartPosition()")) return 0;
1883  ENTER_V8(isolate);
1884  i::HandleScope scope(isolate);
1887  return message->start_position();
1888 }
1889 
1890 
1892  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1893  if (IsDeadCheck(isolate, "v8::Message::GetEndPosition()")) return 0;
1894  ENTER_V8(isolate);
1895  i::HandleScope scope(isolate);
1898  return message->end_position();
1899 }
1900 
1901 
1903  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1904  if (IsDeadCheck(isolate, "v8::Message::GetStartColumn()")) {
1905  return kNoColumnInfo;
1906  }
1907  ENTER_V8(isolate);
1908  i::HandleScope scope(isolate);
1909  i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this);
1910  EXCEPTION_PREAMBLE(isolate);
1911  i::Handle<i::Object> start_col_obj = CallV8HeapFunction(
1912  "GetPositionInLine",
1913  data_obj,
1914  &has_pending_exception);
1915  EXCEPTION_BAILOUT_CHECK(isolate, 0);
1916  return static_cast<int>(start_col_obj->Number());
1917 }
1918 
1919 
1921  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1922  if (IsDeadCheck(isolate, "v8::Message::GetEndColumn()")) return kNoColumnInfo;
1923  ENTER_V8(isolate);
1924  i::HandleScope scope(isolate);
1925  i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this);
1926  EXCEPTION_PREAMBLE(isolate);
1927  i::Handle<i::Object> start_col_obj = CallV8HeapFunction(
1928  "GetPositionInLine",
1929  data_obj,
1930  &has_pending_exception);
1931  EXCEPTION_BAILOUT_CHECK(isolate, 0);
1934  int start = message->start_position();
1935  int end = message->end_position();
1936  return static_cast<int>(start_col_obj->Number()) + (end - start);
1937 }
1938 
1939 
1941  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1942  ON_BAILOUT(isolate, "v8::Message::GetSourceLine()", return Local<String>());
1943  ENTER_V8(isolate);
1944  HandleScope scope;
1945  EXCEPTION_PREAMBLE(isolate);
1946  i::Handle<i::Object> result = CallV8HeapFunction("GetSourceLine",
1947  Utils::OpenHandle(this),
1948  &has_pending_exception);
1950  if (result->IsString()) {
1951  return scope.Close(Utils::ToLocal(i::Handle<i::String>::cast(result)));
1952  } else {
1953  return Local<String>();
1954  }
1955 }
1956 
1957 
1959  i::Isolate* isolate = i::Isolate::Current();
1960  if (IsDeadCheck(isolate, "v8::Message::PrintCurrentStackTrace()")) return;
1961  ENTER_V8(isolate);
1962  isolate->PrintCurrentStackTrace(out);
1963 }
1964 
1965 
1966 // --- S t a c k T r a c e ---
1967 
1969  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1970  if (IsDeadCheck(isolate, "v8::StackTrace::GetFrame()")) {
1971  return Local<StackFrame>();
1972  }
1973  ENTER_V8(isolate);
1974  HandleScope scope;
1976  i::Object* raw_object = self->GetElementNoExceptionThrown(index);
1977  i::Handle<i::JSObject> obj(i::JSObject::cast(raw_object));
1978  return scope.Close(Utils::StackFrameToLocal(obj));
1979 }
1980 
1981 
1983  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1984  if (IsDeadCheck(isolate, "v8::StackTrace::GetFrameCount()")) return -1;
1985  ENTER_V8(isolate);
1986  return i::Smi::cast(Utils::OpenHandle(this)->length())->value();
1987 }
1988 
1989 
1991  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1992  if (IsDeadCheck(isolate, "v8::StackTrace::AsArray()")) Local<Array>();
1993  ENTER_V8(isolate);
1994  return Utils::ToLocal(Utils::OpenHandle(this));
1995 }
1996 
1997 
1999  StackTraceOptions options) {
2000  i::Isolate* isolate = i::Isolate::Current();
2001  if (IsDeadCheck(isolate, "v8::StackTrace::CurrentStackTrace()")) {
2003  }
2004  ENTER_V8(isolate);
2005  i::Handle<i::JSArray> stackTrace =
2006  isolate->CaptureCurrentStackTrace(frame_limit, options);
2007  return Utils::StackTraceToLocal(stackTrace);
2008 }
2009 
2010 
2011 // --- S t a c k F r a m e ---
2012 
2014  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2015  if (IsDeadCheck(isolate, "v8::StackFrame::GetLineNumber()")) {
2017  }
2018  ENTER_V8(isolate);
2019  i::HandleScope scope(isolate);
2021  i::Handle<i::Object> line = GetProperty(self, "lineNumber");
2022  if (!line->IsSmi()) {
2024  }
2025  return i::Smi::cast(*line)->value();
2026 }
2027 
2028 
2030  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2031  if (IsDeadCheck(isolate, "v8::StackFrame::GetColumn()")) {
2032  return Message::kNoColumnInfo;
2033  }
2034  ENTER_V8(isolate);
2035  i::HandleScope scope(isolate);
2037  i::Handle<i::Object> column = GetProperty(self, "column");
2038  if (!column->IsSmi()) {
2039  return Message::kNoColumnInfo;
2040  }
2041  return i::Smi::cast(*column)->value();
2042 }
2043 
2044 
2046  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2047  if (IsDeadCheck(isolate, "v8::StackFrame::GetScriptName()")) {
2048  return Local<String>();
2049  }
2050  ENTER_V8(isolate);
2051  HandleScope scope;
2053  i::Handle<i::Object> name = GetProperty(self, "scriptName");
2054  if (!name->IsString()) {
2055  return Local<String>();
2056  }
2057  return scope.Close(Local<String>::Cast(Utils::ToLocal(name)));
2058 }
2059 
2060 
2062  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2063  if (IsDeadCheck(isolate, "v8::StackFrame::GetScriptNameOrSourceURL()")) {
2064  return Local<String>();
2065  }
2066  ENTER_V8(isolate);
2067  HandleScope scope;
2069  i::Handle<i::Object> name = GetProperty(self, "scriptNameOrSourceURL");
2070  if (!name->IsString()) {
2071  return Local<String>();
2072  }
2073  return scope.Close(Local<String>::Cast(Utils::ToLocal(name)));
2074 }
2075 
2076 
2078  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2079  if (IsDeadCheck(isolate, "v8::StackFrame::GetFunctionName()")) {
2080  return Local<String>();
2081  }
2082  ENTER_V8(isolate);
2083  HandleScope scope;
2085  i::Handle<i::Object> name = GetProperty(self, "functionName");
2086  if (!name->IsString()) {
2087  return Local<String>();
2088  }
2089  return scope.Close(Local<String>::Cast(Utils::ToLocal(name)));
2090 }
2091 
2092 
2093 bool StackFrame::IsEval() const {
2094  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2095  if (IsDeadCheck(isolate, "v8::StackFrame::IsEval()")) return false;
2096  ENTER_V8(isolate);
2097  i::HandleScope scope(isolate);
2099  i::Handle<i::Object> is_eval = GetProperty(self, "isEval");
2100  return is_eval->IsTrue();
2101 }
2102 
2103 
2105  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2106  if (IsDeadCheck(isolate, "v8::StackFrame::IsConstructor()")) return false;
2107  ENTER_V8(isolate);
2108  i::HandleScope scope(isolate);
2110  i::Handle<i::Object> is_constructor = GetProperty(self, "isConstructor");
2111  return is_constructor->IsTrue();
2112 }
2113 
2114 
2115 // --- D a t a ---
2116 
2117 bool Value::FullIsUndefined() const {
2118  if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsUndefined()")) {
2119  return false;
2120  }
2121  bool result = Utils::OpenHandle(this)->IsUndefined();
2122  ASSERT_EQ(result, QuickIsUndefined());
2123  return result;
2124 }
2125 
2126 
2127 bool Value::FullIsNull() const {
2128  if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsNull()")) return false;
2129  bool result = Utils::OpenHandle(this)->IsNull();
2130  ASSERT_EQ(result, QuickIsNull());
2131  return result;
2132 }
2133 
2134 
2135 bool Value::IsTrue() const {
2136  if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsTrue()")) return false;
2137  return Utils::OpenHandle(this)->IsTrue();
2138 }
2139 
2140 
2141 bool Value::IsFalse() const {
2142  if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsFalse()")) return false;
2143  return Utils::OpenHandle(this)->IsFalse();
2144 }
2145 
2146 
2147 bool Value::IsFunction() const {
2148  if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsFunction()")) {
2149  return false;
2150  }
2151  return Utils::OpenHandle(this)->IsJSFunction();
2152 }
2153 
2154 
2155 bool Value::FullIsString() const {
2156  if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsString()")) return false;
2157  bool result = Utils::OpenHandle(this)->IsString();
2158  ASSERT_EQ(result, QuickIsString());
2159  return result;
2160 }
2161 
2162 
2163 bool Value::IsArray() const {
2164  if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsArray()")) return false;
2165  return Utils::OpenHandle(this)->IsJSArray();
2166 }
2167 
2168 
2169 bool Value::IsObject() const {
2170  if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsObject()")) return false;
2171  return Utils::OpenHandle(this)->IsJSObject();
2172 }
2173 
2174 
2175 bool Value::IsNumber() const {
2176  if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsNumber()")) return false;
2177  return Utils::OpenHandle(this)->IsNumber();
2178 }
2179 
2180 
2181 bool Value::IsBoolean() const {
2182  if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsBoolean()")) {
2183  return false;
2184  }
2185  return Utils::OpenHandle(this)->IsBoolean();
2186 }
2187 
2188 
2189 bool Value::IsExternal() const {
2190  if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsExternal()")) {
2191  return false;
2192  }
2193  return Utils::OpenHandle(this)->IsForeign();
2194 }
2195 
2196 
2197 bool Value::IsInt32() const {
2198  if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsInt32()")) return false;
2200  if (obj->IsSmi()) return true;
2201  if (obj->IsNumber()) {
2202  double value = obj->Number();
2203  static const i::DoubleRepresentation minus_zero(-0.0);
2204  i::DoubleRepresentation rep(value);
2205  if (rep.bits == minus_zero.bits) {
2206  return false;
2207  }
2208  return i::FastI2D(i::FastD2I(value)) == value;
2209  }
2210  return false;
2211 }
2212 
2213 
2214 bool Value::IsUint32() const {
2215  if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsUint32()")) return false;
2217  if (obj->IsSmi()) return i::Smi::cast(*obj)->value() >= 0;
2218  if (obj->IsNumber()) {
2219  double value = obj->Number();
2220  static const i::DoubleRepresentation minus_zero(-0.0);
2221  i::DoubleRepresentation rep(value);
2222  if (rep.bits == minus_zero.bits) {
2223  return false;
2224  }
2225  return i::FastUI2D(i::FastD2UI(value)) == value;
2226  }
2227  return false;
2228 }
2229 
2230 
2231 bool Value::IsDate() const {
2232  i::Isolate* isolate = i::Isolate::Current();
2233  if (IsDeadCheck(isolate, "v8::Value::IsDate()")) return false;
2235  return obj->HasSpecificClassOf(isolate->heap()->Date_symbol());
2236 }
2237 
2238 
2240  i::Isolate* isolate = i::Isolate::Current();
2241  if (IsDeadCheck(isolate, "v8::Value::IsStringObject()")) return false;
2243  return obj->HasSpecificClassOf(isolate->heap()->String_symbol());
2244 }
2245 
2246 
2248  i::Isolate* isolate = i::Isolate::Current();
2249  if (IsDeadCheck(isolate, "v8::Value::IsNumberObject()")) return false;
2251  return obj->HasSpecificClassOf(isolate->heap()->Number_symbol());
2252 }
2253 
2254 
2255 static i::Object* LookupBuiltin(i::Isolate* isolate,
2256  const char* builtin_name) {
2257  i::Handle<i::String> symbol =
2258  isolate->factory()->LookupAsciiSymbol(builtin_name);
2259  i::Handle<i::JSBuiltinsObject> builtins = isolate->js_builtins_object();
2260  return builtins->GetPropertyNoExceptionThrown(*symbol);
2261 }
2262 
2263 
2264 static bool CheckConstructor(i::Isolate* isolate,
2266  const char* class_name) {
2267  return obj->map()->constructor() == LookupBuiltin(isolate, class_name);
2268 }
2269 
2270 
2271 bool Value::IsNativeError() const {
2272  i::Isolate* isolate = i::Isolate::Current();
2273  if (IsDeadCheck(isolate, "v8::Value::IsNativeError()")) return false;
2275  if (obj->IsJSObject()) {
2277  return CheckConstructor(isolate, js_obj, "$Error") ||
2278  CheckConstructor(isolate, js_obj, "$EvalError") ||
2279  CheckConstructor(isolate, js_obj, "$RangeError") ||
2280  CheckConstructor(isolate, js_obj, "$ReferenceError") ||
2281  CheckConstructor(isolate, js_obj, "$SyntaxError") ||
2282  CheckConstructor(isolate, js_obj, "$TypeError") ||
2283  CheckConstructor(isolate, js_obj, "$URIError");
2284  } else {
2285  return false;
2286  }
2287 }
2288 
2289 
2291  i::Isolate* isolate = i::Isolate::Current();
2292  if (IsDeadCheck(isolate, "v8::Value::IsBooleanObject()")) return false;
2294  return obj->HasSpecificClassOf(isolate->heap()->Boolean_symbol());
2295 }
2296 
2297 
2298 bool Value::IsRegExp() const {
2299  if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsRegExp()")) return false;
2301  return obj->IsJSRegExp();
2302 }
2303 
2304 
2308  if (obj->IsString()) {
2309  str = obj;
2310  } else {
2311  i::Isolate* isolate = i::Isolate::Current();
2312  if (IsDeadCheck(isolate, "v8::Value::ToString()")) {
2313  return Local<String>();
2314  }
2315  LOG_API(isolate, "ToString");
2316  ENTER_V8(isolate);
2317  EXCEPTION_PREAMBLE(isolate);
2318  str = i::Execution::ToString(obj, &has_pending_exception);
2320  }
2321  return Local<String>(ToApi<String>(str));
2322 }
2323 
2324 
2328  if (obj->IsString()) {
2329  str = obj;
2330  } else {
2331  i::Isolate* isolate = i::Isolate::Current();
2332  if (IsDeadCheck(isolate, "v8::Value::ToDetailString()")) {
2333  return Local<String>();
2334  }
2335  LOG_API(isolate, "ToDetailString");
2336  ENTER_V8(isolate);
2337  EXCEPTION_PREAMBLE(isolate);
2338  str = i::Execution::ToDetailString(obj, &has_pending_exception);
2340  }
2341  return Local<String>(ToApi<String>(str));
2342 }
2343 
2344 
2348  if (obj->IsJSObject()) {
2349  val = obj;
2350  } else {
2351  i::Isolate* isolate = i::Isolate::Current();
2352  if (IsDeadCheck(isolate, "v8::Value::ToObject()")) {
2353  return Local<v8::Object>();
2354  }
2355  LOG_API(isolate, "ToObject");
2356  ENTER_V8(isolate);
2357  EXCEPTION_PREAMBLE(isolate);
2358  val = i::Execution::ToObject(obj, &has_pending_exception);
2360  }
2361  return Local<v8::Object>(ToApi<Object>(val));
2362 }
2363 
2364 
2367  if (obj->IsBoolean()) {
2368  return Local<Boolean>(ToApi<Boolean>(obj));
2369  } else {
2370  i::Isolate* isolate = i::Isolate::Current();
2371  if (IsDeadCheck(isolate, "v8::Value::ToBoolean()")) {
2372  return Local<Boolean>();
2373  }
2374  LOG_API(isolate, "ToBoolean");
2375  ENTER_V8(isolate);
2377  return Local<Boolean>(ToApi<Boolean>(val));
2378  }
2379 }
2380 
2381 
2385  if (obj->IsNumber()) {
2386  num = obj;
2387  } else {
2388  i::Isolate* isolate = i::Isolate::Current();
2389  if (IsDeadCheck(isolate, "v8::Value::ToNumber()")) {
2390  return Local<Number>();
2391  }
2392  LOG_API(isolate, "ToNumber");
2393  ENTER_V8(isolate);
2394  EXCEPTION_PREAMBLE(isolate);
2395  num = i::Execution::ToNumber(obj, &has_pending_exception);
2397  }
2398  return Local<Number>(ToApi<Number>(num));
2399 }
2400 
2401 
2405  if (obj->IsSmi()) {
2406  num = obj;
2407  } else {
2408  i::Isolate* isolate = i::Isolate::Current();
2409  if (IsDeadCheck(isolate, "v8::Value::ToInteger()")) return Local<Integer>();
2410  LOG_API(isolate, "ToInteger");
2411  ENTER_V8(isolate);
2412  EXCEPTION_PREAMBLE(isolate);
2413  num = i::Execution::ToInteger(obj, &has_pending_exception);
2415  }
2416  return Local<Integer>(ToApi<Integer>(num));
2417 }
2418 
2419 
2420 void External::CheckCast(v8::Value* that) {
2421  if (IsDeadCheck(i::Isolate::Current(), "v8::External::Cast()")) return;
2423  ApiCheck(obj->IsForeign(),
2424  "v8::External::Cast()",
2425  "Could not convert to external");
2426 }
2427 
2428 
2429 void v8::Object::CheckCast(Value* that) {
2430  if (IsDeadCheck(i::Isolate::Current(), "v8::Object::Cast()")) return;
2432  ApiCheck(obj->IsJSObject(),
2433  "v8::Object::Cast()",
2434  "Could not convert to object");
2435 }
2436 
2437 
2438 void v8::Function::CheckCast(Value* that) {
2439  if (IsDeadCheck(i::Isolate::Current(), "v8::Function::Cast()")) return;
2441  ApiCheck(obj->IsJSFunction(),
2442  "v8::Function::Cast()",
2443  "Could not convert to function");
2444 }
2445 
2446 
2447 void v8::String::CheckCast(v8::Value* that) {
2448  if (IsDeadCheck(i::Isolate::Current(), "v8::String::Cast()")) return;
2450  ApiCheck(obj->IsString(),
2451  "v8::String::Cast()",
2452  "Could not convert to string");
2453 }
2454 
2455 
2456 void v8::Number::CheckCast(v8::Value* that) {
2457  if (IsDeadCheck(i::Isolate::Current(), "v8::Number::Cast()")) return;
2459  ApiCheck(obj->IsNumber(),
2460  "v8::Number::Cast()",
2461  "Could not convert to number");
2462 }
2463 
2464 
2465 void v8::Integer::CheckCast(v8::Value* that) {
2466  if (IsDeadCheck(i::Isolate::Current(), "v8::Integer::Cast()")) return;
2468  ApiCheck(obj->IsNumber(),
2469  "v8::Integer::Cast()",
2470  "Could not convert to number");
2471 }
2472 
2473 
2474 void v8::Array::CheckCast(Value* that) {
2475  if (IsDeadCheck(i::Isolate::Current(), "v8::Array::Cast()")) return;
2477  ApiCheck(obj->IsJSArray(),
2478  "v8::Array::Cast()",
2479  "Could not convert to array");
2480 }
2481 
2482 
2483 void v8::Date::CheckCast(v8::Value* that) {
2484  i::Isolate* isolate = i::Isolate::Current();
2485  if (IsDeadCheck(isolate, "v8::Date::Cast()")) return;
2487  ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Date_symbol()),
2488  "v8::Date::Cast()",
2489  "Could not convert to date");
2490 }
2491 
2492 
2493 void v8::StringObject::CheckCast(v8::Value* that) {
2494  i::Isolate* isolate = i::Isolate::Current();
2495  if (IsDeadCheck(isolate, "v8::StringObject::Cast()")) return;
2497  ApiCheck(obj->HasSpecificClassOf(isolate->heap()->String_symbol()),
2498  "v8::StringObject::Cast()",
2499  "Could not convert to StringObject");
2500 }
2501 
2502 
2503 void v8::NumberObject::CheckCast(v8::Value* that) {
2504  i::Isolate* isolate = i::Isolate::Current();
2505  if (IsDeadCheck(isolate, "v8::NumberObject::Cast()")) return;
2507  ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Number_symbol()),
2508  "v8::NumberObject::Cast()",
2509  "Could not convert to NumberObject");
2510 }
2511 
2512 
2513 void v8::BooleanObject::CheckCast(v8::Value* that) {
2514  i::Isolate* isolate = i::Isolate::Current();
2515  if (IsDeadCheck(isolate, "v8::BooleanObject::Cast()")) return;
2517  ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Boolean_symbol()),
2518  "v8::BooleanObject::Cast()",
2519  "Could not convert to BooleanObject");
2520 }
2521 
2522 
2523 void v8::RegExp::CheckCast(v8::Value* that) {
2524  if (IsDeadCheck(i::Isolate::Current(), "v8::RegExp::Cast()")) return;
2526  ApiCheck(obj->IsJSRegExp(),
2527  "v8::RegExp::Cast()",
2528  "Could not convert to regular expression");
2529 }
2530 
2531 
2532 bool Value::BooleanValue() const {
2534  if (obj->IsBoolean()) {
2535  return obj->IsTrue();
2536  } else {
2537  i::Isolate* isolate = i::Isolate::Current();
2538  if (IsDeadCheck(isolate, "v8::Value::BooleanValue()")) return false;
2539  LOG_API(isolate, "BooleanValue");
2540  ENTER_V8(isolate);
2542  return value->IsTrue();
2543  }
2544 }
2545 
2546 
2547 double Value::NumberValue() const {
2550  if (obj->IsNumber()) {
2551  num = obj;
2552  } else {
2553  i::Isolate* isolate = i::Isolate::Current();
2554  if (IsDeadCheck(isolate, "v8::Value::NumberValue()")) {
2555  return i::OS::nan_value();
2556  }
2557  LOG_API(isolate, "NumberValue");
2558  ENTER_V8(isolate);
2559  EXCEPTION_PREAMBLE(isolate);
2560  num = i::Execution::ToNumber(obj, &has_pending_exception);
2562  }
2563  return num->Number();
2564 }
2565 
2566 
2567 int64_t Value::IntegerValue() const {
2570  if (obj->IsNumber()) {
2571  num = obj;
2572  } else {
2573  i::Isolate* isolate = i::Isolate::Current();
2574  if (IsDeadCheck(isolate, "v8::Value::IntegerValue()")) return 0;
2575  LOG_API(isolate, "IntegerValue");
2576  ENTER_V8(isolate);
2577  EXCEPTION_PREAMBLE(isolate);
2578  num = i::Execution::ToInteger(obj, &has_pending_exception);
2579  EXCEPTION_BAILOUT_CHECK(isolate, 0);
2580  }
2581  if (num->IsSmi()) {
2582  return i::Smi::cast(*num)->value();
2583  } else {
2584  return static_cast<int64_t>(num->Number());
2585  }
2586 }
2587 
2588 
2592  if (obj->IsSmi()) {
2593  num = obj;
2594  } else {
2595  i::Isolate* isolate = i::Isolate::Current();
2596  if (IsDeadCheck(isolate, "v8::Value::ToInt32()")) return Local<Int32>();
2597  LOG_API(isolate, "ToInt32");
2598  ENTER_V8(isolate);
2599  EXCEPTION_PREAMBLE(isolate);
2600  num = i::Execution::ToInt32(obj, &has_pending_exception);
2602  }
2603  return Local<Int32>(ToApi<Int32>(num));
2604 }
2605 
2606 
2610  if (obj->IsSmi()) {
2611  num = obj;
2612  } else {
2613  i::Isolate* isolate = i::Isolate::Current();
2614  if (IsDeadCheck(isolate, "v8::Value::ToUint32()")) return Local<Uint32>();
2615  LOG_API(isolate, "ToUInt32");
2616  ENTER_V8(isolate);
2617  EXCEPTION_PREAMBLE(isolate);
2618  num = i::Execution::ToUint32(obj, &has_pending_exception);
2620  }
2621  return Local<Uint32>(ToApi<Uint32>(num));
2622 }
2623 
2624 
2627  if (obj->IsSmi()) {
2628  if (i::Smi::cast(*obj)->value() >= 0) return Utils::Uint32ToLocal(obj);
2629  return Local<Uint32>();
2630  }
2631  i::Isolate* isolate = i::Isolate::Current();
2632  if (IsDeadCheck(isolate, "v8::Value::ToArrayIndex()")) return Local<Uint32>();
2633  LOG_API(isolate, "ToArrayIndex");
2634  ENTER_V8(isolate);
2635  EXCEPTION_PREAMBLE(isolate);
2636  i::Handle<i::Object> string_obj =
2637  i::Execution::ToString(obj, &has_pending_exception);
2640  uint32_t index;
2641  if (str->AsArrayIndex(&index)) {
2642  i::Handle<i::Object> value;
2643  if (index <= static_cast<uint32_t>(i::Smi::kMaxValue)) {
2644  value = i::Handle<i::Object>(i::Smi::FromInt(index));
2645  } else {
2646  value = isolate->factory()->NewNumber(index);
2647  }
2648  return Utils::Uint32ToLocal(value);
2649  }
2650  return Local<Uint32>();
2651 }
2652 
2653 
2656  if (obj->IsSmi()) {
2657  return i::Smi::cast(*obj)->value();
2658  } else {
2659  i::Isolate* isolate = i::Isolate::Current();
2660  if (IsDeadCheck(isolate, "v8::Value::Int32Value()")) return 0;
2661  LOG_API(isolate, "Int32Value (slow)");
2662  ENTER_V8(isolate);
2663  EXCEPTION_PREAMBLE(isolate);
2664  i::Handle<i::Object> num =
2665  i::Execution::ToInt32(obj, &has_pending_exception);
2666  EXCEPTION_BAILOUT_CHECK(isolate, 0);
2667  if (num->IsSmi()) {
2668  return i::Smi::cast(*num)->value();
2669  } else {
2670  return static_cast<int32_t>(num->Number());
2671  }
2672  }
2673 }
2674 
2675 
2676 bool Value::Equals(Handle<Value> that) const {
2677  i::Isolate* isolate = i::Isolate::Current();
2678  if (IsDeadCheck(isolate, "v8::Value::Equals()")
2679  || EmptyCheck("v8::Value::Equals()", this)
2680  || EmptyCheck("v8::Value::Equals()", that)) {
2681  return false;
2682  }
2683  LOG_API(isolate, "Equals");
2684  ENTER_V8(isolate);
2686  i::Handle<i::Object> other = Utils::OpenHandle(*that);
2687  // If both obj and other are JSObjects, we'd better compare by identity
2688  // immediately when going into JS builtin. The reason is Invoke
2689  // would overwrite global object receiver with global proxy.
2690  if (obj->IsJSObject() && other->IsJSObject()) {
2691  return *obj == *other;
2692  }
2693  i::Handle<i::Object> args[] = { other };
2694  EXCEPTION_PREAMBLE(isolate);
2695  i::Handle<i::Object> result =
2696  CallV8HeapFunction("EQUALS", obj, ARRAY_SIZE(args), args,
2697  &has_pending_exception);
2698  EXCEPTION_BAILOUT_CHECK(isolate, false);
2699  return *result == i::Smi::FromInt(i::EQUAL);
2700 }
2701 
2702 
2704  i::Isolate* isolate = i::Isolate::Current();
2705  if (IsDeadCheck(isolate, "v8::Value::StrictEquals()")
2706  || EmptyCheck("v8::Value::StrictEquals()", this)
2707  || EmptyCheck("v8::Value::StrictEquals()", that)) {
2708  return false;
2709  }
2710  LOG_API(isolate, "StrictEquals");
2712  i::Handle<i::Object> other = Utils::OpenHandle(*that);
2713  // Must check HeapNumber first, since NaN !== NaN.
2714  if (obj->IsHeapNumber()) {
2715  if (!other->IsNumber()) return false;
2716  double x = obj->Number();
2717  double y = other->Number();
2718  // Must check explicitly for NaN:s on Windows, but -0 works fine.
2719  return x == y && !isnan(x) && !isnan(y);
2720  } else if (*obj == *other) { // Also covers Booleans.
2721  return true;
2722  } else if (obj->IsSmi()) {
2723  return other->IsNumber() && obj->Number() == other->Number();
2724  } else if (obj->IsString()) {
2725  return other->IsString() &&
2726  i::String::cast(*obj)->Equals(i::String::cast(*other));
2727  } else if (obj->IsUndefined() || obj->IsUndetectableObject()) {
2728  return other->IsUndefined() || other->IsUndetectableObject();
2729  } else {
2730  return false;
2731  }
2732 }
2733 
2734 
2735 uint32_t Value::Uint32Value() const {
2737  if (obj->IsSmi()) {
2738  return i::Smi::cast(*obj)->value();
2739  } else {
2740  i::Isolate* isolate = i::Isolate::Current();
2741  if (IsDeadCheck(isolate, "v8::Value::Uint32Value()")) return 0;
2742  LOG_API(isolate, "Uint32Value");
2743  ENTER_V8(isolate);
2744  EXCEPTION_PREAMBLE(isolate);
2745  i::Handle<i::Object> num =
2746  i::Execution::ToUint32(obj, &has_pending_exception);
2747  EXCEPTION_BAILOUT_CHECK(isolate, 0);
2748  if (num->IsSmi()) {
2749  return i::Smi::cast(*num)->value();
2750  } else {
2751  return static_cast<uint32_t>(num->Number());
2752  }
2753  }
2754 }
2755 
2756 
2758  v8::PropertyAttribute attribs) {
2759  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2760  ON_BAILOUT(isolate, "v8::Object::Set()", return false);
2761  ENTER_V8(isolate);
2762  i::HandleScope scope(isolate);
2764  i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
2765  i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
2766  EXCEPTION_PREAMBLE(isolate);
2768  self,
2769  key_obj,
2770  value_obj,
2771  static_cast<PropertyAttributes>(attribs),
2773  has_pending_exception = obj.is_null();
2774  EXCEPTION_BAILOUT_CHECK(isolate, false);
2775  return true;
2776 }
2777 
2778 
2779 bool v8::Object::Set(uint32_t index, v8::Handle<Value> value) {
2780  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2781  ON_BAILOUT(isolate, "v8::Object::Set()", return false);
2782  ENTER_V8(isolate);
2783  i::HandleScope scope(isolate);
2785  i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
2786  EXCEPTION_PREAMBLE(isolate);
2788  self,
2789  index,
2790  value_obj,
2791  NONE,
2793  has_pending_exception = obj.is_null();
2794  EXCEPTION_BAILOUT_CHECK(isolate, false);
2795  return true;
2796 }
2797 
2798 
2800  v8::Handle<Value> value,
2801  v8::PropertyAttribute attribs) {
2802  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2803  ON_BAILOUT(isolate, "v8::Object::ForceSet()", return false);
2804  ENTER_V8(isolate);
2805  i::HandleScope scope(isolate);
2807  i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
2808  i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
2809  EXCEPTION_PREAMBLE(isolate);
2811  self,
2812  key_obj,
2813  value_obj,
2814  static_cast<PropertyAttributes>(attribs));
2815  has_pending_exception = obj.is_null();
2816  EXCEPTION_BAILOUT_CHECK(isolate, false);
2817  return true;
2818 }
2819 
2820 
2822  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2823  ON_BAILOUT(isolate, "v8::Object::ForceDelete()", return false);
2824  ENTER_V8(isolate);
2825  i::HandleScope scope(isolate);
2827  i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
2828 
2829  // When deleting a property on the global object using ForceDelete
2830  // deoptimize all functions as optimized code does not check for the hole
2831  // value with DontDelete properties. We have to deoptimize all contexts
2832  // because of possible cross-context inlined functions.
2833  if (self->IsJSGlobalProxy() || self->IsGlobalObject()) {
2835  }
2836 
2837  EXCEPTION_PREAMBLE(isolate);
2838  i::Handle<i::Object> obj = i::ForceDeleteProperty(self, key_obj);
2839  has_pending_exception = obj.is_null();
2840  EXCEPTION_BAILOUT_CHECK(isolate, false);
2841  return obj->IsTrue();
2842 }
2843 
2844 
2846  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2847  ON_BAILOUT(isolate, "v8::Object::Get()", return Local<v8::Value>());
2848  ENTER_V8(isolate);
2850  i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
2851  EXCEPTION_PREAMBLE(isolate);
2852  i::Handle<i::Object> result = i::GetProperty(self, key_obj);
2853  has_pending_exception = result.is_null();
2855  return Utils::ToLocal(result);
2856 }
2857 
2858 
2860  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2861  ON_BAILOUT(isolate, "v8::Object::Get()", return Local<v8::Value>());
2862  ENTER_V8(isolate);
2864  EXCEPTION_PREAMBLE(isolate);
2865  i::Handle<i::Object> result = i::Object::GetElement(self, index);
2866  has_pending_exception = result.is_null();
2868  return Utils::ToLocal(result);
2869 }
2870 
2871 
2873  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2874  ON_BAILOUT(isolate, "v8::Object::GetPropertyAttribute()",
2875  return static_cast<PropertyAttribute>(NONE));
2876  ENTER_V8(isolate);
2877  i::HandleScope scope(isolate);
2879  i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
2880  if (!key_obj->IsString()) {
2881  EXCEPTION_PREAMBLE(isolate);
2882  key_obj = i::Execution::ToString(key_obj, &has_pending_exception);
2883  EXCEPTION_BAILOUT_CHECK(isolate, static_cast<PropertyAttribute>(NONE));
2884  }
2885  i::Handle<i::String> key_string = i::Handle<i::String>::cast(key_obj);
2886  PropertyAttributes result = self->GetPropertyAttribute(*key_string);
2887  if (result == ABSENT) return static_cast<PropertyAttribute>(NONE);
2888  return static_cast<PropertyAttribute>(result);
2889 }
2890 
2891 
2893  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2894  ON_BAILOUT(isolate, "v8::Object::GetPrototype()",
2895  return Local<v8::Value>());
2896  ENTER_V8(isolate);
2898  i::Handle<i::Object> result(self->GetPrototype());
2899  return Utils::ToLocal(result);
2900 }
2901 
2902 
2904  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2905  ON_BAILOUT(isolate, "v8::Object::SetPrototype()", return false);
2906  ENTER_V8(isolate);
2908  i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
2909  // We do not allow exceptions thrown while setting the prototype
2910  // to propagate outside.
2911  TryCatch try_catch;
2912  EXCEPTION_PREAMBLE(isolate);
2913  i::Handle<i::Object> result = i::SetPrototype(self, value_obj);
2914  has_pending_exception = result.is_null();
2915  EXCEPTION_BAILOUT_CHECK(isolate, false);
2916  return true;
2917 }
2918 
2919 
2922  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2923  ON_BAILOUT(isolate,
2924  "v8::Object::FindInstanceInPrototypeChain()",
2925  return Local<v8::Object>());
2926  ENTER_V8(isolate);
2927  i::JSObject* object = *Utils::OpenHandle(this);
2928  i::FunctionTemplateInfo* tmpl_info = *Utils::OpenHandle(*tmpl);
2929  while (!object->IsInstanceOf(tmpl_info)) {
2930  i::Object* prototype = object->GetPrototype();
2931  if (!prototype->IsJSObject()) return Local<Object>();
2932  object = i::JSObject::cast(prototype);
2933  }
2934  return Utils::ToLocal(i::Handle<i::JSObject>(object));
2935 }
2936 
2937 
2939  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2940  ON_BAILOUT(isolate, "v8::Object::GetPropertyNames()",
2941  return Local<v8::Array>());
2942  ENTER_V8(isolate);
2943  i::HandleScope scope(isolate);
2945  bool threw = false;
2946  i::Handle<i::FixedArray> value =
2948  if (threw) return Local<v8::Array>();
2949  // Because we use caching to speed up enumeration it is important
2950  // to never change the result of the basic enumeration function so
2951  // we clone the result.
2952  i::Handle<i::FixedArray> elms = isolate->factory()->CopyFixedArray(value);
2953  i::Handle<i::JSArray> result =
2954  isolate->factory()->NewJSArrayWithElements(elms);
2955  return Utils::ToLocal(scope.CloseAndEscape(result));
2956 }
2957 
2958 
2960  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2961  ON_BAILOUT(isolate, "v8::Object::GetOwnPropertyNames()",
2962  return Local<v8::Array>());
2963  ENTER_V8(isolate);
2964  i::HandleScope scope(isolate);
2966  bool threw = false;
2967  i::Handle<i::FixedArray> value =
2969  if (threw) return Local<v8::Array>();
2970  // Because we use caching to speed up enumeration it is important
2971  // to never change the result of the basic enumeration function so
2972  // we clone the result.
2973  i::Handle<i::FixedArray> elms = isolate->factory()->CopyFixedArray(value);
2974  i::Handle<i::JSArray> result =
2975  isolate->factory()->NewJSArrayWithElements(elms);
2976  return Utils::ToLocal(scope.CloseAndEscape(result));
2977 }
2978 
2979 
2981  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2982  ON_BAILOUT(isolate, "v8::Object::ObjectProtoToString()",
2983  return Local<v8::String>());
2984  ENTER_V8(isolate);
2986 
2987  i::Handle<i::Object> name(self->class_name());
2988 
2989  // Native implementation of Object.prototype.toString (v8natives.js):
2990  // var c = %ClassOf(this);
2991  // if (c === 'Arguments') c = 'Object';
2992  // return "[object " + c + "]";
2993 
2994  if (!name->IsString()) {
2995  return v8::String::New("[object ]");
2996 
2997  } else {
2999  if (class_name->IsEqualTo(i::CStrVector("Arguments"))) {
3000  return v8::String::New("[object Object]");
3001 
3002  } else {
3003  const char* prefix = "[object ";
3004  Local<String> str = Utils::ToLocal(class_name);
3005  const char* postfix = "]";
3006 
3007  int prefix_len = i::StrLength(prefix);
3008  int str_len = str->Length();
3009  int postfix_len = i::StrLength(postfix);
3010 
3011  int buf_len = prefix_len + str_len + postfix_len;
3012  i::ScopedVector<char> buf(buf_len);
3013 
3014  // Write prefix.
3015  char* ptr = buf.start();
3016  memcpy(ptr, prefix, prefix_len * v8::internal::kCharSize);
3017  ptr += prefix_len;
3018 
3019  // Write real content.
3020  str->WriteAscii(ptr, 0, str_len);
3021  ptr += str_len;
3022 
3023  // Write postfix.
3024  memcpy(ptr, postfix, postfix_len * v8::internal::kCharSize);
3025 
3026  // Copy the buffer into a heap-allocated string and return it.
3027  Local<String> result = v8::String::New(buf.start(), buf_len);
3028  return result;
3029  }
3030  }
3031 }
3032 
3033 
3035  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3036  ON_BAILOUT(isolate, "v8::Object::GetConstructorName()",
3037  return Local<v8::String>());
3038  ENTER_V8(isolate);
3040  i::Handle<i::String> name(self->constructor_name());
3041  return Utils::ToLocal(name);
3042 }
3043 
3044 
3046  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3047  ON_BAILOUT(isolate, "v8::Object::Delete()", return false);
3048  ENTER_V8(isolate);
3049  i::HandleScope scope(isolate);
3051  i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
3052  return i::JSObject::DeleteProperty(self, key_obj)->IsTrue();
3053 }
3054 
3055 
3057  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3058  ON_BAILOUT(isolate, "v8::Object::Has()", return false);
3059  ENTER_V8(isolate);
3061  i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
3062  return self->HasProperty(*key_obj);
3063 }
3064 
3065 
3066 bool v8::Object::Delete(uint32_t index) {
3067  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3068  ON_BAILOUT(isolate, "v8::Object::DeleteProperty()",
3069  return false);
3070  ENTER_V8(isolate);
3071  HandleScope scope;
3073  return i::JSObject::DeleteElement(self, index)->IsTrue();
3074 }
3075 
3076 
3077 bool v8::Object::Has(uint32_t index) {
3078  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3079  ON_BAILOUT(isolate, "v8::Object::HasProperty()", return false);
3081  return self->HasElement(index);
3082 }
3083 
3084 
3086  AccessorGetter getter,
3087  AccessorSetter setter,
3088  v8::Handle<Value> data,
3089  AccessControl settings,
3090  PropertyAttribute attributes) {
3091  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3092  ON_BAILOUT(isolate, "v8::Object::SetAccessor()", return false);
3093  ENTER_V8(isolate);
3094  i::HandleScope scope(isolate);
3096  i::Handle<i::AccessorInfo> info = MakeAccessorInfo(name, getter, setter, data,
3097  settings, attributes,
3098  signature);
3099  bool fast = Utils::OpenHandle(this)->HasFastProperties();
3101  if (result.is_null() || result->IsUndefined()) return false;
3103  return true;
3104 }
3105 
3106 
3108  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3109  ON_BAILOUT(isolate, "v8::Object::HasOwnProperty()",
3110  return false);
3111  return Utils::OpenHandle(this)->HasLocalProperty(
3112  *Utils::OpenHandle(*key));
3113 }
3114 
3115 
3117  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3118  ON_BAILOUT(isolate, "v8::Object::HasRealNamedProperty()",
3119  return false);
3120  return Utils::OpenHandle(this)->HasRealNamedProperty(
3121  *Utils::OpenHandle(*key));
3122 }
3123 
3124 
3126  ON_BAILOUT(Utils::OpenHandle(this)->GetIsolate(),
3127  "v8::Object::HasRealIndexedProperty()",
3128  return false);
3129  return Utils::OpenHandle(this)->HasRealElementProperty(index);
3130 }
3131 
3132 
3134  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3135  ON_BAILOUT(isolate,
3136  "v8::Object::HasRealNamedCallbackProperty()",
3137  return false);
3138  ENTER_V8(isolate);
3139  return Utils::OpenHandle(this)->HasRealNamedCallbackProperty(
3140  *Utils::OpenHandle(*key));
3141 }
3142 
3143 
3145  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3146  ON_BAILOUT(isolate, "v8::Object::HasNamedLookupInterceptor()",
3147  return false);
3148  return Utils::OpenHandle(this)->HasNamedInterceptor();
3149 }
3150 
3151 
3153  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3154  ON_BAILOUT(isolate, "v8::Object::HasIndexedLookupInterceptor()",
3155  return false);
3156  return Utils::OpenHandle(this)->HasIndexedInterceptor();
3157 }
3158 
3159 
3160 static Local<Value> GetPropertyByLookup(i::Isolate* isolate,
3161  i::Handle<i::JSObject> receiver,
3162  i::Handle<i::String> name,
3163  i::LookupResult* lookup) {
3164  if (!lookup->IsProperty()) {
3165  // No real property was found.
3166  return Local<Value>();
3167  }
3168 
3169  // If the property being looked up is a callback, it can throw
3170  // an exception.
3171  EXCEPTION_PREAMBLE(isolate);
3172  PropertyAttributes ignored;
3173  i::Handle<i::Object> result =
3174  i::Object::GetProperty(receiver, receiver, lookup, name,
3175  &ignored);
3176  has_pending_exception = result.is_null();
3177  EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
3178 
3179  return Utils::ToLocal(result);
3180 }
3181 
3182 
3184  Handle<String> key) {
3185  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3186  ON_BAILOUT(isolate,
3187  "v8::Object::GetRealNamedPropertyInPrototypeChain()",
3188  return Local<Value>());
3189  ENTER_V8(isolate);
3190  i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this);
3191  i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
3192  i::LookupResult lookup(isolate);
3193  self_obj->LookupRealNamedPropertyInPrototypes(*key_obj, &lookup);
3194  return GetPropertyByLookup(isolate, self_obj, key_obj, &lookup);
3195 }
3196 
3197 
3199  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3200  ON_BAILOUT(isolate, "v8::Object::GetRealNamedProperty()",
3201  return Local<Value>());
3202  ENTER_V8(isolate);
3203  i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this);
3204  i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
3205  i::LookupResult lookup(isolate);
3206  self_obj->LookupRealNamedProperty(*key_obj, &lookup);
3207  return GetPropertyByLookup(isolate, self_obj, key_obj, &lookup);
3208 }
3209 
3210 
3211 // Turns on access checks by copying the map and setting the check flag.
3212 // Because the object gets a new map, existing inline cache caching
3213 // the old map of this object will fail.
3215  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3216  ON_BAILOUT(isolate, "v8::Object::TurnOnAccessCheck()", return);
3217  ENTER_V8(isolate);
3218  i::HandleScope scope(isolate);
3220 
3221  // When turning on access checks for a global object deoptimize all functions
3222  // as optimized code does not always handle access checks.
3224 
3225  i::Handle<i::Map> new_map =
3226  isolate->factory()->CopyMapDropTransitions(i::Handle<i::Map>(obj->map()));
3227  new_map->set_is_access_check_needed(true);
3228  obj->set_map(*new_map);
3229 }
3230 
3231 
3233  return Utils::OpenHandle(this)->IsDirty();
3234 }
3235 
3236 
3238  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3239  ON_BAILOUT(isolate, "v8::Object::Clone()", return Local<Object>());
3240  ENTER_V8(isolate);
3242  EXCEPTION_PREAMBLE(isolate);
3243  i::Handle<i::JSObject> result = i::Copy(self);
3244  has_pending_exception = result.is_null();
3246  return Utils::ToLocal(result);
3247 }
3248 
3249 
3250 static i::Context* GetCreationContext(i::JSObject* object) {
3251  i::Object* constructor = object->map()->constructor();
3252  i::JSFunction* function;
3253  if (!constructor->IsJSFunction()) {
3254  // Functions have null as a constructor,
3255  // but any JSFunction knows its context immediately.
3256  ASSERT(object->IsJSFunction());
3257  function = i::JSFunction::cast(object);
3258  } else {
3259  function = i::JSFunction::cast(constructor);
3260  }
3261  return function->context()->global_context();
3262 }
3263 
3264 
3266  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3267  ON_BAILOUT(isolate,
3268  "v8::Object::CreationContext()", return Local<v8::Context>());
3269  ENTER_V8(isolate);
3271  i::Context* context = GetCreationContext(*self);
3272  return Utils::ToLocal(i::Handle<i::Context>(context));
3273 }
3274 
3275 
3277  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3278  ON_BAILOUT(isolate, "v8::Object::GetIdentityHash()", return 0);
3279  ENTER_V8(isolate);
3280  i::HandleScope scope(isolate);
3282  return i::JSObject::GetIdentityHash(self);
3283 }
3284 
3285 
3287  v8::Handle<v8::Value> value) {
3288  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3289  ON_BAILOUT(isolate, "v8::Object::SetHiddenValue()", return false);
3290  ENTER_V8(isolate);
3291  i::HandleScope scope(isolate);
3293  i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
3294  i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
3295  i::Handle<i::Object> result =
3296  i::JSObject::SetHiddenProperty(self, key_obj, value_obj);
3297  return *result == *self;
3298 }
3299 
3300 
3302  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3303  ON_BAILOUT(isolate, "v8::Object::GetHiddenValue()",
3304  return Local<v8::Value>());
3305  ENTER_V8(isolate);
3307  i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
3308  i::Handle<i::Object> result(self->GetHiddenProperty(*key_obj));
3309  if (result->IsUndefined()) return v8::Local<v8::Value>();
3310  return Utils::ToLocal(result);
3311 }
3312 
3313 
3315  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3316  ON_BAILOUT(isolate, "v8::DeleteHiddenValue()", return false);
3317  ENTER_V8(isolate);
3318  i::HandleScope scope(isolate);
3320  i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
3321  self->DeleteHiddenProperty(*key_obj);
3322  return true;
3323 }
3324 
3325 
3326 namespace {
3327 
3328 static i::ElementsKind GetElementsKindFromExternalArrayType(
3329  ExternalArrayType array_type) {
3330  switch (array_type) {
3331  case kExternalByteArray:
3333  break;
3336  break;
3337  case kExternalShortArray:
3339  break;
3342  break;
3343  case kExternalIntArray:
3344  return i::EXTERNAL_INT_ELEMENTS;
3345  break;
3348  break;
3349  case kExternalFloatArray:
3351  break;
3352  case kExternalDoubleArray:
3354  break;
3355  case kExternalPixelArray:
3357  break;
3358  }
3359  UNREACHABLE();
3360  return i::DICTIONARY_ELEMENTS;
3361 }
3362 
3363 
3364 void PrepareExternalArrayElements(i::Handle<i::JSObject> object,
3365  void* data,
3366  ExternalArrayType array_type,
3367  int length) {
3368  i::Isolate* isolate = object->GetIsolate();
3370  isolate->factory()->NewExternalArray(length, array_type, data);
3371 
3372  i::Handle<i::Map> external_array_map =
3373  isolate->factory()->GetElementsTransitionMap(
3374  object,
3375  GetElementsKindFromExternalArrayType(array_type));
3376 
3377  object->set_map(*external_array_map);
3378  object->set_elements(*array);
3379 }
3380 
3381 } // namespace
3382 
3383 
3384 void v8::Object::SetIndexedPropertiesToPixelData(uint8_t* data, int length) {
3385  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3386  ON_BAILOUT(isolate, "v8::SetElementsToPixelData()", return);
3387  ENTER_V8(isolate);
3388  i::HandleScope scope(isolate);
3389  if (!ApiCheck(length <= i::ExternalPixelArray::kMaxLength,
3390  "v8::Object::SetIndexedPropertiesToPixelData()",
3391  "length exceeds max acceptable value")) {
3392  return;
3393  }
3395  if (!ApiCheck(!self->IsJSArray(),
3396  "v8::Object::SetIndexedPropertiesToPixelData()",
3397  "JSArray is not supported")) {
3398  return;
3399  }
3400  PrepareExternalArrayElements(self, data, kExternalPixelArray, length);
3401 }
3402 
3403 
3406  ON_BAILOUT(self->GetIsolate(), "v8::HasIndexedPropertiesInPixelData()",
3407  return false);
3408  return self->HasExternalPixelElements();
3409 }
3410 
3411 
3414  ON_BAILOUT(self->GetIsolate(), "v8::GetIndexedPropertiesPixelData()",
3415  return NULL);
3416  if (self->HasExternalPixelElements()) {
3417  return i::ExternalPixelArray::cast(self->elements())->
3418  external_pixel_pointer();
3419  } else {
3420  return NULL;
3421  }
3422 }
3423 
3424 
3427  ON_BAILOUT(self->GetIsolate(), "v8::GetIndexedPropertiesPixelDataLength()",
3428  return -1);
3429  if (self->HasExternalPixelElements()) {
3430  return i::ExternalPixelArray::cast(self->elements())->length();
3431  } else {
3432  return -1;
3433  }
3434 }
3435 
3436 
3438  void* data,
3439  ExternalArrayType array_type,
3440  int length) {
3441  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3442  ON_BAILOUT(isolate, "v8::SetIndexedPropertiesToExternalArrayData()", return);
3443  ENTER_V8(isolate);
3444  i::HandleScope scope(isolate);
3445  if (!ApiCheck(length <= i::ExternalArray::kMaxLength,
3446  "v8::Object::SetIndexedPropertiesToExternalArrayData()",
3447  "length exceeds max acceptable value")) {
3448  return;
3449  }
3451  if (!ApiCheck(!self->IsJSArray(),
3452  "v8::Object::SetIndexedPropertiesToExternalArrayData()",
3453  "JSArray is not supported")) {
3454  return;
3455  }
3456  PrepareExternalArrayElements(self, data, array_type, length);
3457 }
3458 
3459 
3462  ON_BAILOUT(self->GetIsolate(),
3463  "v8::HasIndexedPropertiesInExternalArrayData()",
3464  return false);
3465  return self->HasExternalArrayElements();
3466 }
3467 
3468 
3471  ON_BAILOUT(self->GetIsolate(),
3472  "v8::GetIndexedPropertiesExternalArrayData()",
3473  return NULL);
3474  if (self->HasExternalArrayElements()) {
3475  return i::ExternalArray::cast(self->elements())->external_pointer();
3476  } else {
3477  return NULL;
3478  }
3479 }
3480 
3481 
3484  ON_BAILOUT(self->GetIsolate(),
3485  "v8::GetIndexedPropertiesExternalArrayDataType()",
3486  return static_cast<ExternalArrayType>(-1));
3487  switch (self->elements()->map()->instance_type()) {
3489  return kExternalByteArray;
3493  return kExternalShortArray;
3497  return kExternalIntArray;
3501  return kExternalFloatArray;
3503  return kExternalDoubleArray;
3505  return kExternalPixelArray;
3506  default:
3507  return static_cast<ExternalArrayType>(-1);
3508  }
3509 }
3510 
3511 
3514  ON_BAILOUT(self->GetIsolate(),
3515  "v8::GetIndexedPropertiesExternalArrayDataLength()",
3516  return 0);
3517  if (self->HasExternalArrayElements()) {
3518  return i::ExternalArray::cast(self->elements())->length();
3519  } else {
3520  return -1;
3521  }
3522 }
3523 
3524 
3526  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3527  ON_BAILOUT(isolate, "v8::Object::IsCallable()", return false);
3528  ENTER_V8(isolate);
3529  i::HandleScope scope(isolate);
3531  if (obj->IsJSFunction()) return true;
3532  return i::Execution::GetFunctionDelegate(obj)->IsJSFunction();
3533 }
3534 
3535 
3537  int argc,
3538  v8::Handle<v8::Value> argv[]) {
3539  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3540  ON_BAILOUT(isolate, "v8::Object::CallAsFunction()",
3541  return Local<v8::Value>());
3542  LOG_API(isolate, "Object::CallAsFunction");
3543  ENTER_V8(isolate);
3544  i::HandleScope scope(isolate);
3546  i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv);
3547  STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**));
3548  i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
3550  if (obj->IsJSFunction()) {
3551  fun = i::Handle<i::JSFunction>::cast(obj);
3552  } else {
3553  EXCEPTION_PREAMBLE(isolate);
3554  i::Handle<i::Object> delegate =
3555  i::Execution::TryGetFunctionDelegate(obj, &has_pending_exception);
3557  fun = i::Handle<i::JSFunction>::cast(delegate);
3558  recv_obj = obj;
3559  }
3560  EXCEPTION_PREAMBLE(isolate);
3561  i::Handle<i::Object> returned =
3562  i::Execution::Call(fun, recv_obj, argc, args, &has_pending_exception);
3564  return Utils::ToLocal(scope.CloseAndEscape(returned));
3565 }
3566 
3567 
3569  v8::Handle<v8::Value> argv[]) {
3570  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3571  ON_BAILOUT(isolate, "v8::Object::CallAsConstructor()",
3572  return Local<v8::Object>());
3573  LOG_API(isolate, "Object::CallAsConstructor");
3574  ENTER_V8(isolate);
3575  i::HandleScope scope(isolate);
3577  STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**));
3578  i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
3579  if (obj->IsJSFunction()) {
3581  EXCEPTION_PREAMBLE(isolate);
3582  i::Handle<i::Object> returned =
3583  i::Execution::New(fun, argc, args, &has_pending_exception);
3585  return Utils::ToLocal(scope.CloseAndEscape(
3586  i::Handle<i::JSObject>::cast(returned)));
3587  }
3588  EXCEPTION_PREAMBLE(isolate);
3589  i::Handle<i::Object> delegate =
3590  i::Execution::TryGetConstructorDelegate(obj, &has_pending_exception);
3592  if (!delegate->IsUndefined()) {
3594  EXCEPTION_PREAMBLE(isolate);
3595  i::Handle<i::Object> returned =
3596  i::Execution::Call(fun, obj, argc, args, &has_pending_exception);
3598  ASSERT(!delegate->IsUndefined());
3599  return Utils::ToLocal(scope.CloseAndEscape(returned));
3600  }
3601  return Local<v8::Object>();
3602 }
3603 
3604 
3606  return NewInstance(0, NULL);
3607 }
3608 
3609 
3611  v8::Handle<v8::Value> argv[]) const {
3612  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3613  ON_BAILOUT(isolate, "v8::Function::NewInstance()",
3614  return Local<v8::Object>());
3615  LOG_API(isolate, "Function::NewInstance");
3616  ENTER_V8(isolate);
3617  HandleScope scope;
3619  STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**));
3620  i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
3621  EXCEPTION_PREAMBLE(isolate);
3622  i::Handle<i::Object> returned =
3623  i::Execution::New(function, argc, args, &has_pending_exception);
3625  return scope.Close(Utils::ToLocal(i::Handle<i::JSObject>::cast(returned)));
3626 }
3627 
3628 
3630  v8::Handle<v8::Value> argv[]) {
3631  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3632  ON_BAILOUT(isolate, "v8::Function::Call()", return Local<v8::Value>());
3633  LOG_API(isolate, "Function::Call");
3634  ENTER_V8(isolate);
3635  i::Object* raw_result = NULL;
3636  {
3637  i::HandleScope scope(isolate);
3639  i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv);
3640  STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**));
3641  i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
3642  EXCEPTION_PREAMBLE(isolate);
3643  i::Handle<i::Object> returned =
3644  i::Execution::Call(fun, recv_obj, argc, args, &has_pending_exception);
3646  raw_result = *returned;
3647  }
3648  i::Handle<i::Object> result(raw_result);
3649  return Utils::ToLocal(result);
3650 }
3651 
3652 
3654  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3655  ENTER_V8(isolate);
3656  USE(isolate);
3658  func->shared()->set_name(*Utils::OpenHandle(*name));
3659 }
3660 
3661 
3664  return Utils::ToLocal(i::Handle<i::Object>(func->shared()->name()));
3665 }
3666 
3667 
3670  return Utils::ToLocal(i::Handle<i::Object>(func->shared()->inferred_name()));
3671 }
3672 
3673 
3676  if (func->shared()->script()->IsScript()) {
3677  i::Handle<i::Script> script(i::Script::cast(func->shared()->script()));
3678  v8::ScriptOrigin origin(
3679  Utils::ToLocal(i::Handle<i::Object>(script->name())),
3680  v8::Integer::New(script->line_offset()->value()),
3681  v8::Integer::New(script->column_offset()->value()));
3682  return origin;
3683  }
3684  return v8::ScriptOrigin(Handle<Value>());
3685 }
3686 
3687 
3688 const int Function::kLineOffsetNotFound = -1;
3689 
3690 
3693  if (func->shared()->script()->IsScript()) {
3694  i::Handle<i::Script> script(i::Script::cast(func->shared()->script()));
3695  return i::GetScriptLineNumber(script, func->shared()->start_position());
3696  }
3697  return kLineOffsetNotFound;
3698 }
3699 
3700 
3703  if (func->shared()->script()->IsScript()) {
3704  i::Handle<i::Script> script(i::Script::cast(func->shared()->script()));
3705  return i::GetScriptColumnNumber(script, func->shared()->start_position());
3706  }
3707  return kLineOffsetNotFound;
3708 }
3709 
3712  if (!func->shared()->script()->IsScript())
3713  return v8::Undefined();
3714  i::Handle<i::Script> script(i::Script::cast(func->shared()->script()));
3715  return Utils::ToLocal(i::Handle<i::Object>(script->id()));
3716 }
3717 
3718 int String::Length() const {
3720  if (IsDeadCheck(str->GetIsolate(), "v8::String::Length()")) return 0;
3721  return str->length();
3722 }
3723 
3724 
3725 int String::Utf8Length() const {
3727  if (IsDeadCheck(str->GetIsolate(), "v8::String::Utf8Length()")) return 0;
3728  return i::Utf8Length(str);
3729 }
3730 
3731 
3732 // Will fail with a negative answer if the recursion depth is too high.
3733 static int RecursivelySerializeToUtf8(i::String* string,
3734  char* buffer,
3735  int start,
3736  int end,
3737  int recursion_budget,
3738  int32_t previous_character,
3739  int32_t* last_character) {
3740  int utf8_bytes = 0;
3741  while (true) {
3742  if (string->IsAsciiRepresentation()) {
3743  i::String::WriteToFlat(string, buffer, start, end);
3744  *last_character = unibrow::Utf16::kNoPreviousCharacter;
3745  return utf8_bytes + end - start;
3746  }
3747  switch (i::StringShape(string).representation_tag()) {
3748  case i::kExternalStringTag: {
3749  const uint16_t* data = i::ExternalTwoByteString::cast(string)->
3750  ExternalTwoByteStringGetData(0);
3751  char* current = buffer;
3752  for (int i = start; i < end; i++) {
3753  uint16_t character = data[i];
3754  current +=
3755  unibrow::Utf8::Encode(current, character, previous_character);
3756  previous_character = character;
3757  }
3758  *last_character = previous_character;
3759  return static_cast<int>(utf8_bytes + current - buffer);
3760  }
3761  case i::kSeqStringTag: {
3762  const uint16_t* data =
3764  char* current = buffer;
3765  for (int i = start; i < end; i++) {
3766  uint16_t character = data[i];
3767  current +=
3768  unibrow::Utf8::Encode(current, character, previous_character);
3769  previous_character = character;
3770  }
3771  *last_character = previous_character;
3772  return static_cast<int>(utf8_bytes + current - buffer);
3773  }
3774  case i::kSlicedStringTag: {
3775  i::SlicedString* slice = i::SlicedString::cast(string);
3776  unsigned offset = slice->offset();
3777  string = slice->parent();
3778  start += offset;
3779  end += offset;
3780  continue;
3781  }
3782  case i::kConsStringTag: {
3783  i::ConsString* cons_string = i::ConsString::cast(string);
3784  i::String* first = cons_string->first();
3785  int boundary = first->length();
3786  if (start >= boundary) {
3787  // Only need RHS.
3788  string = cons_string->second();
3789  start -= boundary;
3790  end -= boundary;
3791  continue;
3792  } else if (end <= boundary) {
3793  // Only need LHS.
3794  string = first;
3795  } else {
3796  if (recursion_budget == 0) return -1;
3797  int extra_utf8_bytes =
3798  RecursivelySerializeToUtf8(first,
3799  buffer,
3800  start,
3801  boundary,
3802  recursion_budget - 1,
3803  previous_character,
3804  &previous_character);
3805  if (extra_utf8_bytes < 0) return extra_utf8_bytes;
3806  buffer += extra_utf8_bytes;
3807  utf8_bytes += extra_utf8_bytes;
3808  string = cons_string->second();
3809  start = 0;
3810  end -= boundary;
3811  }
3812  }
3813  }
3814  }
3815  UNREACHABLE();
3816  return 0;
3817 }
3818 
3819 
3822  if (IsDeadCheck(str->GetIsolate(), "v8::String::MayContainNonAscii()")) {
3823  return false;
3824  }
3825  return !str->HasOnlyAsciiChars();
3826 }
3827 
3828 
3829 int String::WriteUtf8(char* buffer,
3830  int capacity,
3831  int* nchars_ref,
3832  int options) const {
3833  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3834  if (IsDeadCheck(isolate, "v8::String::WriteUtf8()")) return 0;
3835  LOG_API(isolate, "String::WriteUtf8");
3836  ENTER_V8(isolate);
3838  int string_length = str->length();
3839  if (str->IsAsciiRepresentation()) {
3840  int len;
3841  if (capacity == -1) {
3842  capacity = str->length() + 1;
3843  len = string_length;
3844  } else {
3845  len = i::Min(capacity, str->length());
3846  }
3847  i::String::WriteToFlat(*str, buffer, 0, len);
3848  if (nchars_ref != NULL) *nchars_ref = len;
3849  if (!(options & NO_NULL_TERMINATION) && capacity > len) {
3850  buffer[len] = '\0';
3851  return len + 1;
3852  }
3853  return len;
3854  }
3855 
3856  if (capacity == -1 || capacity / 3 >= string_length) {
3858  const int kMaxRecursion = 100;
3859  int utf8_bytes =
3860  RecursivelySerializeToUtf8(*str,
3861  buffer,
3862  0,
3863  string_length,
3864  kMaxRecursion,
3865  previous,
3866  &previous);
3867  if (utf8_bytes >= 0) {
3868  // Success serializing with recursion.
3869  if ((options & NO_NULL_TERMINATION) == 0 &&
3870  (capacity > utf8_bytes || capacity == -1)) {
3871  buffer[utf8_bytes++] = '\0';
3872  }
3873  if (nchars_ref != NULL) *nchars_ref = string_length;
3874  return utf8_bytes;
3875  }
3876  FlattenString(str);
3877  // Recurse once. This time around the string is flat and the serializing
3878  // with recursion will certainly succeed.
3879  return WriteUtf8(buffer, capacity, nchars_ref, options);
3880  } else if (capacity >= string_length) {
3881  // First check that the buffer is large enough. If it is, then recurse
3882  // once without a capacity limit, which will get into the other branch of
3883  // this 'if'.
3884  int utf8_bytes = i::Utf8Length(str);
3885  if ((options & NO_NULL_TERMINATION) == 0) utf8_bytes++;
3886  if (utf8_bytes <= capacity) {
3887  return WriteUtf8(buffer, -1, nchars_ref, options);
3888  }
3889  }
3890 
3891  // Slow case.
3892  i::StringInputBuffer& write_input_buffer = *isolate->write_input_buffer();
3893  isolate->string_tracker()->RecordWrite(str);
3894  if (options & HINT_MANY_WRITES_EXPECTED) {
3895  // Flatten the string for efficiency. This applies whether we are
3896  // using StringInputBuffer or Get(i) to access the characters.
3897  FlattenString(str);
3898  }
3899  write_input_buffer.Reset(0, *str);
3900  int len = str->length();
3901  // Encode the first K - 3 bytes directly into the buffer since we
3902  // know there's room for them. If no capacity is given we copy all
3903  // of them here.
3904  int fast_end = capacity - (unibrow::Utf8::kMaxEncodedSize - 1);
3905  int i;
3906  int pos = 0;
3907  int nchars = 0;
3908  int previous = unibrow::Utf16::kNoPreviousCharacter;
3909  for (i = 0; i < len && (capacity == -1 || pos < fast_end); i++) {
3910  i::uc32 c = write_input_buffer.GetNext();
3911  int written = unibrow::Utf8::Encode(buffer + pos, c, previous);
3912  pos += written;
3913  nchars++;
3914  previous = c;
3915  }
3916  if (i < len) {
3917  // For the last characters we need to check the length for each one
3918  // because they may be longer than the remaining space in the
3919  // buffer.
3920  char intermediate[unibrow::Utf8::kMaxEncodedSize];
3921  for (; i < len && pos < capacity; i++) {
3922  i::uc32 c = write_input_buffer.GetNext();
3924  unibrow::Utf16::IsLeadSurrogate(previous)) {
3925  // We can't use the intermediate buffer here because the encoding
3926  // of surrogate pairs is done under assumption that you can step
3927  // back and fix the UTF8 stream. Luckily we only need space for one
3928  // more byte, so there is always space.
3929  ASSERT(pos < capacity);
3930  int written = unibrow::Utf8::Encode(buffer + pos, c, previous);
3931  ASSERT(written == 1);
3932  pos += written;
3933  nchars++;
3934  } else {
3935  int written =
3936  unibrow::Utf8::Encode(intermediate,
3937  c,
3939  if (pos + written <= capacity) {
3940  for (int j = 0; j < written; j++)
3941  buffer[pos + j] = intermediate[j];
3942  pos += written;
3943  nchars++;
3944  } else {
3945  // We've reached the end of the buffer
3946  break;
3947  }
3948  }
3949  previous = c;
3950  }
3951  }
3952  if (nchars_ref != NULL) *nchars_ref = nchars;
3953  if (!(options & NO_NULL_TERMINATION) &&
3954  (i == len && (capacity == -1 || pos < capacity)))
3955  buffer[pos++] = '\0';
3956  return pos;
3957 }
3958 
3959 
3960 int String::WriteAscii(char* buffer,
3961  int start,
3962  int length,
3963  int options) const {
3964  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3965  if (IsDeadCheck(isolate, "v8::String::WriteAscii()")) return 0;
3966  LOG_API(isolate, "String::WriteAscii");
3967  ENTER_V8(isolate);
3968  i::StringInputBuffer& write_input_buffer = *isolate->write_input_buffer();
3969  ASSERT(start >= 0 && length >= -1);
3971  isolate->string_tracker()->RecordWrite(str);
3972  if (options & HINT_MANY_WRITES_EXPECTED) {
3973  // Flatten the string for efficiency. This applies whether we are
3974  // using StringInputBuffer or Get(i) to access the characters.
3975  str->TryFlatten();
3976  }
3977  int end = length;
3978  if ( (length == -1) || (length > str->length() - start) )
3979  end = str->length() - start;
3980  if (end < 0) return 0;
3981  write_input_buffer.Reset(start, *str);
3982  int i;
3983  for (i = 0; i < end; i++) {
3984  char c = static_cast<char>(write_input_buffer.GetNext());
3985  if (c == '\0') c = ' ';
3986  buffer[i] = c;
3987  }
3988  if (!(options & NO_NULL_TERMINATION) && (length == -1 || i < length))
3989  buffer[i] = '\0';
3990  return i;
3991 }
3992 
3993 
3995  int start,
3996  int length,
3997  int options) const {
3998  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3999  if (IsDeadCheck(isolate, "v8::String::Write()")) return 0;
4000  LOG_API(isolate, "String::Write");
4001  ENTER_V8(isolate);
4002  ASSERT(start >= 0 && length >= -1);
4004  isolate->string_tracker()->RecordWrite(str);
4005  if (options & HINT_MANY_WRITES_EXPECTED) {
4006  // Flatten the string for efficiency. This applies whether we are
4007  // using StringInputBuffer or Get(i) to access the characters.
4008  str->TryFlatten();
4009  }
4010  int end = start + length;
4011  if ((length == -1) || (length > str->length() - start) )
4012  end = str->length();
4013  if (end < 0) return 0;
4014  i::String::WriteToFlat(*str, buffer, start, end);
4015  if (!(options & NO_NULL_TERMINATION) &&
4016  (length == -1 || end - start < length)) {
4017  buffer[end - start] = '\0';
4018  }
4019  return end - start;
4020 }
4021 
4022 
4025  if (IsDeadCheck(str->GetIsolate(), "v8::String::IsExternal()")) {
4026  return false;
4027  }
4028  EnsureInitializedForIsolate(str->GetIsolate(), "v8::String::IsExternal()");
4029  return i::StringShape(*str).IsExternalTwoByte();
4030 }
4031 
4032 
4035  if (IsDeadCheck(str->GetIsolate(), "v8::String::IsExternalAscii()")) {
4036  return false;
4037  }
4038  return i::StringShape(*str).IsExternalAscii();
4039 }
4040 
4041 
4042 void v8::String::VerifyExternalStringResource(
4043  v8::String::ExternalStringResource* value) const {
4045  const v8::String::ExternalStringResource* expected;
4046  if (i::StringShape(*str).IsExternalTwoByte()) {
4047  const void* resource =
4049  expected = reinterpret_cast<const ExternalStringResource*>(resource);
4050  } else {
4051  expected = NULL;
4052  }
4053  CHECK_EQ(expected, value);
4054 }
4055 
4056 
4060  if (IsDeadCheck(str->GetIsolate(),
4061  "v8::String::GetExternalAsciiStringResource()")) {
4062  return NULL;
4063  }
4064  if (i::StringShape(*str).IsExternalAscii()) {
4065  const void* resource =
4066  i::Handle<i::ExternalAsciiString>::cast(str)->resource();
4067  return reinterpret_cast<const ExternalAsciiStringResource*>(resource);
4068  } else {
4069  return NULL;
4070  }
4071 }
4072 
4073 
4074 double Number::Value() const {
4075  if (IsDeadCheck(i::Isolate::Current(), "v8::Number::Value()")) return 0;
4077  return obj->Number();
4078 }
4079 
4080 
4081 bool Boolean::Value() const {
4082  if (IsDeadCheck(i::Isolate::Current(), "v8::Boolean::Value()")) return false;
4084  return obj->IsTrue();
4085 }
4086 
4087 
4088 int64_t Integer::Value() const {
4089  if (IsDeadCheck(i::Isolate::Current(), "v8::Integer::Value()")) return 0;
4091  if (obj->IsSmi()) {
4092  return i::Smi::cast(*obj)->value();
4093  } else {
4094  return static_cast<int64_t>(obj->Number());
4095  }
4096 }
4097 
4098 
4100  if (IsDeadCheck(i::Isolate::Current(), "v8::Int32::Value()")) return 0;
4102  if (obj->IsSmi()) {
4103  return i::Smi::cast(*obj)->value();
4104  } else {
4105  return static_cast<int32_t>(obj->Number());
4106  }
4107 }
4108 
4109 
4110 uint32_t Uint32::Value() const {
4111  if (IsDeadCheck(i::Isolate::Current(), "v8::Uint32::Value()")) return 0;
4113  if (obj->IsSmi()) {
4114  return i::Smi::cast(*obj)->value();
4115  } else {
4116  return static_cast<uint32_t>(obj->Number());
4117  }
4118 }
4119 
4120 
4123  if (IsDeadCheck(obj->GetIsolate(), "v8::Object::InternalFieldCount()")) {
4124  return 0;
4125  }
4126  return obj->GetInternalFieldCount();
4127 }
4128 
4129 
4130 Local<Value> v8::Object::CheckedGetInternalField(int index) {
4132  if (IsDeadCheck(obj->GetIsolate(), "v8::Object::GetInternalField()")) {
4133  return Local<Value>();
4134  }
4135  if (!ApiCheck(index < obj->GetInternalFieldCount(),
4136  "v8::Object::GetInternalField()",
4137  "Reading internal field out of bounds")) {
4138  return Local<Value>();
4139  }
4140  i::Handle<i::Object> value(obj->GetInternalField(index));
4141  Local<Value> result = Utils::ToLocal(value);
4142 #ifdef DEBUG
4143  Local<Value> unchecked = UncheckedGetInternalField(index);
4144  ASSERT(unchecked.IsEmpty() || (unchecked == result));
4145 #endif
4146  return result;
4147 }
4148 
4149 
4152  i::Isolate* isolate = obj->GetIsolate();
4153  if (IsDeadCheck(isolate, "v8::Object::SetInternalField()")) {
4154  return;
4155  }
4156  if (!ApiCheck(index < obj->GetInternalFieldCount(),
4157  "v8::Object::SetInternalField()",
4158  "Writing internal field out of bounds")) {
4159  return;
4160  }
4161  ENTER_V8(isolate);
4163  obj->SetInternalField(index, *val);
4164 }
4165 
4166 
4167 static bool CanBeEncodedAsSmi(void* ptr) {
4168  const uintptr_t address = reinterpret_cast<uintptr_t>(ptr);
4169  return ((address & i::kEncodablePointerMask) == 0);
4170 }
4171 
4172 
4173 static i::Smi* EncodeAsSmi(void* ptr) {
4174  ASSERT(CanBeEncodedAsSmi(ptr));
4175  const uintptr_t address = reinterpret_cast<uintptr_t>(ptr);
4176  i::Smi* result = reinterpret_cast<i::Smi*>(address << i::kPointerToSmiShift);
4178  ASSERT_EQ(result, i::Smi::FromInt(result->value()));
4180  return result;
4181 }
4182 
4183 
4184 void v8::Object::SetPointerInInternalField(int index, void* value) {
4185  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4186  ENTER_V8(isolate);
4187  if (CanBeEncodedAsSmi(value)) {
4188  Utils::OpenHandle(this)->SetInternalField(index, EncodeAsSmi(value));
4189  } else {
4190  HandleScope scope;
4191  i::Handle<i::Foreign> foreign =
4192  isolate->factory()->NewForeign(
4193  reinterpret_cast<i::Address>(value), i::TENURED);
4194  if (!foreign.is_null())
4195  Utils::OpenHandle(this)->SetInternalField(index, *foreign);
4196  }
4197  ASSERT_EQ(value, GetPointerFromInternalField(index));
4198 }
4199 
4200 
4201 // --- E n v i r o n m e n t ---
4202 
4203 
4205  i::Isolate* isolate = i::Isolate::UncheckedCurrent();
4206  if (isolate != NULL && isolate->IsInitialized()) {
4207  return true;
4208  }
4209  return InitializeHelper();
4210 }
4211 
4212 
4214  i::V8::SetEntropySource(source);
4215 }
4216 
4217 
4219  ReturnAddressLocationResolver return_address_resolver) {
4220  i::V8::SetReturnAddressLocationResolver(return_address_resolver);
4221 }
4222 
4223 
4225  i::Isolate* isolate = i::Isolate::Current();
4226  if (!ApiCheck(isolate != NULL && isolate->IsDefaultIsolate(),
4227  "v8::V8::Dispose()",
4228  "Use v8::Isolate::Dispose() for a non-default isolate.")) {
4229  return false;
4230  }
4231  i::V8::TearDown();
4232  return true;
4233 }
4234 
4235 
4236 HeapStatistics::HeapStatistics(): total_heap_size_(0),
4237  total_heap_size_executable_(0),
4238  used_heap_size_(0),
4239  heap_size_limit_(0) { }
4240 
4241 
4243  if (!i::Isolate::Current()->IsInitialized()) {
4244  // Isolate is unitialized thus heap is not configured yet.
4245  heap_statistics->set_total_heap_size(0);
4246  heap_statistics->set_total_heap_size_executable(0);
4247  heap_statistics->set_used_heap_size(0);
4248  heap_statistics->set_heap_size_limit(0);
4249  return;
4250  }
4251 
4252  i::Heap* heap = i::Isolate::Current()->heap();
4253  heap_statistics->set_total_heap_size(heap->CommittedMemory());
4254  heap_statistics->set_total_heap_size_executable(
4255  heap->CommittedMemoryExecutable());
4256  heap_statistics->set_used_heap_size(heap->SizeOfObjects());
4257  heap_statistics->set_heap_size_limit(heap->MaxReserved());
4258 }
4259 
4260 
4262  i::Isolate* isolate = i::Isolate::Current();
4263  IsDeadCheck(isolate, "v8::V8::VisitExternalResources");
4264  isolate->heap()->VisitExternalResources(visitor);
4265 }
4266 
4267 
4269  // Returning true tells the caller that it need not
4270  // continue to call IdleNotification.
4271  i::Isolate* isolate = i::Isolate::Current();
4272  if (isolate == NULL || !isolate->IsInitialized()) return true;
4273  return i::V8::IdleNotification(hint);
4274 }
4275 
4276 
4278  i::Isolate* isolate = i::Isolate::Current();
4279  if (isolate == NULL || !isolate->IsInitialized()) return;
4280  isolate->heap()->CollectAllAvailableGarbage("low memory notification");
4281 }
4282 
4283 
4285  i::Isolate* isolate = i::Isolate::Current();
4286  if (!isolate->IsInitialized()) return 0;
4287  return isolate->heap()->NotifyContextDisposed();
4288 }
4289 
4290 
4291 const char* v8::V8::GetVersion() {
4292  return i::Version::GetVersion();
4293 }
4294 
4295 
4297  EnsureConstructor(i::Handle<i::ObjectTemplateInfo> templ) {
4298  if (templ->constructor()->IsUndefined()) {
4300  Utils::OpenHandle(*constructor)->set_instance_template(*templ);
4301  templ->set_constructor(*Utils::OpenHandle(*constructor));
4302  }
4304  i::FunctionTemplateInfo::cast(templ->constructor()));
4305 }
4306 
4307 
4309  v8::ExtensionConfiguration* extensions,
4310  v8::Handle<ObjectTemplate> global_template,
4311  v8::Handle<Value> global_object) {
4313  i::Isolate* isolate = i::Isolate::Current();
4314  EnsureInitializedForIsolate(isolate, "v8::Context::New()");
4315  LOG_API(isolate, "Context::New");
4316  ON_BAILOUT(isolate, "v8::Context::New()", return Persistent<Context>());
4317 
4318  // Enter V8 via an ENTER_V8 scope.
4320  {
4321  ENTER_V8(isolate);
4322  v8::Handle<ObjectTemplate> proxy_template = global_template;
4323  i::Handle<i::FunctionTemplateInfo> proxy_constructor;
4324  i::Handle<i::FunctionTemplateInfo> global_constructor;
4325 
4326  if (!global_template.IsEmpty()) {
4327  // Make sure that the global_template has a constructor.
4328  global_constructor =
4329  EnsureConstructor(Utils::OpenHandle(*global_template));
4330 
4331  // Create a fresh template for the global proxy object.
4332  proxy_template = ObjectTemplate::New();
4333  proxy_constructor =
4334  EnsureConstructor(Utils::OpenHandle(*proxy_template));
4335 
4336  // Set the global template to be the prototype template of
4337  // global proxy template.
4338  proxy_constructor->set_prototype_template(
4339  *Utils::OpenHandle(*global_template));
4340 
4341  // Migrate security handlers from global_template to
4342  // proxy_template. Temporarily removing access check
4343  // information from the global template.
4344  if (!global_constructor->access_check_info()->IsUndefined()) {
4345  proxy_constructor->set_access_check_info(
4346  global_constructor->access_check_info());
4347  proxy_constructor->set_needs_access_check(
4348  global_constructor->needs_access_check());
4349  global_constructor->set_needs_access_check(false);
4350  global_constructor->set_access_check_info(
4351  isolate->heap()->undefined_value());
4352  }
4353  }
4354 
4355  // Create the environment.
4356  env = isolate->bootstrapper()->CreateEnvironment(
4357  isolate,
4358  Utils::OpenHandle(*global_object),
4359  proxy_template,
4360  extensions);
4361 
4362  // Restore the access check info on the global template.
4363  if (!global_template.IsEmpty()) {
4364  ASSERT(!global_constructor.is_null());
4365  ASSERT(!proxy_constructor.is_null());
4366  global_constructor->set_access_check_info(
4367  proxy_constructor->access_check_info());
4368  global_constructor->set_needs_access_check(
4369  proxy_constructor->needs_access_check());
4370  }
4371  isolate->runtime_profiler()->Reset();
4372  }
4373  // Leave V8.
4374 
4375  if (env.is_null()) {
4376  return Persistent<Context>();
4377  }
4378  return Persistent<Context>(Utils::ToLocal(env));
4379 }
4380 
4381 
4383  i::Isolate* isolate = i::Isolate::Current();
4384  if (IsDeadCheck(isolate, "v8::Context::SetSecurityToken()")) {
4385  return;
4386  }
4387  ENTER_V8(isolate);
4389  i::Handle<i::Object> token_handle = Utils::OpenHandle(*token);
4390  env->set_security_token(*token_handle);
4391 }
4392 
4393 
4395  i::Isolate* isolate = i::Isolate::Current();
4396  if (IsDeadCheck(isolate,
4397  "v8::Context::UseDefaultSecurityToken()")) {
4398  return;
4399  }
4400  ENTER_V8(isolate);
4402  env->set_security_token(env->global());
4403 }
4404 
4405 
4407  i::Isolate* isolate = i::Isolate::Current();
4408  if (IsDeadCheck(isolate, "v8::Context::GetSecurityToken()")) {
4409  return Handle<Value>();
4410  }
4412  i::Object* security_token = env->security_token();
4413  i::Handle<i::Object> token_handle(security_token);
4414  return Utils::ToLocal(token_handle);
4415 }
4416 
4417 
4420  return env->has_out_of_memory();
4421 }
4422 
4423 
4425  return i::Isolate::Current()->context() != NULL;
4426 }
4427 
4428 
4430  i::Isolate* isolate = i::Isolate::Current();
4431  if (!EnsureInitializedForIsolate(isolate, "v8::Context::GetEntered()")) {
4432  return Local<Context>();
4433  }
4434  i::Handle<i::Object> last =
4436  if (last.is_null()) return Local<Context>();
4438  return Utils::ToLocal(context);
4439 }
4440 
4441 
4443  i::Isolate* isolate = i::Isolate::Current();
4444  if (IsDeadCheck(isolate, "v8::Context::GetCurrent()")) {
4445  return Local<Context>();
4446  }
4447  i::Handle<i::Object> current = isolate->global_context();
4448  if (current.is_null()) return Local<Context>();
4450  return Utils::ToLocal(context);
4451 }
4452 
4453 
4455  i::Isolate* isolate = i::Isolate::Current();
4456  if (IsDeadCheck(isolate, "v8::Context::GetCalling()")) {
4457  return Local<Context>();
4458  }
4459  i::Handle<i::Object> calling =
4460  isolate->GetCallingGlobalContext();
4461  if (calling.is_null()) return Local<Context>();
4463  return Utils::ToLocal(context);
4464 }
4465 
4466 
4468  if (IsDeadCheck(i::Isolate::Current(), "v8::Context::Global()")) {
4469  return Local<v8::Object>();
4470  }
4471  i::Object** ctx = reinterpret_cast<i::Object**>(this);
4472  i::Handle<i::Context> context =
4474  i::Handle<i::Object> global(context->global_proxy());
4476 }
4477 
4478 
4480  i::Isolate* isolate = i::Isolate::Current();
4481  if (IsDeadCheck(isolate, "v8::Context::DetachGlobal()")) return;
4482  ENTER_V8(isolate);
4483  i::Object** ctx = reinterpret_cast<i::Object**>(this);
4484  i::Handle<i::Context> context =
4486  isolate->bootstrapper()->DetachGlobal(context);
4487 }
4488 
4489 
4491  i::Isolate* isolate = i::Isolate::Current();
4492  if (IsDeadCheck(isolate, "v8::Context::ReattachGlobal()")) return;
4493  ENTER_V8(isolate);
4494  i::Object** ctx = reinterpret_cast<i::Object**>(this);
4495  i::Handle<i::Context> context =
4497  isolate->bootstrapper()->ReattachGlobal(
4498  context,
4499  Utils::OpenHandle(*global_object));
4500 }
4501 
4502 
4504  i::Isolate* isolate = i::Isolate::Current();
4505  if (IsDeadCheck(isolate, "v8::Context::AllowCodeGenerationFromStrings()")) {
4506  return;
4507  }
4508  ENTER_V8(isolate);
4509  i::Object** ctx = reinterpret_cast<i::Object**>(this);
4510  i::Handle<i::Context> context =
4512  context->set_allow_code_gen_from_strings(
4513  allow ? isolate->heap()->true_value() : isolate->heap()->false_value());
4514 }
4515 
4516 
4518  i::Isolate* isolate = i::Isolate::Current();
4519  if (IsDeadCheck(isolate,
4520  "v8::Context::IsCodeGenerationFromStringsAllowed()")) {
4521  return false;
4522  }
4523  ENTER_V8(isolate);
4524  i::Object** ctx = reinterpret_cast<i::Object**>(this);
4525  i::Handle<i::Context> context =
4527  return !context->allow_code_gen_from_strings()->IsFalse();
4528 }
4529 
4530 
4531 void V8::SetWrapperClassId(i::Object** global_handle, uint16_t class_id) {
4532  i::GlobalHandles::SetWrapperClassId(global_handle, class_id);
4533 }
4534 
4535 
4537  i::Isolate* isolate = i::Isolate::Current();
4538  ON_BAILOUT(isolate, "v8::ObjectTemplate::NewInstance()",
4539  return Local<v8::Object>());
4540  LOG_API(isolate, "ObjectTemplate::NewInstance");
4541  ENTER_V8(isolate);
4542  EXCEPTION_PREAMBLE(isolate);
4543  i::Handle<i::Object> obj =
4545  &has_pending_exception);
4548 }
4549 
4550 
4552  i::Isolate* isolate = i::Isolate::Current();
4553  ON_BAILOUT(isolate, "v8::FunctionTemplate::GetFunction()",
4554  return Local<v8::Function>());
4555  LOG_API(isolate, "FunctionTemplate::GetFunction");
4556  ENTER_V8(isolate);
4557  EXCEPTION_PREAMBLE(isolate);
4558  i::Handle<i::Object> obj =
4560  &has_pending_exception);
4563 }
4564 
4565 
4567  ON_BAILOUT(i::Isolate::Current(), "v8::FunctionTemplate::HasInstanceOf()",
4568  return false);
4569  i::Object* obj = *Utils::OpenHandle(*value);
4570  return obj->IsInstanceOf(*Utils::OpenHandle(this));
4571 }
4572 
4573 
4574 static Local<External> ExternalNewImpl(void* data) {
4575  return Utils::ToLocal(FACTORY->NewForeign(static_cast<i::Address>(data)));
4576 }
4577 
4578 static void* ExternalValueImpl(i::Handle<i::Object> obj) {
4579  return reinterpret_cast<void*>(i::Foreign::cast(*obj)->foreign_address());
4580 }
4581 
4582 
4584  i::Isolate* isolate = i::Isolate::Current();
4585  STATIC_ASSERT(sizeof(data) == sizeof(i::Address));
4586  EnsureInitializedForIsolate(isolate, "v8::External::Wrap()");
4587  LOG_API(isolate, "External::Wrap");
4588  ENTER_V8(isolate);
4589 
4590  v8::Local<v8::Value> result = CanBeEncodedAsSmi(data)
4591  ? Utils::ToLocal(i::Handle<i::Object>(EncodeAsSmi(data)))
4592  : v8::Local<v8::Value>(ExternalNewImpl(data));
4593 
4594  ASSERT_EQ(data, Unwrap(result));
4595  return result;
4596 }
4597 
4598 
4599 void* v8::Object::SlowGetPointerFromInternalField(int index) {
4601  i::Object* value = obj->GetInternalField(index);
4602  if (value->IsSmi()) {
4604  } else if (value->IsForeign()) {
4605  return reinterpret_cast<void*>(i::Foreign::cast(value)->foreign_address());
4606  } else {
4607  return NULL;
4608  }
4609 }
4610 
4611 
4612 void* v8::External::FullUnwrap(v8::Handle<v8::Value> wrapper) {
4613  if (IsDeadCheck(i::Isolate::Current(), "v8::External::Unwrap()")) return 0;
4614  i::Handle<i::Object> obj = Utils::OpenHandle(*wrapper);
4615  void* result;
4616  if (obj->IsSmi()) {
4618  } else if (obj->IsForeign()) {
4619  result = ExternalValueImpl(obj);
4620  } else {
4621  result = NULL;
4622  }
4623  ASSERT_EQ(result, QuickUnwrap(wrapper));
4624  return result;
4625 }
4626 
4627 
4629  STATIC_ASSERT(sizeof(data) == sizeof(i::Address));
4630  i::Isolate* isolate = i::Isolate::Current();
4631  EnsureInitializedForIsolate(isolate, "v8::External::New()");
4632  LOG_API(isolate, "External::New");
4633  ENTER_V8(isolate);
4634  return ExternalNewImpl(data);
4635 }
4636 
4637 
4638 void* External::Value() const {
4639  if (IsDeadCheck(i::Isolate::Current(), "v8::External::Value()")) return 0;
4641  return ExternalValueImpl(obj);
4642 }
4643 
4644 
4646  i::Isolate* isolate = i::Isolate::Current();
4647  if (!EnsureInitializedForIsolate(isolate, "v8::String::Empty()")) {
4648  return v8::Local<String>();
4649  }
4650  LOG_API(isolate, "String::Empty()");
4651  return Utils::ToLocal(isolate->factory()->empty_symbol());
4652 }
4653 
4654 
4655 Local<String> v8::String::New(const char* data, int length) {
4656  i::Isolate* isolate = i::Isolate::Current();
4657  EnsureInitializedForIsolate(isolate, "v8::String::New()");
4658  LOG_API(isolate, "String::New(char)");
4659  if (length == 0) return Empty();
4660  ENTER_V8(isolate);
4661  if (length == -1) length = i::StrLength(data);
4662  i::Handle<i::String> result =
4663  isolate->factory()->NewStringFromUtf8(
4664  i::Vector<const char>(data, length));
4665  return Utils::ToLocal(result);
4666 }
4667 
4668 
4670  i::Handle<i::String> left_string = Utils::OpenHandle(*left);
4671  i::Isolate* isolate = left_string->GetIsolate();
4672  EnsureInitializedForIsolate(isolate, "v8::String::New()");
4673  LOG_API(isolate, "String::New(char)");
4674  ENTER_V8(isolate);
4675  i::Handle<i::String> right_string = Utils::OpenHandle(*right);
4676  i::Handle<i::String> result = isolate->factory()->NewConsString(left_string,
4677  right_string);
4678  return Utils::ToLocal(result);
4679 }
4680 
4681 
4682 Local<String> v8::String::NewUndetectable(const char* data, int length) {
4683  i::Isolate* isolate = i::Isolate::Current();
4684  EnsureInitializedForIsolate(isolate, "v8::String::NewUndetectable()");
4685  LOG_API(isolate, "String::NewUndetectable(char)");
4686  ENTER_V8(isolate);
4687  if (length == -1) length = i::StrLength(data);
4688  i::Handle<i::String> result =
4689  isolate->factory()->NewStringFromUtf8(
4690  i::Vector<const char>(data, length));
4691  result->MarkAsUndetectable();
4692  return Utils::ToLocal(result);
4693 }
4694 
4695 
4696 static int TwoByteStringLength(const uint16_t* data) {
4697  int length = 0;
4698  while (data[length] != '\0') length++;
4699  return length;
4700 }
4701 
4702 
4703 Local<String> v8::String::New(const uint16_t* data, int length) {
4704  i::Isolate* isolate = i::Isolate::Current();
4705  EnsureInitializedForIsolate(isolate, "v8::String::New()");
4706  LOG_API(isolate, "String::New(uint16_)");
4707  if (length == 0) return Empty();
4708  ENTER_V8(isolate);
4709  if (length == -1) length = TwoByteStringLength(data);
4710  i::Handle<i::String> result =
4711  isolate->factory()->NewStringFromTwoByte(
4712  i::Vector<const uint16_t>(data, length));
4713  return Utils::ToLocal(result);
4714 }
4715 
4716 
4718  i::Isolate* isolate = i::Isolate::Current();
4719  EnsureInitializedForIsolate(isolate, "v8::String::NewUndetectable()");
4720  LOG_API(isolate, "String::NewUndetectable(uint16_)");
4721  ENTER_V8(isolate);
4722  if (length == -1) length = TwoByteStringLength(data);
4723  i::Handle<i::String> result =
4724  isolate->factory()->NewStringFromTwoByte(
4725  i::Vector<const uint16_t>(data, length));
4726  result->MarkAsUndetectable();
4727  return Utils::ToLocal(result);
4728 }
4729 
4730 
4733  i::Handle<i::String> result =
4734  isolate->factory()->NewExternalStringFromTwoByte(resource);
4735  return result;
4736 }
4737 
4738 
4741  i::Handle<i::String> result =
4742  isolate->factory()->NewExternalStringFromAscii(resource);
4743  return result;
4744 }
4745 
4746 
4749  i::Isolate* isolate = i::Isolate::Current();
4750  EnsureInitializedForIsolate(isolate, "v8::String::NewExternal()");
4751  LOG_API(isolate, "String::NewExternal");
4752  ENTER_V8(isolate);
4753  i::Handle<i::String> result = NewExternalStringHandle(isolate, resource);
4754  isolate->heap()->external_string_table()->AddString(*result);
4755  return Utils::ToLocal(result);
4756 }
4757 
4758 
4761  i::Isolate* isolate = obj->GetIsolate();
4762  if (IsDeadCheck(isolate, "v8::String::MakeExternal()")) return false;
4763  if (i::StringShape(*obj).IsExternalTwoByte()) {
4764  return false; // Already an external string.
4765  }
4766  ENTER_V8(isolate);
4767  if (isolate->string_tracker()->IsFreshUnusedString(obj)) {
4768  return false;
4769  }
4770  if (isolate->heap()->IsInGCPostProcessing()) {
4771  return false;
4772  }
4773  bool result = obj->MakeExternal(resource);
4774  if (result && !obj->IsSymbol()) {
4775  isolate->heap()->external_string_table()->AddString(*obj);
4776  }
4777  return result;
4778 }
4779 
4780 
4783  i::Isolate* isolate = i::Isolate::Current();
4784  EnsureInitializedForIsolate(isolate, "v8::String::NewExternal()");
4785  LOG_API(isolate, "String::NewExternal");
4786  ENTER_V8(isolate);
4787  i::Handle<i::String> result = NewExternalAsciiStringHandle(isolate, resource);
4788  isolate->heap()->external_string_table()->AddString(*result);
4789  return Utils::ToLocal(result);
4790 }
4791 
4792 
4796  i::Isolate* isolate = obj->GetIsolate();
4797  if (IsDeadCheck(isolate, "v8::String::MakeExternal()")) return false;
4798  if (i::StringShape(*obj).IsExternalTwoByte()) {
4799  return false; // Already an external string.
4800  }
4801  ENTER_V8(isolate);
4802  if (isolate->string_tracker()->IsFreshUnusedString(obj)) {
4803  return false;
4804  }
4805  if (isolate->heap()->IsInGCPostProcessing()) {
4806  return false;
4807  }
4808  bool result = obj->MakeExternal(resource);
4809  if (result && !obj->IsSymbol()) {
4810  isolate->heap()->external_string_table()->AddString(*obj);
4811  }
4812  return result;
4813 }
4814 
4815 
4817  if (!internal::FLAG_clever_optimizations) return false;
4819  i::Isolate* isolate = obj->GetIsolate();
4820  if (IsDeadCheck(isolate, "v8::String::CanMakeExternal()")) return false;
4821  if (isolate->string_tracker()->IsFreshUnusedString(obj)) return false;
4822  int size = obj->Size(); // Byte size of the original string.
4823  if (size < i::ExternalString::kShortSize) return false;
4824  i::StringShape shape(*obj);
4825  return !shape.IsExternal();
4826 }
4827 
4828 
4830  i::Isolate* isolate = i::Isolate::Current();
4831  EnsureInitializedForIsolate(isolate, "v8::Object::New()");
4832  LOG_API(isolate, "Object::New");
4833  ENTER_V8(isolate);
4835  isolate->factory()->NewJSObject(isolate->object_function());
4836  return Utils::ToLocal(obj);
4837 }
4838 
4839 
4841  i::Isolate* isolate = i::Isolate::Current();
4842  EnsureInitializedForIsolate(isolate, "v8::NumberObject::New()");
4843  LOG_API(isolate, "NumberObject::New");
4844  ENTER_V8(isolate);
4845  i::Handle<i::Object> number = isolate->factory()->NewNumber(value);
4846  i::Handle<i::Object> obj = isolate->factory()->ToObject(number);
4847  return Utils::ToLocal(obj);
4848 }
4849 
4850 
4852  i::Isolate* isolate = i::Isolate::Current();
4853  if (IsDeadCheck(isolate, "v8::NumberObject::NumberValue()")) return 0;
4854  LOG_API(isolate, "NumberObject::NumberValue");
4857  return jsvalue->value()->Number();
4858 }
4859 
4860 
4862  i::Isolate* isolate = i::Isolate::Current();
4863  EnsureInitializedForIsolate(isolate, "v8::BooleanObject::New()");
4864  LOG_API(isolate, "BooleanObject::New");
4865  ENTER_V8(isolate);
4866  i::Handle<i::Object> boolean(value ? isolate->heap()->true_value()
4867  : isolate->heap()->false_value());
4868  i::Handle<i::Object> obj = isolate->factory()->ToObject(boolean);
4869  return Utils::ToLocal(obj);
4870 }
4871 
4872 
4874  i::Isolate* isolate = i::Isolate::Current();
4875  if (IsDeadCheck(isolate, "v8::BooleanObject::BooleanValue()")) return 0;
4876  LOG_API(isolate, "BooleanObject::BooleanValue");
4879  return jsvalue->value()->IsTrue();
4880 }
4881 
4882 
4884  i::Isolate* isolate = i::Isolate::Current();
4885  EnsureInitializedForIsolate(isolate, "v8::StringObject::New()");
4886  LOG_API(isolate, "StringObject::New");
4887  ENTER_V8(isolate);
4888  i::Handle<i::Object> obj =
4889  isolate->factory()->ToObject(Utils::OpenHandle(*value));
4890  return Utils::ToLocal(obj);
4891 }
4892 
4893 
4895  i::Isolate* isolate = i::Isolate::Current();
4896  if (IsDeadCheck(isolate, "v8::StringObject::StringValue()")) {
4897  return Local<v8::String>();
4898  }
4899  LOG_API(isolate, "StringObject::StringValue");
4902  return Utils::ToLocal(
4903  i::Handle<i::String>(i::String::cast(jsvalue->value())));
4904 }
4905 
4906 
4908  i::Isolate* isolate = i::Isolate::Current();
4909  EnsureInitializedForIsolate(isolate, "v8::Date::New()");
4910  LOG_API(isolate, "Date::New");
4911  if (isnan(time)) {
4912  // Introduce only canonical NaN value into the VM, to avoid signaling NaNs.
4913  time = i::OS::nan_value();
4914  }
4915  ENTER_V8(isolate);
4916  EXCEPTION_PREAMBLE(isolate);
4917  i::Handle<i::Object> obj =
4918  i::Execution::NewDate(time, &has_pending_exception);
4920  return Utils::ToLocal(obj);
4921 }
4922 
4923 
4924 double v8::Date::NumberValue() const {
4925  i::Isolate* isolate = i::Isolate::Current();
4926  if (IsDeadCheck(isolate, "v8::Date::NumberValue()")) return 0;
4927  LOG_API(isolate, "Date::NumberValue");
4930  return jsdate->value()->Number();
4931 }
4932 
4933 
4935  i::Isolate* isolate = i::Isolate::Current();
4936  ON_BAILOUT(isolate, "v8::Date::DateTimeConfigurationChangeNotification()",
4937  return);
4938  LOG_API(isolate, "Date::DateTimeConfigurationChangeNotification");
4939  ENTER_V8(isolate);
4940 
4941  isolate->date_cache()->ResetDateCache();
4942 
4943  i::HandleScope scope(isolate);
4944  // Get the function ResetDateCache (defined in date.js).
4945  i::Handle<i::String> func_name_str =
4946  isolate->factory()->LookupAsciiSymbol("ResetDateCache");
4947  i::MaybeObject* result =
4948  isolate->js_builtins_object()->GetProperty(*func_name_str);
4949  i::Object* object_func;
4950  if (!result->ToObject(&object_func)) {
4951  return;
4952  }
4953 
4954  if (object_func->IsJSFunction()) {
4957 
4958  // Call ResetDateCache(0 but expect no exceptions:
4959  bool caught_exception = false;
4960  i::Execution::TryCall(func,
4961  isolate->js_builtins_object(),
4962  0,
4963  NULL,
4964  &caught_exception);
4965  }
4966 }
4967 
4968 
4969 static i::Handle<i::String> RegExpFlagsToString(RegExp::Flags flags) {
4970  char flags_buf[3];
4971  int num_flags = 0;
4972  if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g';
4973  if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm';
4974  if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i';
4975  ASSERT(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf)));
4976  return FACTORY->LookupSymbol(
4977  i::Vector<const char>(flags_buf, num_flags));
4978 }
4979 
4980 
4982  Flags flags) {
4983  i::Isolate* isolate = Utils::OpenHandle(*pattern)->GetIsolate();
4984  EnsureInitializedForIsolate(isolate, "v8::RegExp::New()");
4985  LOG_API(isolate, "RegExp::New");
4986  ENTER_V8(isolate);
4987  EXCEPTION_PREAMBLE(isolate);
4989  Utils::OpenHandle(*pattern),
4990  RegExpFlagsToString(flags),
4991  &has_pending_exception);
4994 }
4995 
4996 
4998  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4999  if (IsDeadCheck(isolate, "v8::RegExp::GetSource()")) {
5000  return Local<v8::String>();
5001  }
5003  return Utils::ToLocal(i::Handle<i::String>(obj->Pattern()));
5004 }
5005 
5006 
5007 // Assert that the static flags cast in GetFlags is valid.
5008 #define REGEXP_FLAG_ASSERT_EQ(api_flag, internal_flag) \
5009  STATIC_ASSERT(static_cast<int>(v8::RegExp::api_flag) == \
5010  static_cast<int>(i::JSRegExp::internal_flag))
5011 REGEXP_FLAG_ASSERT_EQ(kNone, NONE);
5012 REGEXP_FLAG_ASSERT_EQ(kGlobal, GLOBAL);
5013 REGEXP_FLAG_ASSERT_EQ(kIgnoreCase, IGNORE_CASE);
5014 REGEXP_FLAG_ASSERT_EQ(kMultiline, MULTILINE);
5015 #undef REGEXP_FLAG_ASSERT_EQ
5016 
5018  if (IsDeadCheck(i::Isolate::Current(), "v8::RegExp::GetFlags()")) {
5019  return v8::RegExp::kNone;
5020  }
5022  return static_cast<RegExp::Flags>(obj->GetFlags().value());
5023 }
5024 
5025 
5027  i::Isolate* isolate = i::Isolate::Current();
5028  EnsureInitializedForIsolate(isolate, "v8::Array::New()");
5029  LOG_API(isolate, "Array::New");
5030  ENTER_V8(isolate);
5031  int real_length = length > 0 ? length : 0;
5032  i::Handle<i::JSArray> obj = isolate->factory()->NewJSArray(real_length);
5033  i::Handle<i::Object> length_obj =
5034  isolate->factory()->NewNumberFromInt(real_length);
5035  obj->set_length(*length_obj);
5036  return Utils::ToLocal(obj);
5037 }
5038 
5039 
5040 uint32_t v8::Array::Length() const {
5041  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
5042  if (IsDeadCheck(isolate, "v8::Array::Length()")) return 0;
5044  i::Object* length = obj->length();
5045  if (length->IsSmi()) {
5046  return i::Smi::cast(length)->value();
5047  } else {
5048  return static_cast<uint32_t>(length->Number());
5049  }
5050 }
5051 
5052 
5054  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
5055  ON_BAILOUT(isolate, "v8::Array::CloneElementAt()", return Local<Object>());
5057  if (!self->HasFastObjectElements()) {
5058  return Local<Object>();
5059  }
5060  i::FixedArray* elms = i::FixedArray::cast(self->elements());
5061  i::Object* paragon = elms->get(index);
5062  if (!paragon->IsJSObject()) {
5063  return Local<Object>();
5064  }
5065  i::Handle<i::JSObject> paragon_handle(i::JSObject::cast(paragon));
5066  EXCEPTION_PREAMBLE(isolate);
5067  ENTER_V8(isolate);
5068  i::Handle<i::JSObject> result = i::Copy(paragon_handle);
5069  has_pending_exception = result.is_null();
5071  return Utils::ToLocal(result);
5072 }
5073 
5074 
5075 Local<String> v8::String::NewSymbol(const char* data, int length) {
5076  i::Isolate* isolate = i::Isolate::Current();
5077  EnsureInitializedForIsolate(isolate, "v8::String::NewSymbol()");
5078  LOG_API(isolate, "String::NewSymbol(char)");
5079  ENTER_V8(isolate);
5080  if (length == -1) length = i::StrLength(data);
5081  i::Handle<i::String> result =
5082  isolate->factory()->LookupSymbol(i::Vector<const char>(data, length));
5083  return Utils::ToLocal(result);
5084 }
5085 
5086 
5088  i::Isolate* isolate = i::Isolate::Current();
5089  EnsureInitializedForIsolate(isolate, "v8::Number::New()");
5090  if (isnan(value)) {
5091  // Introduce only canonical NaN value into the VM, to avoid signaling NaNs.
5092  value = i::OS::nan_value();
5093  }
5094  ENTER_V8(isolate);
5095  i::Handle<i::Object> result = isolate->factory()->NewNumber(value);
5096  return Utils::NumberToLocal(result);
5097 }
5098 
5099 
5101  i::Isolate* isolate = i::Isolate::UncheckedCurrent();
5102  EnsureInitializedForIsolate(isolate, "v8::Integer::New()");
5103  if (i::Smi::IsValid(value)) {
5105  isolate));
5106  }
5107  ENTER_V8(isolate);
5108  i::Handle<i::Object> result = isolate->factory()->NewNumber(value);
5109  return Utils::IntegerToLocal(result);
5110 }
5111 
5112 
5114  bool fits_into_int32_t = (value & (1 << 31)) == 0;
5115  if (fits_into_int32_t) {
5116  return Integer::New(static_cast<int32_t>(value));
5117  }
5118  i::Isolate* isolate = i::Isolate::Current();
5119  ENTER_V8(isolate);
5120  i::Handle<i::Object> result = isolate->factory()->NewNumber(value);
5121  return Utils::IntegerToLocal(result);
5122 }
5123 
5124 
5126  EnterIsolateIfNeeded()->set_ignore_out_of_memory(true);
5127 }
5128 
5129 
5131  i::Isolate* isolate = i::Isolate::Current();
5132  EnsureInitializedForIsolate(isolate, "v8::V8::AddMessageListener()");
5133  ON_BAILOUT(isolate, "v8::V8::AddMessageListener()", return false);
5134  ENTER_V8(isolate);
5135  i::HandleScope scope(isolate);
5136  NeanderArray listeners(isolate->factory()->message_listeners());
5137  NeanderObject obj(2);
5138  obj.set(0, *isolate->factory()->NewForeign(FUNCTION_ADDR(that)));
5139  obj.set(1, data.IsEmpty() ?
5140  isolate->heap()->undefined_value() :
5141  *Utils::OpenHandle(*data));
5142  listeners.add(obj.value());
5143  return true;
5144 }
5145 
5146 
5148  i::Isolate* isolate = i::Isolate::Current();
5149  EnsureInitializedForIsolate(isolate, "v8::V8::RemoveMessageListener()");
5150  ON_BAILOUT(isolate, "v8::V8::RemoveMessageListeners()", return);
5151  ENTER_V8(isolate);
5152  i::HandleScope scope(isolate);
5153  NeanderArray listeners(isolate->factory()->message_listeners());
5154  for (int i = 0; i < listeners.length(); i++) {
5155  if (listeners.get(i)->IsUndefined()) continue; // skip deleted ones
5156 
5157  NeanderObject listener(i::JSObject::cast(listeners.get(i)));
5158  i::Handle<i::Foreign> callback_obj(i::Foreign::cast(listener.get(0)));
5159  if (callback_obj->foreign_address() == FUNCTION_ADDR(that)) {
5160  listeners.set(i, isolate->heap()->undefined_value());
5161  }
5162  }
5163 }
5164 
5165 
5167  bool capture,
5168  int frame_limit,
5170  i::Isolate::Current()->SetCaptureStackTraceForUncaughtExceptions(
5171  capture,
5172  frame_limit,
5173  options);
5174 }
5175 
5176 
5178  i::Isolate* isolate = EnterIsolateIfNeeded();
5179  if (IsDeadCheck(isolate, "v8::V8::SetCounterFunction()")) return;
5180  isolate->stats_table()->SetCounterFunction(callback);
5181 }
5182 
5184  i::Isolate* isolate = EnterIsolateIfNeeded();
5185  if (IsDeadCheck(isolate, "v8::V8::SetCreateHistogramFunction()")) return;
5186  isolate->stats_table()->SetCreateHistogramFunction(callback);
5187 }
5188 
5190  i::Isolate* isolate = EnterIsolateIfNeeded();
5191  if (IsDeadCheck(isolate, "v8::V8::SetAddHistogramSampleFunction()")) return;
5192  isolate->stats_table()->
5194 }
5195 
5197  i::Isolate* isolate = i::Isolate::Current();
5198  if (IsDeadCheck(isolate, "v8::V8::EnableSlidingStateWindow()")) return;
5199  isolate->logger()->EnableSlidingStateWindow();
5200 }
5201 
5202 
5204  FailedAccessCheckCallback callback) {
5205  i::Isolate* isolate = i::Isolate::Current();
5206  if (IsDeadCheck(isolate, "v8::V8::SetFailedAccessCheckCallbackFunction()")) {
5207  return;
5208  }
5209  isolate->SetFailedAccessCheckCallback(callback);
5210 }
5211 
5213  size_t length,
5214  RetainedObjectInfo* info) {
5215  i::Isolate* isolate = i::Isolate::Current();
5216  if (IsDeadCheck(isolate, "v8::V8::AddObjectGroup()")) return;
5217  STATIC_ASSERT(sizeof(Persistent<Value>) == sizeof(i::Object**));
5218  isolate->global_handles()->AddObjectGroup(
5219  reinterpret_cast<i::Object***>(objects), length, info);
5220 }
5221 
5222 
5224  Persistent<Value>* children,
5225  size_t length) {
5226  i::Isolate* isolate = i::Isolate::Current();
5227  if (IsDeadCheck(isolate, "v8::V8::AddImplicitReferences()")) return;
5228  STATIC_ASSERT(sizeof(Persistent<Value>) == sizeof(i::Object**));
5231  reinterpret_cast<i::Object***>(children), length);
5232 }
5233 
5234 
5235 intptr_t V8::AdjustAmountOfExternalAllocatedMemory(intptr_t change_in_bytes) {
5236  i::Isolate* isolate = i::Isolate::Current();
5237  if (IsDeadCheck(isolate, "v8::V8::AdjustAmountOfExternalAllocatedMemory()")) {
5238  return 0;
5239  }
5240  return isolate->heap()->AdjustAmountOfExternalAllocatedMemory(
5241  change_in_bytes);
5242 }
5243 
5244 
5246  i::Isolate* isolate = i::Isolate::Current();
5247  if (IsDeadCheck(isolate, "v8::V8::SetGlobalGCPrologueCallback()")) return;
5248  isolate->heap()->SetGlobalGCPrologueCallback(callback);
5249 }
5250 
5251 
5253  i::Isolate* isolate = i::Isolate::Current();
5254  if (IsDeadCheck(isolate, "v8::V8::SetGlobalGCEpilogueCallback()")) return;
5255  isolate->heap()->SetGlobalGCEpilogueCallback(callback);
5256 }
5257 
5258 
5260  i::Isolate* isolate = i::Isolate::Current();
5261  if (IsDeadCheck(isolate, "v8::V8::AddGCPrologueCallback()")) return;
5262  isolate->heap()->AddGCPrologueCallback(callback, gc_type);
5263 }
5264 
5265 
5267  i::Isolate* isolate = i::Isolate::Current();
5268  if (IsDeadCheck(isolate, "v8::V8::RemoveGCPrologueCallback()")) return;
5269  isolate->heap()->RemoveGCPrologueCallback(callback);
5270 }
5271 
5272 
5274  i::Isolate* isolate = i::Isolate::Current();
5275  if (IsDeadCheck(isolate, "v8::V8::AddGCEpilogueCallback()")) return;
5276  isolate->heap()->AddGCEpilogueCallback(callback, gc_type);
5277 }
5278 
5279 
5281  i::Isolate* isolate = i::Isolate::Current();
5282  if (IsDeadCheck(isolate, "v8::V8::RemoveGCEpilogueCallback()")) return;
5283  isolate->heap()->RemoveGCEpilogueCallback(callback);
5284 }
5285 
5286 
5288  ObjectSpace space,
5289  AllocationAction action) {
5290  i::Isolate* isolate = i::Isolate::Current();
5291  if (IsDeadCheck(isolate, "v8::V8::AddMemoryAllocationCallback()")) return;
5293  callback, space, action);
5294 }
5295 
5296 
5298  i::Isolate* isolate = i::Isolate::Current();
5299  if (IsDeadCheck(isolate, "v8::V8::RemoveMemoryAllocationCallback()")) return;
5301  callback);
5302 }
5303 
5304 
5306  if (callback == NULL) return;
5308  i::Isolate* isolate = i::Isolate::Current();
5309  if (IsDeadCheck(isolate, "v8::V8::AddLeaveScriptCallback()")) return;
5311 }
5312 
5313 
5316  i::Isolate* isolate = i::Isolate::Current();
5317  if (IsDeadCheck(isolate, "v8::V8::RemoveLeaveScriptCallback()")) return;
5319 }
5320 
5321 
5323  i::Isolate* isolate = i::Isolate::Current();
5324  isolate->logger()->PauseProfiler();
5325 }
5326 
5327 
5329  i::Isolate* isolate = i::Isolate::Current();
5330  isolate->logger()->ResumeProfiler();
5331 }
5332 
5333 
5335  i::Isolate* isolate = i::Isolate::Current();
5336  return isolate->logger()->IsProfilerPaused();
5337 }
5338 
5339 
5341  i::Isolate* isolate = i::Isolate::Current();
5342  EnsureInitializedForIsolate(isolate, "V8::GetCurrentThreadId()");
5343  return isolate->thread_id().ToInteger();
5344 }
5345 
5346 
5347 void V8::TerminateExecution(int thread_id) {
5348  i::Isolate* isolate = i::Isolate::Current();
5349  if (!isolate->IsInitialized()) return;
5350  API_ENTRY_CHECK(isolate, "V8::TerminateExecution()");
5351  // If the thread_id identifies the current thread just terminate
5352  // execution right away. Otherwise, ask the thread manager to
5353  // terminate the thread with the given id if any.
5354  i::ThreadId internal_tid = i::ThreadId::FromInteger(thread_id);
5355  if (isolate->thread_id().Equals(internal_tid)) {
5356  isolate->stack_guard()->TerminateExecution();
5357  } else {
5358  isolate->thread_manager()->TerminateExecution(internal_tid);
5359  }
5360 }
5361 
5362 
5364  // If no isolate is supplied, use the default isolate.
5365  if (isolate != NULL) {
5366  reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->TerminateExecution();
5367  } else {
5369  }
5370 }
5371 
5372 
5374  i::Isolate* i_isolate = isolate != NULL ?
5375  reinterpret_cast<i::Isolate*>(isolate) : i::Isolate::Current();
5376  return IsExecutionTerminatingCheck(i_isolate);
5377 }
5378 
5379 
5381  i::Isolate* isolate = i::Isolate::UncheckedCurrent();
5382  return reinterpret_cast<Isolate*>(isolate);
5383 }
5384 
5385 
5387  i::Isolate* isolate = new i::Isolate();
5388  return reinterpret_cast<Isolate*>(isolate);
5389 }
5390 
5391 
5393  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
5394  if (!ApiCheck(!isolate->IsInUse(),
5395  "v8::Isolate::Dispose()",
5396  "Disposing the isolate that is entered by a thread.")) {
5397  return;
5398  }
5399  isolate->TearDown();
5400 }
5401 
5402 
5404  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
5405  isolate->Enter();
5406 }
5407 
5408 
5410  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
5411  isolate->Exit();
5412 }
5413 
5414 
5416  : str_(NULL), length_(0) {
5417  i::Isolate* isolate = i::Isolate::Current();
5418  if (IsDeadCheck(isolate, "v8::String::Utf8Value::Utf8Value()")) return;
5419  if (obj.IsEmpty()) return;
5420  ENTER_V8(isolate);
5421  i::HandleScope scope(isolate);
5422  TryCatch try_catch;
5423  Handle<String> str = obj->ToString();
5424  if (str.IsEmpty()) return;
5426  length_ = i::Utf8Length(i_str);
5427  str_ = i::NewArray<char>(length_ + 1);
5428  str->WriteUtf8(str_);
5429 }
5430 
5431 
5433  i::DeleteArray(str_);
5434 }
5435 
5436 
5438  : str_(NULL), length_(0) {
5439  i::Isolate* isolate = i::Isolate::Current();
5440  if (IsDeadCheck(isolate, "v8::String::AsciiValue::AsciiValue()")) return;
5441  if (obj.IsEmpty()) return;
5442  ENTER_V8(isolate);
5443  i::HandleScope scope(isolate);
5444  TryCatch try_catch;
5445  Handle<String> str = obj->ToString();
5446  if (str.IsEmpty()) return;
5447  length_ = str->Length();
5448  str_ = i::NewArray<char>(length_ + 1);
5449  str->WriteAscii(str_);
5450 }
5451 
5452 
5454  i::DeleteArray(str_);
5455 }
5456 
5457 
5459  : str_(NULL), length_(0) {
5460  i::Isolate* isolate = i::Isolate::Current();
5461  if (IsDeadCheck(isolate, "v8::String::Value::Value()")) return;
5462  if (obj.IsEmpty()) return;
5463  ENTER_V8(isolate);
5464  i::HandleScope scope(isolate);
5465  TryCatch try_catch;
5466  Handle<String> str = obj->ToString();
5467  if (str.IsEmpty()) return;
5468  length_ = str->Length();
5469  str_ = i::NewArray<uint16_t>(length_ + 1);
5470  str->Write(str_);
5471 }
5472 
5473 
5475  i::DeleteArray(str_);
5476 }
5477 
5479  i::Isolate* isolate = i::Isolate::Current();
5480  LOG_API(isolate, "RangeError");
5481  ON_BAILOUT(isolate, "v8::Exception::RangeError()", return Local<Value>());
5482  ENTER_V8(isolate);
5483  i::Object* error;
5484  {
5485  i::HandleScope scope(isolate);
5486  i::Handle<i::String> message = Utils::OpenHandle(*raw_message);
5487  i::Handle<i::Object> result = isolate->factory()->NewRangeError(message);
5488  error = *result;
5489  }
5490  i::Handle<i::Object> result(error);
5491  return Utils::ToLocal(result);
5492 }
5493 
5495  i::Isolate* isolate = i::Isolate::Current();
5496  LOG_API(isolate, "ReferenceError");
5497  ON_BAILOUT(isolate, "v8::Exception::ReferenceError()", return Local<Value>());
5498  ENTER_V8(isolate);
5499  i::Object* error;
5500  {
5501  i::HandleScope scope(isolate);
5502  i::Handle<i::String> message = Utils::OpenHandle(*raw_message);
5503  i::Handle<i::Object> result =
5504  isolate->factory()->NewReferenceError(message);
5505  error = *result;
5506  }
5507  i::Handle<i::Object> result(error);
5508  return Utils::ToLocal(result);
5509 }
5510 
5512  i::Isolate* isolate = i::Isolate::Current();
5513  LOG_API(isolate, "SyntaxError");
5514  ON_BAILOUT(isolate, "v8::Exception::SyntaxError()", return Local<Value>());
5515  ENTER_V8(isolate);
5516  i::Object* error;
5517  {
5518  i::HandleScope scope(isolate);
5519  i::Handle<i::String> message = Utils::OpenHandle(*raw_message);
5520  i::Handle<i::Object> result = isolate->factory()->NewSyntaxError(message);
5521  error = *result;
5522  }
5523  i::Handle<i::Object> result(error);
5524  return Utils::ToLocal(result);
5525 }
5526 
5528  i::Isolate* isolate = i::Isolate::Current();
5529  LOG_API(isolate, "TypeError");
5530  ON_BAILOUT(isolate, "v8::Exception::TypeError()", return Local<Value>());
5531  ENTER_V8(isolate);
5532  i::Object* error;
5533  {
5534  i::HandleScope scope(isolate);
5535  i::Handle<i::String> message = Utils::OpenHandle(*raw_message);
5536  i::Handle<i::Object> result = isolate->factory()->NewTypeError(message);
5537  error = *result;
5538  }
5539  i::Handle<i::Object> result(error);
5540  return Utils::ToLocal(result);
5541 }
5542 
5544  i::Isolate* isolate = i::Isolate::Current();
5545  LOG_API(isolate, "Error");
5546  ON_BAILOUT(isolate, "v8::Exception::Error()", return Local<Value>());
5547  ENTER_V8(isolate);
5548  i::Object* error;
5549  {
5550  i::HandleScope scope(isolate);
5551  i::Handle<i::String> message = Utils::OpenHandle(*raw_message);
5552  i::Handle<i::Object> result = isolate->factory()->NewError(message);
5553  error = *result;
5554  }
5555  i::Handle<i::Object> result(error);
5556  return Utils::ToLocal(result);
5557 }
5558 
5559 
5560 // --- D e b u g S u p p o r t ---
5561 
5562 #ifdef ENABLE_DEBUGGER_SUPPORT
5563 
5564 static void EventCallbackWrapper(const v8::Debug::EventDetails& event_details) {
5565  i::Isolate* isolate = i::Isolate::Current();
5566  if (isolate->debug_event_callback() != NULL) {
5567  isolate->debug_event_callback()(event_details.GetEvent(),
5568  event_details.GetExecutionState(),
5569  event_details.GetEventData(),
5570  event_details.GetCallbackData());
5571  }
5572 }
5573 
5574 
5575 bool Debug::SetDebugEventListener(EventCallback that, Handle<Value> data) {
5576  i::Isolate* isolate = i::Isolate::Current();
5577  EnsureInitializedForIsolate(isolate, "v8::Debug::SetDebugEventListener()");
5578  ON_BAILOUT(isolate, "v8::Debug::SetDebugEventListener()", return false);
5579  ENTER_V8(isolate);
5580 
5581  isolate->set_debug_event_callback(that);
5582 
5583  i::HandleScope scope(isolate);
5584  i::Handle<i::Object> foreign = isolate->factory()->undefined_value();
5585  if (that != NULL) {
5586  foreign =
5587  isolate->factory()->NewForeign(FUNCTION_ADDR(EventCallbackWrapper));
5588  }
5589  isolate->debugger()->SetEventListener(foreign, Utils::OpenHandle(*data));
5590  return true;
5591 }
5592 
5593 
5594 bool Debug::SetDebugEventListener2(EventCallback2 that, Handle<Value> data) {
5595  i::Isolate* isolate = i::Isolate::Current();
5596  EnsureInitializedForIsolate(isolate, "v8::Debug::SetDebugEventListener2()");
5597  ON_BAILOUT(isolate, "v8::Debug::SetDebugEventListener2()", return false);
5598  ENTER_V8(isolate);
5599  i::HandleScope scope(isolate);
5600  i::Handle<i::Object> foreign = isolate->factory()->undefined_value();
5601  if (that != NULL) {
5602  foreign = isolate->factory()->NewForeign(FUNCTION_ADDR(that));
5603  }
5604  isolate->debugger()->SetEventListener(foreign, Utils::OpenHandle(*data));
5605  return true;
5606 }
5607 
5608 
5610  Handle<Value> data) {
5611  i::Isolate* isolate = i::Isolate::Current();
5612  ON_BAILOUT(isolate, "v8::Debug::SetDebugEventListener()", return false);
5613  ENTER_V8(isolate);
5614  isolate->debugger()->SetEventListener(Utils::OpenHandle(*that),
5615  Utils::OpenHandle(*data));
5616  return true;
5617 }
5618 
5619 
5620 void Debug::DebugBreak(Isolate* isolate) {
5621  // If no isolate is supplied, use the default isolate.
5622  if (isolate != NULL) {
5623  reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->DebugBreak();
5624  } else {
5626  }
5627 }
5628 
5629 
5630 void Debug::CancelDebugBreak(Isolate* isolate) {
5631  // If no isolate is supplied, use the default isolate.
5632  if (isolate != NULL) {
5633  i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
5634  internal_isolate->stack_guard()->Continue(i::DEBUGBREAK);
5635  } else {
5637  }
5638 }
5639 
5640 
5641 void Debug::DebugBreakForCommand(ClientData* data, Isolate* isolate) {
5642  // If no isolate is supplied, use the default isolate.
5643  if (isolate != NULL) {
5644  i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
5645  internal_isolate->debugger()->EnqueueDebugCommand(data);
5646  } else {
5647  i::Isolate::GetDefaultIsolateDebugger()->EnqueueDebugCommand(data);
5648  }
5649 }
5650 
5651 
5652 static void MessageHandlerWrapper(const v8::Debug::Message& message) {
5653  i::Isolate* isolate = i::Isolate::Current();
5654  if (isolate->message_handler()) {
5655  v8::String::Value json(message.GetJSON());
5656  (isolate->message_handler())(*json, json.length(), message.GetClientData());
5657  }
5658 }
5659 
5660 
5662  bool message_handler_thread) {
5663  i::Isolate* isolate = i::Isolate::Current();
5664  EnsureInitializedForIsolate(isolate, "v8::Debug::SetMessageHandler");
5665  ENTER_V8(isolate);
5666 
5667  // Message handler thread not supported any more. Parameter temporally left in
5668  // the API for client compatibility reasons.
5669  CHECK(!message_handler_thread);
5670 
5671  // TODO(sgjesse) support the old message handler API through a simple wrapper.
5672  isolate->set_message_handler(handler);
5673  if (handler != NULL) {
5674  isolate->debugger()->SetMessageHandler(MessageHandlerWrapper);
5675  } else {
5676  isolate->debugger()->SetMessageHandler(NULL);
5677  }
5678 }
5679 
5680 
5682  i::Isolate* isolate = i::Isolate::Current();
5683  EnsureInitializedForIsolate(isolate, "v8::Debug::SetMessageHandler");
5684  ENTER_V8(isolate);
5685  isolate->debugger()->SetMessageHandler(handler);
5686 }
5687 
5688 
5689 void Debug::SendCommand(const uint16_t* command, int length,
5690  ClientData* client_data,
5691  Isolate* isolate) {
5692  // If no isolate is supplied, use the default isolate.
5693  if (isolate != NULL) {
5694  i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
5695  internal_isolate->debugger()->ProcessCommand(
5696  i::Vector<const uint16_t>(command, length), client_data);
5697  } else {
5698  i::Isolate::GetDefaultIsolateDebugger()->ProcessCommand(
5699  i::Vector<const uint16_t>(command, length), client_data);
5700  }
5701 }
5702 
5703 
5704 void Debug::SetHostDispatchHandler(HostDispatchHandler handler,
5705  int period) {
5706  i::Isolate* isolate = i::Isolate::Current();
5707  EnsureInitializedForIsolate(isolate, "v8::Debug::SetHostDispatchHandler");
5708  ENTER_V8(isolate);
5709  isolate->debugger()->SetHostDispatchHandler(handler, period);
5710 }
5711 
5712 
5714  DebugMessageDispatchHandler handler, bool provide_locker) {
5715  i::Isolate* isolate = i::Isolate::Current();
5716  EnsureInitializedForIsolate(isolate,
5717  "v8::Debug::SetDebugMessageDispatchHandler");
5718  ENTER_V8(isolate);
5719  isolate->debugger()->SetDebugMessageDispatchHandler(
5720  handler, provide_locker);
5721 }
5722 
5723 
5724 Local<Value> Debug::Call(v8::Handle<v8::Function> fun,
5725  v8::Handle<v8::Value> data) {
5726  i::Isolate* isolate = i::Isolate::Current();
5727  if (!isolate->IsInitialized()) return Local<Value>();
5728  ON_BAILOUT(isolate, "v8::Debug::Call()", return Local<Value>());
5729  ENTER_V8(isolate);
5730  i::Handle<i::Object> result;
5731  EXCEPTION_PREAMBLE(isolate);
5732  if (data.IsEmpty()) {
5733  result = isolate->debugger()->Call(Utils::OpenHandle(*fun),
5734  isolate->factory()->undefined_value(),
5735  &has_pending_exception);
5736  } else {
5737  result = isolate->debugger()->Call(Utils::OpenHandle(*fun),
5738  Utils::OpenHandle(*data),
5739  &has_pending_exception);
5740  }
5741  EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
5742  return Utils::ToLocal(result);
5743 }
5744 
5745 
5746 Local<Value> Debug::GetMirror(v8::Handle<v8::Value> obj) {
5747  i::Isolate* isolate = i::Isolate::Current();
5748  if (!isolate->IsInitialized()) return Local<Value>();
5749  ON_BAILOUT(isolate, "v8::Debug::GetMirror()", return Local<Value>());
5750  ENTER_V8(isolate);
5751  v8::HandleScope scope;
5752  i::Debug* isolate_debug = isolate->debug();
5753  isolate_debug->Load();
5754  i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global());
5755  i::Handle<i::String> name =
5756  isolate->factory()->LookupAsciiSymbol("MakeMirror");
5757  i::Handle<i::Object> fun_obj = i::GetProperty(debug, name);
5760  const int kArgc = 1;
5761  v8::Handle<v8::Value> argv[kArgc] = { obj };
5762  EXCEPTION_PREAMBLE(isolate);
5763  v8::Handle<v8::Value> result = v8_fun->Call(Utils::ToLocal(debug),
5764  kArgc,
5765  argv);
5766  EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
5767  return scope.Close(result);
5768 }
5769 
5770 
5771 bool Debug::EnableAgent(const char* name, int port, bool wait_for_connection) {
5772  return i::Isolate::Current()->debugger()->StartAgent(name, port,
5773  wait_for_connection);
5774 }
5775 
5776 
5777 void Debug::DisableAgent() {
5778  return i::Isolate::Current()->debugger()->StopAgent();
5779 }
5780 
5781 
5783  i::Execution::ProcessDebugMessages(true);
5784 }
5785 
5786 Local<Context> Debug::GetDebugContext() {
5787  i::Isolate* isolate = i::Isolate::Current();
5788  EnsureInitializedForIsolate(isolate, "v8::Debug::GetDebugContext()");
5789  ENTER_V8(isolate);
5790  return Utils::ToLocal(i::Isolate::Current()->debugger()->GetDebugContext());
5791 }
5792 
5793 #endif // ENABLE_DEBUGGER_SUPPORT
5794 
5795 
5797  i::Isolate* isolate = i::Isolate::Current();
5798  IsDeadCheck(isolate, "v8::CpuProfileNode::GetFunctionName");
5799  const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
5800  const i::CodeEntry* entry = node->entry();
5801  if (!entry->has_name_prefix()) {
5802  return Handle<String>(ToApi<String>(
5803  isolate->factory()->LookupAsciiSymbol(entry->name())));
5804  } else {
5805  return Handle<String>(ToApi<String>(isolate->factory()->NewConsString(
5806  isolate->factory()->LookupAsciiSymbol(entry->name_prefix()),
5807  isolate->factory()->LookupAsciiSymbol(entry->name()))));
5808  }
5809 }
5810 
5811 
5813  i::Isolate* isolate = i::Isolate::Current();
5814  IsDeadCheck(isolate, "v8::CpuProfileNode::GetScriptResourceName");
5815  const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
5816  return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol(
5817  node->entry()->resource_name())));
5818 }
5819 
5820 
5822  i::Isolate* isolate = i::Isolate::Current();
5823  IsDeadCheck(isolate, "v8::CpuProfileNode::GetLineNumber");
5824  return reinterpret_cast<const i::ProfileNode*>(this)->entry()->line_number();
5825 }
5826 
5827 
5829  i::Isolate* isolate = i::Isolate::Current();
5830  IsDeadCheck(isolate, "v8::CpuProfileNode::GetTotalTime");
5831  return reinterpret_cast<const i::ProfileNode*>(this)->GetTotalMillis();
5832 }
5833 
5834 
5836  i::Isolate* isolate = i::Isolate::Current();
5837  IsDeadCheck(isolate, "v8::CpuProfileNode::GetSelfTime");
5838  return reinterpret_cast<const i::ProfileNode*>(this)->GetSelfMillis();
5839 }
5840 
5841 
5843  i::Isolate* isolate = i::Isolate::Current();
5844  IsDeadCheck(isolate, "v8::CpuProfileNode::GetTotalSamplesCount");
5845  return reinterpret_cast<const i::ProfileNode*>(this)->total_ticks();
5846 }
5847 
5848 
5850  i::Isolate* isolate = i::Isolate::Current();
5851  IsDeadCheck(isolate, "v8::CpuProfileNode::GetSelfSamplesCount");
5852  return reinterpret_cast<const i::ProfileNode*>(this)->self_ticks();
5853 }
5854 
5855 
5856 unsigned CpuProfileNode::GetCallUid() const {
5857  i::Isolate* isolate = i::Isolate::Current();
5858  IsDeadCheck(isolate, "v8::CpuProfileNode::GetCallUid");
5859  return reinterpret_cast<const i::ProfileNode*>(this)->entry()->GetCallUid();
5860 }
5861 
5862 
5864  i::Isolate* isolate = i::Isolate::Current();
5865  IsDeadCheck(isolate, "v8::CpuProfileNode::GetChildrenCount");
5866  return reinterpret_cast<const i::ProfileNode*>(this)->children()->length();
5867 }
5868 
5869 
5870 const CpuProfileNode* CpuProfileNode::GetChild(int index) const {
5871  i::Isolate* isolate = i::Isolate::Current();
5872  IsDeadCheck(isolate, "v8::CpuProfileNode::GetChild");
5873  const i::ProfileNode* child =
5874  reinterpret_cast<const i::ProfileNode*>(this)->children()->at(index);
5875  return reinterpret_cast<const CpuProfileNode*>(child);
5876 }
5877 
5878 
5880  i::Isolate* isolate = i::Isolate::Current();
5881  IsDeadCheck(isolate, "v8::CpuProfile::Delete");
5882  i::CpuProfiler::DeleteProfile(reinterpret_cast<i::CpuProfile*>(this));
5883  if (i::CpuProfiler::GetProfilesCount() == 0 &&
5885  // If this was the last profile, clean up all accessory data as well.
5887  }
5888 }
5889 
5890 
5891 unsigned CpuProfile::GetUid() const {
5892  i::Isolate* isolate = i::Isolate::Current();
5893  IsDeadCheck(isolate, "v8::CpuProfile::GetUid");
5894  return reinterpret_cast<const i::CpuProfile*>(this)->uid();
5895 }
5896 
5897 
5899  i::Isolate* isolate = i::Isolate::Current();
5900  IsDeadCheck(isolate, "v8::CpuProfile::GetTitle");
5901  const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
5902  return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol(
5903  profile->title())));
5904 }
5905 
5906 
5908  i::Isolate* isolate = i::Isolate::Current();
5909  IsDeadCheck(isolate, "v8::CpuProfile::GetBottomUpRoot");
5910  const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
5911  return reinterpret_cast<const CpuProfileNode*>(profile->bottom_up()->root());
5912 }
5913 
5914 
5916  i::Isolate* isolate = i::Isolate::Current();
5917  IsDeadCheck(isolate, "v8::CpuProfile::GetTopDownRoot");
5918  const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
5919  return reinterpret_cast<const CpuProfileNode*>(profile->top_down()->root());
5920 }
5921 
5922 
5924  i::Isolate* isolate = i::Isolate::Current();
5925  IsDeadCheck(isolate, "v8::CpuProfiler::GetProfilesCount");
5927 }
5928 
5929 
5931  Handle<Value> security_token) {
5932  i::Isolate* isolate = i::Isolate::Current();
5933  IsDeadCheck(isolate, "v8::CpuProfiler::GetProfile");
5934  return reinterpret_cast<const CpuProfile*>(
5936  security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
5937  index));
5938 }
5939 
5940 
5942  Handle<Value> security_token) {
5943  i::Isolate* isolate = i::Isolate::Current();
5944  IsDeadCheck(isolate, "v8::CpuProfiler::FindProfile");
5945  return reinterpret_cast<const CpuProfile*>(
5947  security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
5948  uid));
5949 }
5950 
5951 
5953  i::Isolate* isolate = i::Isolate::Current();
5954  IsDeadCheck(isolate, "v8::CpuProfiler::StartProfiling");
5956 }
5957 
5958 
5960  Handle<Value> security_token) {
5961  i::Isolate* isolate = i::Isolate::Current();
5962  IsDeadCheck(isolate, "v8::CpuProfiler::StopProfiling");
5963  return reinterpret_cast<const CpuProfile*>(
5965  security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
5966  *Utils::OpenHandle(*title)));
5967 }
5968 
5969 
5971  i::Isolate* isolate = i::Isolate::Current();
5972  IsDeadCheck(isolate, "v8::CpuProfiler::DeleteAllProfiles");
5974 }
5975 
5976 
5977 static i::HeapGraphEdge* ToInternal(const HeapGraphEdge* edge) {
5978  return const_cast<i::HeapGraphEdge*>(
5979  reinterpret_cast<const i::HeapGraphEdge*>(edge));
5980 }
5981 
5982 
5984  i::Isolate* isolate = i::Isolate::Current();
5985  IsDeadCheck(isolate, "v8::HeapGraphEdge::GetType");
5986  return static_cast<HeapGraphEdge::Type>(ToInternal(this)->type());
5987 }
5988 
5989 
5991  i::Isolate* isolate = i::Isolate::Current();
5992  IsDeadCheck(isolate, "v8::HeapGraphEdge::GetName");
5993  i::HeapGraphEdge* edge = ToInternal(this);
5994  switch (edge->type()) {
5995  case i::HeapGraphEdge::kContextVariable:
5996  case i::HeapGraphEdge::kInternal:
5997  case i::HeapGraphEdge::kProperty:
5998  case i::HeapGraphEdge::kShortcut:
5999  return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol(
6000  edge->name())));
6001  case i::HeapGraphEdge::kElement:
6002  case i::HeapGraphEdge::kHidden:
6003  return Handle<Number>(ToApi<Number>(isolate->factory()->NewNumberFromInt(
6004  edge->index())));
6005  default: UNREACHABLE();
6006  }
6007  return v8::Undefined();
6008 }
6009 
6010 
6012  i::Isolate* isolate = i::Isolate::Current();
6013  IsDeadCheck(isolate, "v8::HeapGraphEdge::GetFromNode");
6014  const i::HeapEntry* from = ToInternal(this)->from();
6015  return reinterpret_cast<const HeapGraphNode*>(from);
6016 }
6017 
6018 
6020  i::Isolate* isolate = i::Isolate::Current();
6021  IsDeadCheck(isolate, "v8::HeapGraphEdge::GetToNode");
6022  const i::HeapEntry* to = ToInternal(this)->to();
6023  return reinterpret_cast<const HeapGraphNode*>(to);
6024 }
6025 
6026 
6027 static i::HeapEntry* ToInternal(const HeapGraphNode* entry) {
6028  return const_cast<i::HeapEntry*>(
6029  reinterpret_cast<const i::HeapEntry*>(entry));
6030 }
6031 
6032 
6034  i::Isolate* isolate = i::Isolate::Current();
6035  IsDeadCheck(isolate, "v8::HeapGraphNode::GetType");
6036  return static_cast<HeapGraphNode::Type>(ToInternal(this)->type());
6037 }
6038 
6039 
6041  i::Isolate* isolate = i::Isolate::Current();
6042  IsDeadCheck(isolate, "v8::HeapGraphNode::GetName");
6043  return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol(
6044  ToInternal(this)->name())));
6045 }
6046 
6047 
6049  i::Isolate* isolate = i::Isolate::Current();
6050  IsDeadCheck(isolate, "v8::HeapGraphNode::GetId");
6051  return ToInternal(this)->id();
6052 }
6053 
6054 
6056  i::Isolate* isolate = i::Isolate::Current();
6057  IsDeadCheck(isolate, "v8::HeapGraphNode::GetSelfSize");
6058  return ToInternal(this)->self_size();
6059 }
6060 
6061 
6063  i::Isolate* isolate = i::Isolate::Current();
6064  IsDeadCheck(isolate, "v8::HeapSnapshot::GetChildrenCount");
6065  return ToInternal(this)->children().length();
6066 }
6067 
6068 
6069 const HeapGraphEdge* HeapGraphNode::GetChild(int index) const {
6070  i::Isolate* isolate = i::Isolate::Current();
6071  IsDeadCheck(isolate, "v8::HeapSnapshot::GetChild");
6072  return reinterpret_cast<const HeapGraphEdge*>(
6073  ToInternal(this)->children()[index]);
6074 }
6075 
6076 
6078  i::Isolate* isolate = i::Isolate::Current();
6079  IsDeadCheck(isolate, "v8::HeapGraphNode::GetHeapValue");
6080  i::Handle<i::HeapObject> object = ToInternal(this)->GetHeapObject();
6081  return v8::Handle<Value>(!object.is_null() ?
6082  ToApi<Value>(object) : ToApi<Value>(
6083  isolate->factory()->undefined_value()));
6084 }
6085 
6086 
6087 static i::HeapSnapshot* ToInternal(const HeapSnapshot* snapshot) {
6088  return const_cast<i::HeapSnapshot*>(
6089  reinterpret_cast<const i::HeapSnapshot*>(snapshot));
6090 }
6091 
6092 
6094  i::Isolate* isolate = i::Isolate::Current();
6095  IsDeadCheck(isolate, "v8::HeapSnapshot::Delete");
6097  ToInternal(this)->Delete();
6098  } else {
6099  // If this is the last snapshot, clean up all accessory data as well.
6101  }
6102 }
6103 
6104 
6106  i::Isolate* isolate = i::Isolate::Current();
6107  IsDeadCheck(isolate, "v8::HeapSnapshot::GetType");
6108  return static_cast<HeapSnapshot::Type>(ToInternal(this)->type());
6109 }
6110 
6111 
6112 unsigned HeapSnapshot::GetUid() const {
6113  i::Isolate* isolate = i::Isolate::Current();
6114  IsDeadCheck(isolate, "v8::HeapSnapshot::GetUid");
6115  return ToInternal(this)->uid();
6116 }
6117 
6118 
6120  i::Isolate* isolate = i::Isolate::Current();
6121  IsDeadCheck(isolate, "v8::HeapSnapshot::GetTitle");
6122  return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol(
6123  ToInternal(this)->title())));
6124 }
6125 
6126 
6128  i::Isolate* isolate = i::Isolate::Current();
6129  IsDeadCheck(isolate, "v8::HeapSnapshot::GetHead");
6130  return reinterpret_cast<const HeapGraphNode*>(ToInternal(this)->root());
6131 }
6132 
6133 
6135  i::Isolate* isolate = i::Isolate::Current();
6136  IsDeadCheck(isolate, "v8::HeapSnapshot::GetNodeById");
6137  return reinterpret_cast<const HeapGraphNode*>(
6138  ToInternal(this)->GetEntryById(id));
6139 }
6140 
6141 
6143  i::Isolate* isolate = i::Isolate::Current();
6144  IsDeadCheck(isolate, "v8::HeapSnapshot::GetNodesCount");
6145  return ToInternal(this)->entries().length();
6146 }
6147 
6148 
6149 const HeapGraphNode* HeapSnapshot::GetNode(int index) const {
6150  i::Isolate* isolate = i::Isolate::Current();
6151  IsDeadCheck(isolate, "v8::HeapSnapshot::GetNode");
6152  return reinterpret_cast<const HeapGraphNode*>(
6153  &ToInternal(this)->entries().at(index));
6154 }
6155 
6156 
6158  i::Isolate* isolate = i::Isolate::Current();
6159  IsDeadCheck(isolate, "v8::HeapSnapshot::GetMaxSnapshotJSObjectId");
6160  return ToInternal(this)->max_snapshot_js_object_id();
6161 }
6162 
6163 
6165  HeapSnapshot::SerializationFormat format) const {
6166  i::Isolate* isolate = i::Isolate::Current();
6167  IsDeadCheck(isolate, "v8::HeapSnapshot::Serialize");
6168  ApiCheck(format == kJSON,
6169  "v8::HeapSnapshot::Serialize",
6170  "Unknown serialization format");
6171  ApiCheck(stream->GetOutputEncoding() == OutputStream::kAscii,
6172  "v8::HeapSnapshot::Serialize",
6173  "Unsupported output encoding");
6174  ApiCheck(stream->GetChunkSize() > 0,
6175  "v8::HeapSnapshot::Serialize",
6176  "Invalid stream chunk size");
6177  i::HeapSnapshotJSONSerializer serializer(ToInternal(this));
6178  serializer.Serialize(stream);
6179 }
6180 
6181 
6183  i::Isolate* isolate = i::Isolate::Current();
6184  IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshotsCount");
6186 }
6187 
6188 
6190  i::Isolate* isolate = i::Isolate::Current();
6191  IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshot");
6192  return reinterpret_cast<const HeapSnapshot*>(
6194 }
6195 
6196 
6198  i::Isolate* isolate = i::Isolate::Current();
6199  IsDeadCheck(isolate, "v8::HeapProfiler::FindSnapshot");
6200  return reinterpret_cast<const HeapSnapshot*>(
6202 }
6203 
6204 
6206  i::Isolate* isolate = i::Isolate::Current();
6207  IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshotObjectId");
6210 }
6211 
6212 
6214  HeapSnapshot::Type type,
6215  ActivityControl* control) {
6216  i::Isolate* isolate = i::Isolate::Current();
6217  IsDeadCheck(isolate, "v8::HeapProfiler::TakeSnapshot");
6219  switch (type) {
6220  case HeapSnapshot::kFull:
6221  internal_type = i::HeapSnapshot::kFull;
6222  break;
6223  default:
6224  UNREACHABLE();
6225  }
6226  return reinterpret_cast<const HeapSnapshot*>(
6228  *Utils::OpenHandle(*title), internal_type, control));
6229 }
6230 
6231 
6233  i::Isolate* isolate = i::Isolate::Current();
6234  IsDeadCheck(isolate, "v8::HeapProfiler::StartHeapObjectsTracking");
6236 }
6237 
6238 
6240  i::Isolate* isolate = i::Isolate::Current();
6241  IsDeadCheck(isolate, "v8::HeapProfiler::StopHeapObjectsTracking");
6243 }
6244 
6245 
6247  i::Isolate* isolate = i::Isolate::Current();
6248  IsDeadCheck(isolate, "v8::HeapProfiler::PushHeapObjectsStats");
6250 }
6251 
6252 
6254  i::Isolate* isolate = i::Isolate::Current();
6255  IsDeadCheck(isolate, "v8::HeapProfiler::DeleteAllSnapshots");
6257 }
6258 
6259 
6261  WrapperInfoCallback callback) {
6262  i::Isolate::Current()->heap_profiler()->DefineWrapperClass(class_id,
6263  callback);
6264 }
6265 
6266 
6268  i::Isolate* isolate = i::Isolate::Current();
6269  return isolate->global_handles()->NumberOfGlobalHandles();
6270 }
6271 
6272 
6275 }
6276 
6277 
6278 v8::Testing::StressType internal::Testing::stress_type_ =
6280 
6281 
6284 }
6285 
6287  if (internal::FLAG_stress_runs != 0) return internal::FLAG_stress_runs;
6288 #ifdef DEBUG
6289  // In debug mode the code runs much slower so stressing will only make two
6290  // runs.
6291  return 2;
6292 #else
6293  return 5;
6294 #endif
6295 }
6296 
6297 
6298 static void SetFlagsFromString(const char* flags) {
6299  V8::SetFlagsFromString(flags, i::StrLength(flags));
6300 }
6301 
6302 
6304  static const char* kLazyOptimizations =
6305  "--prepare-always-opt "
6306  "--max-inlined-source-size=999999 "
6307  "--max-inlined-nodes=999999 "
6308  "--max-inlined-nodes-cumulative=999999 "
6309  "--noalways-opt";
6310  static const char* kForcedOptimizations = "--always-opt";
6311 
6312  // If deoptimization stressed turn on frequent deoptimization. If no value
6313  // is spefified through --deopt-every-n-times use a default default value.
6314  static const char* kDeoptEvery13Times = "--deopt-every-n-times=13";
6316  internal::FLAG_deopt_every_n_times == 0) {
6317  SetFlagsFromString(kDeoptEvery13Times);
6318  }
6319 
6320 #ifdef DEBUG
6321  // As stressing in debug mode only make two runs skip the deopt stressing
6322  // here.
6323  if (run == GetStressRuns() - 1) {
6324  SetFlagsFromString(kForcedOptimizations);
6325  } else {
6326  SetFlagsFromString(kLazyOptimizations);
6327  }
6328 #else
6329  if (run == GetStressRuns() - 1) {
6330  SetFlagsFromString(kForcedOptimizations);
6331  } else if (run != GetStressRuns() - 2) {
6332  SetFlagsFromString(kLazyOptimizations);
6333  }
6334 #endif
6335 }
6336 
6337 
6340 }
6341 
6342 
6343 namespace internal {
6344 
6345 
6346 void HandleScopeImplementer::FreeThreadResources() {
6347  Free();
6348 }
6349 
6350 
6351 char* HandleScopeImplementer::ArchiveThread(char* storage) {
6353  isolate_->handle_scope_data();
6354  handle_scope_data_ = *current;
6355  memcpy(storage, this, sizeof(*this));
6356 
6357  ResetAfterArchive();
6358  current->Initialize();
6359 
6360  return storage + ArchiveSpacePerThread();
6361 }
6362 
6363 
6364 int HandleScopeImplementer::ArchiveSpacePerThread() {
6365  return sizeof(HandleScopeImplementer);
6366 }
6367 
6368 
6369 char* HandleScopeImplementer::RestoreThread(char* storage) {
6370  memcpy(this, storage, sizeof(*this));
6371  *isolate_->handle_scope_data() = handle_scope_data_;
6372  return storage + ArchiveSpacePerThread();
6373 }
6374 
6375 
6376 void HandleScopeImplementer::IterateThis(ObjectVisitor* v) {
6377  // Iterate over all handles in the blocks except for the last.
6378  for (int i = blocks()->length() - 2; i >= 0; --i) {
6379  Object** block = blocks()->at(i);
6380  v->VisitPointers(block, &block[kHandleBlockSize]);
6381  }
6382 
6383  // Iterate over live handles in the last block (if any).
6384  if (!blocks()->is_empty()) {
6385  v->VisitPointers(blocks()->last(), handle_scope_data_.next);
6386  }
6387 
6388  if (!saved_contexts_.is_empty()) {
6389  Object** start = reinterpret_cast<Object**>(&saved_contexts_.first());
6390  v->VisitPointers(start, start + saved_contexts_.length());
6391  }
6392 }
6393 
6394 
6395 void HandleScopeImplementer::Iterate(ObjectVisitor* v) {
6397  isolate_->handle_scope_data();
6398  handle_scope_data_ = *current;
6399  IterateThis(v);
6400 }
6401 
6402 
6403 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
6404  HandleScopeImplementer* scope_implementer =
6405  reinterpret_cast<HandleScopeImplementer*>(storage);
6406  scope_implementer->IterateThis(v);
6407  return storage + ArchiveSpacePerThread();
6408 }
6409 
6410 } } // namespace v8::internal
void API_Fatal(const char *location, const char *format,...)
Definition: checks.cc:92
void Enter()
Definition: api.cc:731
Object * GetPrototype()
Definition: objects.cc:709
byte * Address
Definition: globals.h:172
static Local< Context > GetCurrent()
Definition: api.cc:4442
static CpuProfile * FindProfile(Object *security_token, unsigned uid)
void SaveContext(Context *context)
Definition: api.h:494
int Utf8Length(Handle< String > str)
Definition: handles.cc:947
static Isolate * GetCurrent()
Definition: api.cc:5380
void SetCallAsFunctionHandler(InvocationCallback callback, Handle< Value > data=Handle< Value >())
Definition: api.cc:1405
void PauseProfiler()
Definition: log.cc:1276
static void DeleteAllSnapshots()
Definition: api.cc:6253
static void set_stress_type(v8::Testing::StressType stress_type)
Definition: api.h:565
static Handle< Object > New(Handle< JSFunction > func, int argc, Handle< Object > argv[], bool *pending_exception)
Definition: execution.cc:177
Handle< Array >(* NamedPropertyEnumerator)(const AccessorInfo &info)
Definition: v8.h:2056
Handle< Value > GetScriptData() const
Definition: api.cc:1802
static void DeleteProfile(CpuProfile *profile)
static Handle< Object > DeleteElement(Handle< JSObject > obj, uint32_t index)
Definition: objects.cc:3791
RegisteredExtension * next()
Definition: api.h:151
double GetSelfTime() const
Definition: api.cc:5835
V8EXPORT int Length() const
Definition: api.cc:3718
V8EXPORT double NumberValue() const
Definition: api.cc:2547
static bool Initialize(Deserializer *des)
Definition: v8.cc:64
void(* GCCallback)()
Definition: v8.h:2732
const HeapGraphEdge * GetChild(int index) const
Definition: api.cc:6069
static const byte * data()
Definition: snapshot.h:53
void Destroy(Object **location)
static Local< Script > Compile(Handle< String > source, ScriptOrigin *origin=NULL, ScriptData *pre_data=NULL, Handle< String > script_data=Handle< String >())
Definition: api.cc:1560
int GetLineNumber() const
Definition: api.cc:2013
void FlattenString(Handle< String > string)
Definition: handles.cc:211
bool IsEval() const
Definition: api.cc:2093
static void AddGCEpilogueCallback(GCEpilogueCallback callback, GCType gc_type_filter=kGCTypeAll)
Definition: api.cc:5273
V8EXPORT int WriteUtf8(char *buffer, int length=-1, int *nchars_ref=NULL, int options=NO_OPTIONS) const
Definition: api.cc:3829
static int NumberOfHandles()
Definition: handles.cc:48
static void SetAllowCodeGenerationFromStringsCallback(AllowCodeGenerationFromStringsCallback that)
Definition: api.cc:460
V8EXPORT bool HasRealIndexedProperty(uint32_t index)
Definition: api.cc:3125
static ScriptDataImpl * PreParse(Utf16CharacterStream *source, v8::Extension *extension, int flags)
Definition: parser.cc:5992
void(* MemoryAllocationCallback)(ObjectSpace space, AllocationAction action, int size)
Definition: v8.h:2689
static HeapSnapshot * GetSnapshot(int index)
Handle< JSObject > NewJSObject(Handle< JSFunction > constructor, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:973
DateCache * date_cache()
Definition: isolate.h:1038
Handle< String > NewExternalStringFromAscii(const ExternalAsciiString::Resource *resource)
Definition: factory.cc:270
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping true
V8EXPORT bool BooleanValue() const
Definition: api.cc:4873
#define CHECK_EQ(expected, value)
Definition: checks.h:219
V8EXPORT bool IsTrue() const
Definition: api.cc:2135
Local< Array > AsArray()
Definition: api.cc:1990
V8EXPORT uint8_t * GetIndexedPropertiesPixelData()
Definition: api.cc:3412
static bool IsExecutionTerminating(Isolate *isolate=NULL)
Definition: api.cc:5373
static const int kMaxLength
Definition: objects.h:3717
const char * data
Definition: v8.h:2869
Handle< JSFunction > NewFunctionFromSharedFunctionInfo(Handle< SharedFunctionInfo > function_info, Handle< Context > context, PretenureFlag pretenure=TENURED)
Definition: factory.cc:541
static Local< FunctionTemplate > New(InvocationCallback callback=0, Handle< Value > data=Handle< Value >(), Handle< Signature > signature=Handle< Signature >())
Definition: api.cc:943
static Handle< Object > TryCall(Handle< JSFunction > func, Handle< Object > receiver, int argc, Handle< Object > argv[], bool *caught_exception)
Definition: execution.cc:186
V8EXPORT bool DeleteHiddenValue(Handle< String > key)
Definition: api.cc:3314
void Dispose()
Definition: api.cc:5392
Handle< Boolean > V8EXPORT True()
Definition: api.cc:566
V8EXPORT Local< String > GetSource() const
Definition: api.cc:4997
V8EXPORT const ExternalAsciiStringResource * GetExternalAsciiStringResource() const
Definition: api.cc:4058
static SnapshotObjectId PushHeapObjectsStats(OutputStream *stream)
static int GetStressRuns()
Definition: api.cc:6286
void(* CallCompletedCallback)()
Definition: v8.h:2694
static const HeapSnapshot * TakeSnapshot(Handle< String > title, HeapSnapshot::Type type=HeapSnapshot::kFull, ActivityControl *control=NULL)
Definition: api.cc:6213
Handle< Value >(* NamedPropertySetter)(Local< String > property, Local< Value > value, const AccessorInfo &info)
Definition: v8.h:2031
void RecordWrite(Handle< String > string)
Definition: api.h:338
static Handle< Object > ToUint32(Handle< Object > obj, bool *exc)
Definition: execution.cc:635
intptr_t * old_pointer_space_size
Definition: heap.h:2071
void Exit()
Definition: api.cc:5409
intptr_t * cell_space_size
Definition: heap.h:2079
const HeapGraphNode * GetFromNode() const
Definition: api.cc:6011
void SetSecurityToken(Handle< Value > token)
Definition: api.cc:4382
Extension(const char *name, const char *source=0, int dep_count=0, const char **deps=0, int source_length=-1)
Definition: api.cc:531
Local< Value > Exception() const
Definition: api.cc:1712
static String * cast(Object *obj)
void ScheduleThrow(Object *exception)
Definition: isolate.cc:944
int * new_space_capacity
Definition: heap.h:2070
const int kPointerToSmiShift
Definition: v8.h:3903
HandleScopeImplementer * handle_scope_implementer()
Definition: isolate.h:849
Definition: v8.h:2934
v8::internal::Handle< v8::internal::JSObject > value()
Definition: api.h:77
void set(int index, v8::internal::Object *value)
Definition: api.cc:880
V8EXPORT Local< Object > CloneElementAt(uint32_t index)
Definition: api.cc:5053
Definition: v8.h:863
static Local< Number > NumberToLocal(v8::internal::Handle< v8::internal::Object > obj)
V8EXPORT bool StrictEquals(Handle< Value > that) const
Definition: api.cc:2703
static void SetAddHistogramSampleFunction(AddHistogramSampleCallback)
Definition: api.cc:5189
bool HasOutOfMemoryException()
Definition: api.cc:4418
V8EXPORT Local< Value > Get(Handle< Value > key)
Definition: api.cc:2845
static Smi * FromInt(int value)
Definition: objects-inl.h:973
Handle< Integer > ResourceLineOffset() const
Definition: v8.h:4160
V8EXPORT bool IsNativeError() const
Definition: api.cc:2271
virtual Handle< Object > GetEventData() const =0
void V8EXPORT RegisterExtension(Extension *extension)
Definition: api.cc:525
Local< Object > NewInstance()
Definition: api.cc:4536
V8EXPORT PropertyAttribute GetPropertyAttributes(Handle< Value > key)
Definition: api.cc:2872
~HandleScope()
Definition: api.cc:687
bool HasCaught() const
Definition: api.cc:1695
double GetTotalTime() const
Definition: api.cc:5828
V8EXPORT Local< Array > GetOwnPropertyNames()
Definition: api.cc:2959
void SetCaptureMessage(bool value)
Definition: api.cc:1765
StackTraceOptions
Definition: v8.h:763
static ObjectTemplateInfo * cast(Object *obj)
intptr_t MaxReserved()
Definition: heap.h:465
Handle< Value > GetName() const
Definition: api.cc:5990
static Local< AccessorSignature > AccessorSignatureToLocal(v8::internal::Handle< v8::internal::FunctionTemplateInfo > obj)
StatsTable * stats_table()
Definition: isolate.cc:1885
Handle< JSArray > NewJSArray(int capacity, ElementsKind elements_kind=TERMINAL_FAST_ELEMENTS_KIND, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:1005
value format" "after each garbage collection") DEFINE_bool(print_cumulative_gc_stat, false, "print cumulative GC statistics in name=value format on exit") DEFINE_bool(trace_gc_verbose, false, "print more details following each garbage collection") DEFINE_bool(trace_fragmentation, false, "report fragmentation for old pointer and data pages") DEFINE_bool(collect_maps, true, "garbage collect maps from which no objects can be reached") DEFINE_bool(flush_code, true, "flush code that we expect not to use again before full gc") DEFINE_bool(incremental_marking, true, "use incremental marking") DEFINE_bool(incremental_marking_steps, true, "do incremental marking steps") DEFINE_bool(trace_incremental_marking, false, "trace progress of the incremental marking") DEFINE_bool(use_idle_notification, true, "Use idle notification to reduce memory footprint.") DEFINE_bool(send_idle_notification, false, "Send idle notifcation between stress runs.") DEFINE_bool(use_ic, true, "use inline caching") DEFINE_bool(native_code_counters, false, "generate extra code for manipulating stats counters") DEFINE_bool(always_compact, false, "Perform compaction on every full GC") DEFINE_bool(lazy_sweeping, true, "Use lazy sweeping for old pointer and data spaces") DEFINE_bool(never_compact, false, "Never perform compaction on full GC-testing only") DEFINE_bool(compact_code_space, true, "Compact code space on full non-incremental collections") DEFINE_bool(cleanup_code_caches_at_gc, true, "Flush inline caches prior to mark compact collection and" "flush code caches in maps during mark compact cycle.") DEFINE_int(random_seed, 0, "Default seed for initializing random generator" "(0, the default, means to use system random).") DEFINE_bool(use_verbose_printer, true, "allows verbose printing") DEFINE_bool(allow_natives_syntax, false, "allow natives syntax") DEFINE_bool(trace_sim, false, "Trace simulator execution") DEFINE_bool(check_icache, false, "Check icache flushes in ARM and MIPS simulator") DEFINE_int(stop_sim_at, 0, "Simulator stop after x number of instructions") DEFINE_int(sim_stack_alignment, 8, "Stack alingment in bytes in simulator(4 or 8, 8 is default)") DEFINE_bool(trace_exception, false, "print stack trace when throwing exceptions") DEFINE_bool(preallocate_message_memory, false, "preallocate some memory to build stack traces.") DEFINE_bool(randomize_hashes, true, "randomize hashes to avoid predictable hash collisions" "(with snapshots this option cannot override the baked-in seed)") DEFINE_int(hash_seed, 0, "Fixed seed to use to hash property keys(0 means random)" "(with snapshots this option cannot override the baked-in seed)") DEFINE_bool(preemption, false, "activate a 100ms timer that switches between V8 threads") DEFINE_bool(regexp_optimization, true, "generate optimized regexp code") DEFINE_bool(testing_bool_flag, true, "testing_bool_flag") DEFINE_int(testing_int_flag, 13, "testing_int_flag") DEFINE_float(testing_float_flag, 2.5, "float-flag") DEFINE_string(testing_string_flag, "Hello, world!", "string-flag") DEFINE_int(testing_prng_seed, 42, "Seed used for threading test randomness") DEFINE_string(testing_serialization_file, "/tmp/serdes", "file in which to serialize heap") DEFINE_bool(help, false, "Print usage message, including flags, on console") DEFINE_bool(dump_counters, false, "Dump counters on exit") DEFINE_string(map_counters, "", "Map counters to a file") DEFINE_args(js_arguments, JSARGUMENTS_INIT, "Pass all remaining arguments to the script.Alias for\"--\".") DEFINE_bool(debug_compile_events, true,"Enable debugger compile events") DEFINE_bool(debug_script_collected_events, true,"Enable debugger script collected events") DEFINE_bool(gdbjit, false,"enable GDBJIT interface (disables compacting GC)") DEFINE_bool(gdbjit_full, false,"enable GDBJIT interface for all code objects") DEFINE_bool(gdbjit_dump, false,"dump elf objects with debug info to disk") DEFINE_string(gdbjit_dump_filter,"","dump only objects containing this substring") DEFINE_bool(force_marking_deque_overflows, false,"force overflows of marking deque by reducing it's size ""to 64 words") DEFINE_bool(stress_compaction, false,"stress the GC compactor to flush out bugs (implies ""--force_marking_deque_overflows)")#define FLAG DEFINE_bool(enable_slow_asserts, false,"enable asserts that are slow to execute") DEFINE_bool(trace_codegen, false,"print name of functions for which code is generated") DEFINE_bool(print_source, false,"pretty print source code") DEFINE_bool(print_builtin_source, false,"pretty print source code for builtins") DEFINE_bool(print_ast, false,"print source AST") DEFINE_bool(print_builtin_ast, false,"print source AST for builtins") DEFINE_string(stop_at,"","function name where to insert a breakpoint") DEFINE_bool(print_builtin_scopes, false,"print scopes for builtins") DEFINE_bool(print_scopes, false,"print scopes") DEFINE_bool(trace_contexts, false,"trace contexts operations") DEFINE_bool(gc_greedy, false,"perform GC prior to some allocations") DEFINE_bool(gc_verbose, false,"print stuff during garbage collection") DEFINE_bool(heap_stats, false,"report heap statistics before and after GC") DEFINE_bool(code_stats, false,"report code statistics after GC") DEFINE_bool(verify_heap, false,"verify heap pointers before and after GC") DEFINE_bool(print_handles, false,"report handles after GC") DEFINE_bool(print_global_handles, false,"report global handles after GC") DEFINE_bool(trace_ic, false,"trace inline cache state transitions") DEFINE_bool(print_interfaces, false,"print interfaces") DEFINE_bool(print_interface_details, false,"print interface inference details") DEFINE_int(print_interface_depth, 5,"depth for printing interfaces") DEFINE_bool(trace_normalization, false,"prints when objects are turned into dictionaries.") DEFINE_bool(trace_lazy, false,"trace lazy compilation") DEFINE_bool(collect_heap_spill_statistics, false,"report heap spill statistics along with heap_stats ""(requires heap_stats)") DEFINE_bool(trace_isolates, false,"trace isolate state changes") DEFINE_bool(log_state_changes, false,"Log state changes.") DEFINE_bool(regexp_possessive_quantifier, false,"enable possessive quantifier syntax for testing") DEFINE_bool(trace_regexp_bytecodes, false,"trace regexp bytecode execution") DEFINE_bool(trace_regexp_assembler, false,"trace regexp macro assembler calls.")#define FLAG DEFINE_bool(log, false,"Minimal logging (no API, code, GC, suspect, or handles samples).") DEFINE_bool(log_all, false,"Log all events to the log file.") DEFINE_bool(log_runtime, false,"Activate runtime system %Log call.") DEFINE_bool(log_api, false,"Log API events to the log file.") DEFINE_bool(log_code, false,"Log code events to the log file without profiling.") DEFINE_bool(log_gc, false,"Log heap samples on garbage collection for the hp2ps tool.") DEFINE_bool(log_handles, false,"Log global handle events.") DEFINE_bool(log_snapshot_positions, false,"log positions of (de)serialized objects in the snapshot.") DEFINE_bool(log_suspect, false,"Log suspect operations.") DEFINE_bool(prof, false,"Log statistical profiling information (implies --log-code).") DEFINE_bool(prof_auto, true,"Used with --prof, starts profiling automatically") DEFINE_bool(prof_lazy, false,"Used with --prof, only does sampling and logging"" when profiler is active (implies --noprof_auto).") DEFINE_bool(prof_browser_mode, true,"Used with --prof, turns on browser-compatible mode for profiling.") DEFINE_bool(log_regexp, false,"Log regular expression execution.") DEFINE_bool(sliding_state_window, false,"Update sliding state window counters.") DEFINE_string(logfile,"v8.log","Specify the name of the log file.") DEFINE_bool(ll_prof, false,"Enable low-level linux profiler.")#define FLAG DEFINE_bool(trace_elements_transitions, false,"trace elements transitions") DEFINE_bool(print_code_stubs, false,"print code stubs") DEFINE_bool(test_secondary_stub_cache, false,"test secondary stub cache by disabling the primary one") DEFINE_bool(test_primary_stub_cache, false,"test primary stub cache by disabling the secondary one") DEFINE_bool(print_code, false,"print generated code") DEFINE_bool(print_opt_code, false,"print optimized code") DEFINE_bool(print_unopt_code, false,"print unoptimized code before ""printing optimized code based on it") DEFINE_bool(print_code_verbose, false,"print more information for code") DEFINE_bool(print_builtin_code, false,"print generated code for builtins")#43"/Users/thlorenz/dev/dx/v8-perf/build/v8/src/flags.cc"2#define FLAG_MODE_DEFINE_DEFAULTS#1"/Users/thlorenz/dev/dx/v8-perf/build/v8/src/flag-definitions.h"1#define FLAG_FULL(ftype, ctype, nam, def, cmt)#define FLAG_READONLY(ftype, ctype, nam, def, cmt)#define DEFINE_implication(whenflag, thenflag)#define DEFINE_bool(nam, def, cmt)#define DEFINE_int(nam, def, cmt)#define DEFINE_float(nam, def, cmt)#define DEFINE_string(nam, def, cmt)#define DEFINE_args(nam, def, cmt)#define FLAG DEFINE_bool(use_strict, false,"enforce strict mode") DEFINE_bool(es5_readonly, false,"activate correct semantics for inheriting readonliness") DEFINE_bool(es52_globals, false,"activate new semantics for global var declarations") DEFINE_bool(harmony_typeof, false,"enable harmony semantics for typeof") DEFINE_bool(harmony_scoping, false,"enable harmony block scoping") DEFINE_bool(harmony_modules, false,"enable harmony modules (implies block scoping)") DEFINE_bool(harmony_proxies, false,"enable harmony proxies") DEFINE_bool(harmony_collections, false,"enable harmony collections (sets, maps, and weak maps)") DEFINE_bool(harmony, false,"enable all harmony features (except typeof)") DEFINE_implication(harmony, harmony_scoping) DEFINE_implication(harmony, harmony_modules) DEFINE_implication(harmony, harmony_proxies) DEFINE_implication(harmony, harmony_collections) DEFINE_implication(harmony_modules, harmony_scoping) DEFINE_bool(packed_arrays, false,"optimizes arrays that have no holes") DEFINE_bool(smi_only_arrays, true,"tracks arrays with only smi values") DEFINE_bool(clever_optimizations, true,"Optimize object size, Array shift, DOM strings and string +") DEFINE_bool(unbox_double_arrays, true,"automatically unbox arrays of doubles") DEFINE_bool(string_slices, true,"use string slices") DEFINE_bool(crankshaft, true,"use crankshaft") DEFINE_string(hydrogen_filter,"","optimization filter") DEFINE_bool(use_range, true,"use hydrogen range analysis") DEFINE_bool(eliminate_dead_phis, true,"eliminate dead phis") DEFINE_bool(use_gvn, true,"use hydrogen global value numbering") DEFINE_bool(use_canonicalizing, true,"use hydrogen instruction canonicalizing") DEFINE_bool(use_inlining, true,"use function inlining") DEFINE_int(max_inlined_source_size, 600,"maximum source size in bytes considered for a single inlining") DEFINE_int(max_inlined_nodes, 196,"maximum number of AST nodes considered for a single inlining") DEFINE_int(max_inlined_nodes_cumulative, 196,"maximum cumulative number of AST nodes considered for inlining") DEFINE_bool(loop_invariant_code_motion, true,"loop invariant code motion") DEFINE_bool(collect_megamorphic_maps_from_stub_cache, true,"crankshaft harvests type feedback from stub cache") DEFINE_bool(hydrogen_stats, false,"print statistics for hydrogen") DEFINE_bool(trace_hydrogen, false,"trace generated hydrogen to file") DEFINE_string(trace_phase,"Z","trace generated IR for specified phases") DEFINE_bool(trace_inlining, false,"trace inlining decisions") DEFINE_bool(trace_alloc, false,"trace register allocator") DEFINE_bool(trace_all_uses, false,"trace all use positions") DEFINE_bool(trace_range, false,"trace range analysis") DEFINE_bool(trace_gvn, false,"trace global value numbering") DEFINE_bool(trace_representation, false,"trace representation types") DEFINE_bool(stress_pointer_maps, false,"pointer map for every instruction") DEFINE_bool(stress_environments, false,"environment for every instruction") DEFINE_int(deopt_every_n_times, 0,"deoptimize every n times a deopt point is passed") DEFINE_bool(trap_on_deopt, false,"put a break point before deoptimizing") DEFINE_bool(deoptimize_uncommon_cases, true,"deoptimize uncommon cases") DEFINE_bool(polymorphic_inlining, true,"polymorphic inlining") DEFINE_bool(use_osr, true,"use on-stack replacement") DEFINE_bool(array_bounds_checks_elimination, false,"perform array bounds checks elimination") DEFINE_bool(array_index_dehoisting, false,"perform array index dehoisting") DEFINE_bool(trace_osr, false,"trace on-stack replacement") DEFINE_int(stress_runs, 0,"number of stress runs") DEFINE_bool(optimize_closures, true,"optimize closures") DEFINE_bool(inline_construct, true,"inline constructor calls") DEFINE_bool(inline_arguments, true,"inline functions with arguments object") DEFINE_int(loop_weight, 1,"loop weight for representation inference") DEFINE_bool(optimize_for_in, true,"optimize functions containing for-in loops") DEFINE_bool(experimental_profiler, true,"enable all profiler experiments") DEFINE_bool(watch_ic_patching, false,"profiler considers IC stability") DEFINE_int(frame_count, 1,"number of stack frames inspected by the profiler") DEFINE_bool(self_optimization, false,"primitive functions trigger their own optimization") DEFINE_bool(direct_self_opt, false,"call recompile stub directly when self-optimizing") DEFINE_bool(retry_self_opt, false,"re-try self-optimization if it failed") DEFINE_bool(count_based_interrupts, false,"trigger profiler ticks based on counting instead of timing") DEFINE_bool(interrupt_at_exit, false,"insert an interrupt check at function exit") DEFINE_bool(weighted_back_edges, false,"weight back edges by jump distance for interrupt triggering") DEFINE_int(interrupt_budget, 5900,"execution budget before interrupt is triggered") DEFINE_int(type_info_threshold, 15,"percentage of ICs that must have type info to allow optimization") DEFINE_int(self_opt_count, 130,"call count before self-optimization") DEFINE_implication(experimental_profiler, watch_ic_patching) DEFINE_implication(experimental_profiler, self_optimization) DEFINE_implication(experimental_profiler, retry_self_opt) DEFINE_implication(experimental_profiler, count_based_interrupts) DEFINE_implication(experimental_profiler, interrupt_at_exit) DEFINE_implication(experimental_profiler, weighted_back_edges) DEFINE_bool(trace_opt_verbose, false,"extra verbose compilation tracing") DEFINE_implication(trace_opt_verbose, trace_opt) DEFINE_bool(debug_code, false,"generate extra code (assertions) for debugging") DEFINE_bool(code_comments, false,"emit comments in code disassembly") DEFINE_bool(enable_sse2, true,"enable use of SSE2 instructions if available") DEFINE_bool(enable_sse3, true,"enable use of SSE3 instructions if available") DEFINE_bool(enable_sse4_1, true,"enable use of SSE4.1 instructions if available") DEFINE_bool(enable_cmov, true,"enable use of CMOV instruction if available") DEFINE_bool(enable_rdtsc, true,"enable use of RDTSC instruction if available") DEFINE_bool(enable_sahf, true,"enable use of SAHF instruction if available (X64 only)") DEFINE_bool(enable_vfp3, true,"enable use of VFP3 instructions if available - this implies ""enabling ARMv7 instructions (ARM only)") DEFINE_bool(enable_armv7, true,"enable use of ARMv7 instructions if available (ARM only)") DEFINE_bool(enable_fpu, true,"enable use of MIPS FPU instructions if available (MIPS only)") DEFINE_string(expose_natives_as, NULL,"expose natives in global object") DEFINE_string(expose_debug_as, NULL,"expose debug in global object") DEFINE_bool(expose_gc, false,"expose gc extension") DEFINE_bool(expose_externalize_string, false,"expose externalize string extension") DEFINE_int(stack_trace_limit, 10,"number of stack frames to capture") DEFINE_bool(builtins_in_stack_traces, false,"show built-in functions in stack traces") DEFINE_bool(disable_native_files, false,"disable builtin natives files") DEFINE_bool(inline_new, true,"use fast inline allocation") DEFINE_bool(stack_trace_on_abort, true,"print a stack trace if an assertion failure occurs") DEFINE_bool(trace, false,"trace function calls") DEFINE_bool(mask_constants_with_cookie, true,"use random jit cookie to mask large constants") DEFINE_bool(lazy, true,"use lazy compilation") DEFINE_bool(trace_opt, false,"trace lazy optimization") DEFINE_bool(trace_opt_stats, false,"trace lazy optimization statistics") DEFINE_bool(opt, true,"use adaptive optimizations") DEFINE_bool(always_opt, false,"always try to optimize functions") DEFINE_bool(prepare_always_opt, false,"prepare for turning on always opt") DEFINE_bool(trace_deopt, false,"trace deoptimization") DEFINE_int(min_preparse_length, 1024,"minimum length for automatic enable preparsing") DEFINE_bool(always_full_compiler, false,"try to use the dedicated run-once backend for all code") DEFINE_bool(trace_bailout, false,"print reasons for falling back to using the classic V8 backend") DEFINE_bool(compilation_cache, true,"enable compilation cache") DEFINE_bool(cache_prototype_transitions, true,"cache prototype transitions") DEFINE_bool(trace_debug_json, false,"trace debugging JSON request/response") DEFINE_bool(debugger_auto_break, true,"automatically set the debug break flag when debugger commands are ""in the queue") DEFINE_bool(enable_liveedit, true,"enable liveedit experimental feature") DEFINE_bool(break_on_abort, true,"always cause a debug break before aborting") DEFINE_int(stack_size, kPointerSize *123,"default size of stack region v8 is allowed to use (in kBytes)") DEFINE_int(max_stack_trace_source_length, 300,"maximum length of function source code printed in a stack trace.") DEFINE_bool(always_inline_smi_code, false,"always inline smi code in non-opt code") DEFINE_int(max_new_space_size, 0,"max size of the new generation (in kBytes)") DEFINE_int(max_old_space_size, 0,"max size of the old generation (in Mbytes)") DEFINE_int(max_executable_size, 0,"max size of executable memory (in Mbytes)") DEFINE_bool(gc_global, false,"always perform global GCs") DEFINE_int(gc_interval,-1,"garbage collect after <n> allocations") DEFINE_bool(trace_gc, false,"print one trace line following each garbage collection") DEFINE_bool(trace_gc_nvp, false,"print one detailed trace line in name=value format ""after each garbage collection") DEFINE_bool(print_cumulative_gc_stat, false,"print cumulative GC statistics in name=value format on exit") DEFINE_bool(trace_gc_verbose, false,"print more details following each garbage collection") DEFINE_bool(trace_fragmentation, false,"report fragmentation for old pointer and data pages") DEFINE_bool(collect_maps, true,"garbage collect maps from which no objects can be reached") DEFINE_bool(flush_code, true,"flush code that we expect not to use again before full gc") DEFINE_bool(incremental_marking, true,"use incremental marking") DEFINE_bool(incremental_marking_steps, true,"do incremental marking steps") DEFINE_bool(trace_incremental_marking, false,"trace progress of the incremental marking") DEFINE_bool(use_idle_notification, true,"Use idle notification to reduce memory footprint.") DEFINE_bool(send_idle_notification, false,"Send idle notifcation between stress runs.") DEFINE_bool(use_ic, true,"use inline caching") DEFINE_bool(native_code_counters, false,"generate extra code for manipulating stats counters") DEFINE_bool(always_compact, false,"Perform compaction on every full GC") DEFINE_bool(lazy_sweeping, true,"Use lazy sweeping for old pointer and data spaces") DEFINE_bool(never_compact, false,"Never perform compaction on full GC - testing only") DEFINE_bool(compact_code_space, true,"Compact code space on full non-incremental collections") DEFINE_bool(cleanup_code_caches_at_gc, true,"Flush inline caches prior to mark compact collection and ""flush code caches in maps during mark compact cycle.") DEFINE_int(random_seed, 0,"Default seed for initializing random generator ""(0, the default, means to use system random).") DEFINE_bool(use_verbose_printer, true,"allows verbose printing") DEFINE_bool(allow_natives_syntax, false,"allow natives syntax") DEFINE_bool(trace_sim, false,"Trace simulator execution") DEFINE_bool(check_icache, false,"Check icache flushes in ARM and MIPS simulator") DEFINE_int(stop_sim_at, 0,"Simulator stop after x number of instructions") DEFINE_int(sim_stack_alignment, 8,"Stack alingment in bytes in simulator (4 or 8, 8 is default)") DEFINE_bool(trace_exception, false,"print stack trace when throwing exceptions") DEFINE_bool(preallocate_message_memory, false,"preallocate some memory to build stack traces.") DEFINE_bool(randomize_hashes, true,"randomize hashes to avoid predictable hash collisions ""(with snapshots this option cannot override the baked-in seed)") DEFINE_int(hash_seed, 0,"Fixed seed to use to hash property keys (0 means random)""(with snapshots this option cannot override the baked-in seed)") DEFINE_bool(preemption, false,"activate a 100ms timer that switches between V8 threads") DEFINE_bool(regexp_optimization, true,"generate optimized regexp code") DEFINE_bool(testing_bool_flag, true,"testing_bool_flag") DEFINE_int(testing_int_flag, 13,"testing_int_flag") DEFINE_float(testing_float_flag, 2.5,"float-flag") DEFINE_string(testing_string_flag,"Hello, world!","string-flag") DEFINE_int(testing_prng_seed, 42,"Seed used for threading test randomness") DEFINE_string(testing_serialization_file,"/tmp/serdes","file in which to serialize heap") DEFINE_bool(help, false,"Print usage message, including flags, on console") DEFINE_bool(dump_counters, false,"Dump counters on exit") DEFINE_string(map_counters,"","Map counters to a file") DEFINE_args(js_arguments, JSARGUMENTS_INIT,"Pass all remaining arguments to the script. Alias for \"--\".") DEFINE_bool(debug_compile_events, true,"Enable debugger compile events") DEFINE_bool(debug_script_collected_events, true,"Enable debugger script collected events") DEFINE_bool(gdbjit, false,"enable GDBJIT interface (disables compacting GC)") DEFINE_bool(gdbjit_full, false,"enable GDBJIT interface for all code objects") DEFINE_bool(gdbjit_dump, false,"dump elf objects with debug info to disk") DEFINE_string(gdbjit_dump_filter,"","dump only objects containing this substring") DEFINE_bool(force_marking_deque_overflows, false,"force overflows of marking deque by reducing it's size ""to 64 words") DEFINE_bool(stress_compaction, false,"stress the GC compactor to flush out bugs (implies ""--force_marking_deque_overflows)")#define FLAG DEFINE_bool(enable_slow_asserts, false,"enable asserts that are slow to execute") DEFINE_bool(trace_codegen, false,"print name of functions for which code is generated") DEFINE_bool(print_source, false,"pretty print source code") DEFINE_bool(print_builtin_source, false,"pretty print source code for builtins") DEFINE_bool(print_ast, false,"print source AST") DEFINE_bool(print_builtin_ast, false,"print source AST for builtins") DEFINE_string(stop_at,"","function name where to insert a breakpoint") DEFINE_bool(print_builtin_scopes, false,"print scopes for builtins") DEFINE_bool(print_scopes, false,"print scopes") DEFINE_bool(trace_contexts, false,"trace contexts operations") DEFINE_bool(gc_greedy, false,"perform GC prior to some allocations") DEFINE_bool(gc_verbose, false,"print stuff during garbage collection") DEFINE_bool(heap_stats, false,"report heap statistics before and after GC") DEFINE_bool(code_stats, false,"report code statistics after GC") DEFINE_bool(verify_heap, false,"verify heap pointers before and after GC") DEFINE_bool(print_handles, false,"report handles after GC") DEFINE_bool(print_global_handles, false,"report global handles after GC") DEFINE_bool(trace_ic, false,"trace inline cache state transitions") DEFINE_bool(print_interfaces, false,"print interfaces") DEFINE_bool(print_interface_details, false,"print interface inference details") DEFINE_int(print_interface_depth, 5,"depth for printing interfaces") DEFINE_bool(trace_normalization, false,"prints when objects are turned into dictionaries.") DEFINE_bool(trace_lazy, false,"trace lazy compilation") DEFINE_bool(collect_heap_spill_statistics, false,"report heap spill statistics along with heap_stats ""(requires heap_stats)") DEFINE_bool(trace_isolates, false,"trace isolate state changes") DEFINE_bool(log_state_changes, false,"Log state changes.") DEFINE_bool(regexp_possessive_quantifier, false,"enable possessive quantifier syntax for testing") DEFINE_bool(trace_regexp_bytecodes, false,"trace regexp bytecode execution") DEFINE_bool(trace_regexp_assembler, false,"trace regexp macro assembler calls.")#define FLAG DEFINE_bool(log, false,"Minimal logging (no API, code, GC, suspect, or handles samples).") DEFINE_bool(log_all, false,"Log all events to the log file.") DEFINE_bool(log_runtime, false,"Activate runtime system %Log call.") DEFINE_bool(log_api, false,"Log API events to the log file.") DEFINE_bool(log_code, false,"Log code events to the log file without profiling.") DEFINE_bool(log_gc, false,"Log heap samples on garbage collection for the hp2ps tool.") DEFINE_bool(log_handles, false,"Log global handle events.") DEFINE_bool(log_snapshot_positions, false,"log positions of (de)serialized objects in the snapshot.") DEFINE_bool(log_suspect, false,"Log suspect operations.") DEFINE_bool(prof, false,"Log statistical profiling information (implies --log-code).") DEFINE_bool(prof_auto, true,"Used with --prof, starts profiling automatically") DEFINE_bool(prof_lazy, false,"Used with --prof, only does sampling and logging"" when profiler is active (implies --noprof_auto).") DEFINE_bool(prof_browser_mode, true,"Used with --prof, turns on browser-compatible mode for profiling.") DEFINE_bool(log_regexp, false,"Log regular expression execution.") DEFINE_bool(sliding_state_window, false,"Update sliding state window counters.") DEFINE_string(logfile,"v8.log","Specify the name of the log file.") DEFINE_bool(ll_prof, false,"Enable low-level linux profiler.")#define FLAG DEFINE_bool(trace_elements_transitions, false,"trace elements transitions") DEFINE_bool(print_code_stubs, false,"print code stubs") DEFINE_bool(test_secondary_stub_cache, false,"test secondary stub cache by disabling the primary one") DEFINE_bool(test_primary_stub_cache, false,"test primary stub cache by disabling the secondary one") DEFINE_bool(print_code, false,"print generated code") DEFINE_bool(print_opt_code, false,"print optimized code") DEFINE_bool(print_unopt_code, false,"print unoptimized code before ""printing optimized code based on it") DEFINE_bool(print_code_verbose, false,"print more information for code") DEFINE_bool(print_builtin_code, false,"print generated code for builtins")#47"/Users/thlorenz/dev/dx/v8-perf/build/v8/src/flags.cc"2 namespace{struct Flag{enum FlagType{TYPE_BOOL, TYPE_INT, TYPE_FLOAT, TYPE_STRING, TYPE_ARGS} name
Definition: flags.cc:1349
Handle< String > GetName() const
Definition: api.cc:6040
static void SetFatalError()
Definition: v8.cc:97
SnapshotObjectId GetId() const
Definition: api.cc:6048
V8EXPORT bool IsBooleanObject() const
Definition: api.cc:2290
static Handle< T > cast(Handle< S > that)
Definition: handles.h:81
Local< String > Get() const
Definition: api.cc:1773
static void SetCaptureStackTraceForUncaughtExceptions(bool capture, int frame_limit=10, StackTrace::StackTraceOptions options=StackTrace::kOverview)
Definition: api.cc:5166
void AllowCodeGenerationFromStrings(bool allow)
Definition: api.cc:4503
void SetData(Handle< String > data)
Definition: api.cc:765
void AddString(String *string)
Definition: heap-inl.h:571
ThreadId thread_id()
Definition: isolate.h:531
static V8EXPORT Local< String > New(const char *data, int length=-1)
Definition: api.cc:4655
void SetData(Handle< String > data)
Definition: api.cc:1652
void AddImplicitReferences(HeapObject **parent, Object ***children, size_t length)
int ToInteger() const
Definition: isolate.h:170
bool IsAsciiRepresentation()
Definition: objects-inl.h:289
const CpuProfileNode * GetChild(int index) const
Definition: api.cc:5870
static ExternalTwoByteString * cast(Object *obj)
#define API_ENTRY_CHECK(isolate, msg)
Definition: api.cc:115
void VisitExternalResources(v8::ExternalResourceVisitor *visitor)
Definition: heap.cc:1476
int32_t uc32
Definition: globals.h:274
V8EXPORT bool IsExternal() const
Definition: api.cc:2189
bool(* IndexedSecurityCallback)(Local< Object > host, uint32_t index, AccessType type, Local< Value > data)
Definition: v8.h:2124
static V8EXPORT Local< String > NewSymbol(const char *data, int length=-1)
Definition: api.cc:5075
V8EXPORT Local< String > GetConstructorName()
Definition: api.cc:3034
Local< ObjectTemplate > InstanceTemplate()
Definition: api.cc:1115
V8EXPORT Local< Int32 > ToInt32() const
Definition: api.cc:2589
static Handle< Object > ToInteger(Handle< Object > obj, bool *exc)
Definition: execution.cc:630
Handle< Primitive > V8EXPORT Null()
Definition: api.cc:556
Definition: v8.h:506
static Handle< Object > ToObject(Handle< Object > obj, bool *exc)
Definition: execution.cc:624
V8EXPORT Local< Context > CreationContext()
Definition: api.cc:3265
Flag flags[]
Definition: flags.cc:1467
void SetGlobalGCPrologueCallback(GCCallback callback)
Definition: heap.h:1110
int int32_t
Definition: unicode.cc:47
static void AddMemoryAllocationCallback(MemoryAllocationCallback callback, ObjectSpace space, AllocationAction action)
Definition: api.cc:5287
static void SetReturnAddressLocationResolver(ReturnAddressLocationResolver return_address_resolver)
Definition: api.cc:4218
V8EXPORT bool HasRealNamedCallbackProperty(Handle< String > key)
Definition: api.cc:3133
virtual Handle< Value > GetCallbackData() const =0
V8EXPORT Local< Value > GetHiddenValue(Handle< String > key)
Definition: api.cc:3301
v8::HandleScope::Data HandleScopeData
Definition: apiutils.h:69
void RemoveGCPrologueCallback(GCEpilogueCallback callback)
Definition: heap.cc:6247
Bootstrapper * bootstrapper()
Definition: isolate.h:803
Handle< String > GetScriptResourceName() const
Definition: api.cc:5812
static bool IsNearDeath(Object **location)
const HeapGraphNode * GetNodeById(SnapshotObjectId id) const
Definition: api.cc:6134
static Local< Context > GetDebugContext()
static Foreign * cast(Object *obj)
int GetStartPosition() const
Definition: api.cc:1880
int length()
Definition: api.cc:849
Local< Value > GetData()
Definition: api.cc:777
AllocationAction
Definition: v8.h:2683
static CpuProfile * StopProfiling(const char *title)
static const int kNoColumnInfo
Definition: v8.h:748
int *(* CounterLookupCallback)(const char *name)
Definition: v8.h:2660
const HeapGraphNode * GetNode(int index) const
Definition: api.cc:6149
void ReattachGlobal(Handle< Object > global_object)
Definition: api.cc:4490
static Local< Value > Error(Handle< String > message)
Definition: api.cc:5543
intptr_t * code_space_size
Definition: heap.h:2075
void SetIndexedPropertyHandler(IndexedPropertyGetter getter, IndexedPropertySetter setter=0, IndexedPropertyQuery query=0, IndexedPropertyDeleter deleter=0, IndexedPropertyEnumerator enumerator=0, Handle< Value > data=Handle< Value >())
Definition: api.cc:1379
void AddGCEpilogueCallback(GCEpilogueCallback callback, GCType gc_type_filter)
Definition: heap.cc:6259
Handle< Object > SetAccessor(Handle< JSObject > obj, Handle< AccessorInfo > info)
Definition: handles.cc:342
static void set_context_raw_data(const byte *context_raw_data)
Definition: snapshot.h:62
V8EXPORT Local< Array > GetPropertyNames()
Definition: api.cc:2938
V8EXPORT ExternalArrayType GetIndexedPropertiesExternalArrayDataType()
Definition: api.cc:3482
virtual DebugEvent GetEvent() const =0
V8EXPORT Local< Value > Call(Handle< Object > recv, int argc, Handle< Value > argv[])
Definition: api.cc:3629
V8EXPORT bool IsRegExp() const
Definition: api.cc:2298
static V8EXPORT const int kLineOffsetNotFound
Definition: v8.h:1771
#define ENTER_V8(isolate)
Definition: api.cc:64
Utf8Value(Handle< v8::Value > obj)
Definition: api.cc:5415
static Handle< Object > ToInt32(Handle< Object > obj, bool *exc)
Definition: execution.cc:640
#define ASSERT(condition)
Definition: checks.h:270
static Vector< const byte > GetScriptsSource()
void(* GCPrologueCallback)(GCType type, GCCallbackFlags flags)
Definition: v8.h:2729
V8EXPORT bool MayContainNonAscii() const
Definition: api.cc:3820
void ClearWeakness(Object **location)
~TryCatch()
Definition: api.cc:1682
V8EXPORT Local< Number > ToNumber() const
Definition: api.cc:2382
void SetFailedAccessCheckCallback(v8::FailedAccessCheckCallback callback)
Definition: isolate.cc:741
void UseDefaultSecurityToken()
Definition: api.cc:4394
static int GetSnapshotsCount()
Definition: api.cc:6182
static int size()
Definition: snapshot.h:54
CompressionAlgorithm
Definition: v8.h:2864
void EnterContext(Handle< Object > context)
Definition: api.h:509
void ResumeProfiler()
Definition: log.cc:1295
static StackGuard * GetDefaultIsolateStackGuard()
Definition: isolate.cc:393
void AddGCPrologueCallback(GCEpilogueCallback callback, GCType gc_type_filter)
Definition: heap.cc:6239
static Script * cast(Object *obj)
ExternalArrayType
Definition: v8.h:1407
void(* MessageHandler2)(const Message &message)
Definition: v8-debug.h:235
unsigned short uint16_t
Definition: unicode.cc:46
V8EXPORT void * GetIndexedPropertiesExternalArrayData()
Definition: api.cc:3469
TryCatch()
Definition: api.cc:1669
V8EXPORT bool IsCallable()
Definition: api.cc:3525
static void DeoptimizeAll()
Definition: deoptimizer.cc:249
static void SetDecompressedStartupData(StartupData *decompressed_data)
Definition: api.cc:425
int GetSelfSize() const
Definition: api.cc:6055
Handle< Value > ResourceName() const
Definition: v8.h:4155
static V8EXPORT Local< Value > Wrap(void *data)
Definition: api.cc:4583
#define EXCEPTION_BAILOUT_CHECK(isolate, value)
Definition: api.cc:111
ThreadManager * thread_manager()
Definition: isolate.h:867
kPropertyAccessorsOffset kNamedPropertyHandlerOffset instance_template
Definition: objects-inl.h:3618
static SharedFunctionInfo * cast(Object *obj)
virtual int DecompressData(char *raw_data, int *raw_data_size, const char *compressed_data, int compressed_data_size)=0
static bool IsDead()
Definition: api.cc:227
void(* FatalErrorCallback)(const char *location, const char *message)
Definition: v8.h:2630
V8EXPORT Local< String > ToString() const
Definition: api.cc:2305
static const int kNoLineNumberInfo
Definition: v8.h:747
static void DefineWrapperClass(uint16_t class_id, WrapperInfoCallback callback)
Definition: api.cc:6260
intptr_t CommittedMemoryExecutable()
Definition: heap.cc:209
static bool InContext()
Definition: api.cc:4424
Type GetType() const
Definition: api.cc:5983
Handle< Object > NewNumber(double value, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:581
#define CHECK(condition)
Definition: checks.h:56
static const int kShortSize
Definition: objects.h:7516
Handle< Value >(* IndexedPropertySetter)(uint32_t index, Local< Value > value, const AccessorInfo &info)
Definition: v8.h:2071
int GetScriptColumnNumber(Handle< Script > script, int code_pos)
Definition: handles.cc:504
static const CpuProfile * FindProfile(unsigned uid, Handle< Value > security_token=Handle< Value >())
Definition: api.cc:5941
static bool IsDead()
Definition: v8.h:89
void ResetDateCache()
Definition: date.cc:51
V8EXPORT Local< Value > CallAsConstructor(int argc, Handle< Value > argv[])
Definition: api.cc:3568
static Handle< Object > ToDetailString(Handle< Object > obj, bool *exc)
Definition: execution.cc:619
static intptr_t AdjustAmountOfExternalAllocatedMemory(intptr_t change_in_bytes)
Definition: api.cc:5235
void SetVerbose(bool value)
Definition: api.cc:1760
int isnan(double x)
static CpuProfile * GetProfile(Object *security_token, int index)
Handle< Object > GetProperty(Handle< JSReceiver > obj, const char *name)
Definition: handles.cc:282
virtual ClientData * GetClientData() const =0
V8EXPORT bool CanMakeExternal()
Definition: api.cc:4816
V8EXPORT bool IsDirty()
Definition: api.cc:3232
void Set(Handle< String > name, Handle< Data > value, PropertyAttribute attributes=None)
Definition: api.cc:894
Factory * factory()
Definition: isolate.h:977
static bool HasDetachedProfiles()
void AddObjectGroup(Object ***handles, size_t length, v8::RetainedObjectInfo *info)
PropertyAttributes
V8EXPORT Handle< Value > GetName() const
Definition: api.cc:3662
int * pending_global_handle_count
Definition: heap.h:2084
static bool Dispose()
Definition: api.cc:4224
static void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback)
Definition: api.cc:5203
static V8EXPORT Local< String > NewUndetectable(const char *data, int length=-1)
Definition: api.cc:4682
Handle< String > LookupAsciiSymbol(Vector< const char > str)
Definition: factory.cc:174
V8EXPORT void SetIndexedPropertiesToExternalArrayData(void *data, ExternalArrayType array_type, int number_of_elements)
Definition: api.cc:3437
const CpuProfileNode * GetBottomUpRoot() const
Definition: api.cc:5907
static const unsigned kMaxEncodedSize
Definition: unicode.h:163
static Handle< Object > SetHiddenProperty(Handle< JSObject > obj, Handle< String > key, Handle< Object > value)
Definition: objects.cc:3551
V8EXPORT Local< Uint32 > ToUint32() const
Definition: api.cc:2607
V8EXPORT bool Equals(Handle< Value > that) const
Definition: api.cc:2676
Handle< Object > NewSyntaxError(const char *type, Handle< JSArray > args)
Definition: factory.cc:636
V8EXPORT Handle< Value > GetScriptId() const
Definition: api.cc:3710
static void VisitExternalResources(ExternalResourceVisitor *visitor)
Definition: api.cc:4261
#define SET_FIELD_WRAPPED(obj, setter, cdata)
Definition: api.cc:1037
REGEXP_FLAG_ASSERT_EQ(kNone, NONE)
bool IsDefaultIsolate() const
Definition: isolate.h:467
Handle< String > GetFunctionName() const
Definition: api.cc:5796
static void GetCompressedStartupData(StartupData *compressed_data)
Definition: api.cc:394
Handle< Object > LastEnteredContext()
Definition: api.h:521
void SetCounterFunction(CounterLookupCallback f)
Definition: counters.h:45
Handle< Value > GetScriptResourceName() const
Definition: api.cc:1785
static void AddGCPrologueCallback(GCPrologueCallback callback, GCType gc_type_filter=kGCTypeAll)
Definition: api.cc:5259
static Smi * cast(Object *object)
void(* FailedAccessCheckCallback)(Local< Object > target, AccessType type, Local< Value > data)
Definition: v8.h:2697
Value(Handle< v8::Value > obj)
Definition: api.cc:5458
Handle< Object > ForceDeleteProperty(Handle< JSObject > object, Handle< Object > key)
Definition: handles.cc:259
V8EXPORT bool IsExternal() const
Definition: api.cc:4023
v8::internal::Handle< v8::internal::JSObject > value()
Definition: api.h:64
V8EXPORT bool HasIndexedPropertiesInExternalArrayData()
Definition: api.cc:3460
static bool IdleNotification(int hint)
Definition: v8.cc:184
bool Equals(String *other)
Definition: objects-inl.h:2275
static void SetEntropySource(EntropySource source)
Definition: v8.cc:156
V8EXPORT void SetInternalField(int index, Handle< Value > value)
Definition: api.cc:4150
static Local< StackFrame > StackFrameToLocal(v8::internal::Handle< v8::internal::JSObject > obj)
V8EXPORT void SetPointerInInternalField(int index, void *value)
Definition: api.cc:4184
void SetClassName(Handle< String > name)
Definition: api.cc:1132
static V8EXPORT Local< Integer > NewFromUnsigned(uint32_t value)
Definition: api.cc:5113
StackGuard * stack_guard()
Definition: isolate.h:819
int GetEndColumn() const
Definition: api.cc:1920
void set_context_exit_happened(bool context_exit_happened)
Definition: isolate.h:1030
double GetSelfSamplesCount() const
Definition: api.cc:5849
Handle< Context > global_context()
Definition: isolate.cc:1318
Handle< Value >(* IndexedPropertyGetter)(uint32_t index, const AccessorInfo &info)
Definition: v8.h:2063
intptr_t * lo_space_size
Definition: heap.h:2081
static void DebugBreakForCommand(ClientData *data=NULL, Isolate *isolate=NULL)
Local< StackFrame > GetFrame(uint32_t index) const
Definition: api.cc:1968
static const char * GetVersion()
Definition: api.cc:4291
V8EXPORT Local< Value > GetRealNamedProperty(Handle< String > key)
Definition: api.cc:3198
int NotifyContextDisposed()
Definition: heap.h:1075
#define LEAVE_V8(isolate)
Definition: api.cc:67
Local< Value > Id()
Definition: api.cc:1635
V8EXPORT bool IsExternalAscii() const
Definition: api.cc:4033
void TerminateExecution(ThreadId thread_id)
Definition: v8threads.cc:399
const uint16_t * SeqTwoByteStringGetData(unsigned start)
Definition: objects.cc:6268
Handle< Map > GetElementsTransitionMap(Handle< JSObject > object, ElementsKind elements_kind)
Definition: factory.cc:506
V8EXPORT bool IsStringObject() const
Definition: api.cc:2239
V8EXPORT bool MakeExternal(ExternalStringResource *resource)
Definition: api.cc:4759
Handle< String > NewStringFromUtf8(Vector< const char > str, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:207
int * near_death_global_handle_count
Definition: heap.h:2085
V8EXPORT ScriptOrigin GetScriptOrigin() const
Definition: api.cc:3674
static Local< Script > New(Handle< String > source, ScriptOrigin *origin=NULL, ScriptData *pre_data=NULL, Handle< String > script_data=Handle< String >())
Definition: api.cc:1499
static int GetCompressedStartupDataCount()
Definition: api.cc:385
T ** location() const
Definition: handles.h:75
unsigned GetCallUid() const
Definition: api.cc:5856
Handle< Object > NewRangeError(const char *type, Vector< Handle< Object > > args)
Definition: factory.cc:625
void RemoveMemoryAllocationCallback(MemoryAllocationCallback callback)
Definition: spaces.cc:679
V8EXPORT bool IsUint32() const
Definition: api.cc:2214
static Local< StackTrace > StackTraceToLocal(v8::internal::Handle< v8::internal::JSArray > obj)
static bool SetDebugEventListener(EventCallback that, Handle< Value > data=Handle< Value >())
V8EXPORT int InternalFieldCount()
Definition: api.cc:4121
static bool HasSmiTag(internal::Object *value)
Definition: v8.h:3946
int GetChildrenCount() const
Definition: api.cc:6062
static void DeoptimizeGlobalObject(JSObject *object)
Definition: deoptimizer.cc:261
static bool AddMessageListener(MessageCallback that, Handle< Value > data=Handle< Value >())
Definition: api.cc:5130
#define UNREACHABLE()
Definition: checks.h:50
Handle< Value >(* InvocationCallback)(const Arguments &args)
Definition: v8.h:2017
static ScriptData * PreCompile(const char *input, int length)
Definition: api.cc:1455
Handle< Value >(* NamedPropertyGetter)(Local< String > property, const AccessorInfo &info)
Definition: v8.h:2023
Object * GetElementNoExceptionThrown(uint32_t index)
Definition: objects-inl.h:842
bool HasInstance(Handle< Value > object)
Definition: api.cc:4566
static void SetFlagsFromString(const char *str, int length)
Definition: api.cc:475
static void AddObjectGroup(Persistent< Value > *objects, size_t length, RetainedObjectInfo *info=NULL)
Definition: api.cc:5212
static Local< Message > MessageToLocal(v8::internal::Handle< v8::internal::Object > obj)
int max_old_space_size() const
Definition: v8.h:2609
static void EnsureDefaultIsolate()
Definition: isolate.cc:363
V8EXPORT void * Value() const
Definition: api.cc:4638
V8EXPORT Local< String > ObjectProtoToString()
Definition: api.cc:2980
T * start() const
Definition: utils.h:389
static V8EXPORT void DateTimeConfigurationChangeNotification()
Definition: api.cc:4934
static const CpuProfile * GetProfile(int index, Handle< Value > security_token=Handle< Value >())
Definition: api.cc:5930
static const HeapSnapshot * FindSnapshot(unsigned uid)
Definition: api.cc:6197
static Handle< Object > ToBoolean(Handle< Object > obj)
Definition: execution.cc:593
static void RemoveCallCompletedCallback(CallCompletedCallback callback)
Definition: api.cc:5314
void *(* CreateHistogramCallback)(const char *name, int min, int max, size_t buckets)
Definition: v8.h:2662
v8::internal::Object * get(int index)
Definition: api.cc:854
static Local< ObjectTemplate > New()
Definition: api.cc:1246
V8EXPORT bool HasIndexedPropertiesInPixelData()
Definition: api.cc:3404
void DetachGlobal()
Definition: api.cc:4479
#define ON_BAILOUT(isolate, location, code)
Definition: api.cc:72
void SetCallHandler(InvocationCallback callback, Handle< Value > data=Handle< Value >())
Definition: api.cc:1043
Handle< JSObject > NewNeanderObject()
Definition: factory.cc:605
int max_young_space_size() const
Definition: v8.h:2607
Handle< Value > ReThrow()
Definition: api.cc:1705
static void StopHeapObjectsTracking()
Definition: api.cc:6239
void RemoveGCEpilogueCallback(GCEpilogueCallback callback)
Definition: heap.cc:6267
static size_t GetMemorySizeUsedByProfiler()
static SlicedString * cast(Object *obj)
static void MemCopy(void *dest, const void *src, size_t size)
Definition: platform.h:314
StringTracker * string_tracker()
Definition: isolate.h:875
RuntimeProfiler * runtime_profiler()
Definition: isolate.h:811
SnapshotObjectId GetMaxSnapshotJSObjectId() const
Definition: api.cc:6157
Handle< Integer >(* NamedPropertyQuery)(Local< String > property, const AccessorInfo &info)
Definition: v8.h:2040
virtual int GetChunkSize()
Definition: v8.h:3800
V8EXPORT Local< Value > GetPrototype()
Definition: api.cc:2892
static void StartProfiling(Handle< String > title)
Definition: api.cc:5952
static void GetHeapStatistics(HeapStatistics *heap_statistics)
Definition: api.cc:4242
Handle< Object > Create(Object *value)
Handle< Map > CopyMapDropTransitions(Handle< Map > map)
Definition: factory.cc:499
static bool IsValid(intptr_t value)
Definition: objects-inl.h:1051
static Local< Uint32 > Uint32ToLocal(v8::internal::Handle< v8::internal::Object > obj)
void set_context(Context *context)
Definition: isolate.h:519
static int context_raw_size()
Definition: snapshot.h:61
static void SetHostDispatchHandler(HostDispatchHandler handler, int period=100)
void CollectAllAvailableGarbage(const char *gc_reason=NULL)
Definition: heap.cc:462
virtual Handle< Object > GetExecutionState() const =0
V8EXPORT bool ForceDelete(Handle< Value > key)
Definition: api.cc:2821
bool(* AllowCodeGenerationFromStringsCallback)(Local< Context > context)
Definition: v8.h:2707
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination trace on stack replacement optimize closures functions with arguments object optimize functions containing for in loops profiler considers IC stability primitive functions trigger their own optimization re try self optimization if it failed insert an interrupt check at function exit execution budget before interrupt is triggered call count before self optimization self_optimization count_based_interrupts weighted_back_edges trace_opt emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 enable use of ARMv7 instructions if enable use of MIPS FPU instructions if NULL
JSObject * global_proxy()
Definition: contexts.cc:78
static void EnterDefaultIsolate()
Definition: isolate.cc:399
Handle< String > GetTitle() const
Definition: api.cc:5898
int compressed_size
Definition: v8.h:2870
MemoryAllocator * memory_allocator()
Definition: isolate.h:830
V8EXPORT int Utf8Length() const
Definition: api.cc:3725
MaybeObject * scheduled_exception()
Definition: isolate.h:595
T * NewArray(size_t size)
Definition: allocation.h:83
void SetAccessor(Handle< String > name, AccessorGetter getter, AccessorSetter setter=0, Handle< Value > data=Handle< Value >(), AccessControl settings=DEFAULT, PropertyAttribute attribute=None, Handle< AccessorSignature > signature=Handle< AccessorSignature >())
Definition: api.cc:1284
Handle< Object > SetProperty(Handle< Object > object, Handle< Object > key, Handle< Object > value, PropertyAttributes attributes, StrictModeFlag strict_mode)
Definition: handles.cc:232
static void ResumeProfiler()
Definition: api.cc:5328
int * global_handle_count
Definition: heap.h:2082
void SetInternalFieldCount(int value)
Definition: api.cc:1431
unsigned int FastD2UI(double x)
int GetColumn() const
Definition: api.cc:2029
#define LOG_API(isolate, expr)
Definition: api.cc:62
static Isolate * New()
Definition: api.cc:5386
static void SetFatalErrorHandler(FatalErrorCallback that)
Definition: api.cc:454
V8EXPORT bool HasIndexedLookupInterceptor()
Definition: api.cc:3152
intptr_t * cell_space_capacity
Definition: heap.h:2080
intptr_t * memory_allocator_size
Definition: heap.h:2087
Handle< Integer >(* IndexedPropertyQuery)(uint32_t index, const AccessorInfo &info)
Definition: v8.h:2080
uintptr_t(* ReturnAddressLocationResolver)(uintptr_t return_addr_location)
Definition: v8.h:2917
void PrintCurrentStackTrace(FILE *out)
Definition: isolate.cc:962
Handle< String > LookupSymbol(Vector< const char > str)
Definition: factory.cc:161
static SnapshotObjectId PushHeapObjectsStats(OutputStream *stream)
Definition: api.cc:6246
static int ContextDisposedNotification()
Definition: api.cc:4284
Handle< JSArray > CaptureCurrentStackTrace(int frame_limit, StackTrace::StackTraceOptions options)
Definition: isolate.cc:542
static void TerminateExecution(int thread_id)
Definition: api.cc:5347
GlobalHandles * global_handles()
Definition: isolate.h:865
V8EXPORT int32_t Int32Value() const
Definition: api.cc:2654
static void RemoveCallCompletedCallback(CallCompletedCallback callback)
Definition: v8.cc:205
void(* AccessorSetter)(Local< String > property, Local< Value > value, const AccessorInfo &info)
Definition: v8.h:1428
V8EXPORT bool IsBoolean() const
Definition: api.cc:2181
V8EXPORT Local< Object > NewInstance() const
Definition: api.cc:3605
int InternalFieldCount()
Definition: api.cc:1422
static void TransformToFastProperties(Handle< JSObject > object, int unused_property_fields)
Definition: objects.cc:3352
intptr_t * code_space_capacity
Definition: heap.h:2076
bool IsConstructor() const
Definition: api.cc:2104
Local< Object > Global()
Definition: api.cc:4467
int raw_size
Definition: v8.h:2871
Handle< String > NewStringFromTwoByte(Vector< const uc16 > str, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:216
Handle< ExternalArray > NewExternalArray(int length, ExternalArrayType array_type, void *external_pointer, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:427
static FunctionTemplateInfo * cast(Object *obj)
V8EXPORT void SetIndexedPropertiesToPixelData(uint8_t *data, int length)
Definition: api.cc:3384
Handle< FixedArray > NewFixedArray(int size, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:44
V8EXPORT void TurnOnAccessCheck()
Definition: api.cc:3214
int length() const
Definition: utils.h:383
static void PrintCurrentStackTrace(FILE *out)
Definition: api.cc:1958
v8::ImplementationUtilities::HandleScopeData * handle_scope_data()
Definition: isolate.h:846
static void SetStressRunType(StressType type)
Definition: api.cc:6282
V8EXPORT int GetScriptColumnNumber() const
Definition: api.cc:3701
bool ConfigureHeap(int max_semispace_size, intptr_t max_old_gen_size, intptr_t max_executable_size)
Definition: heap.cc:5722
intptr_t * map_space_size
Definition: heap.h:2077
Handle< FixedArray > GetKeysInFixedArrayFor(Handle< JSReceiver > object, KeyCollectionType type, bool *threw)
Definition: handles.cc:600
void Enter()
Definition: api.cc:5403
static void RemoveMessageListeners(MessageCallback that)
Definition: api.cc:5147
GCType
Definition: v8.h:2718
static MUST_USE_RESULT Handle< Object > SetElement(Handle< JSObject > object, uint32_t index, Handle< Object > value, PropertyAttributes attr, StrictModeFlag strict_mode, SetPropertyMode set_mode=SET_PROPERTY)
Definition: objects.cc:9663
V8EXPORT bool Has(Handle< String > key)
Definition: api.cc:3056
static ExternalPixelArray * cast(Object *obj)
static bool IsProfilerPaused()
Definition: api.cc:5334
static const char * GetVersion()
Definition: version.h:49
void(* AddHistogramSampleCallback)(void *histogram, int sample)
Definition: v8.h:2667
static Handle< JSRegExp > NewJSRegExp(Handle< String > pattern, Handle< String > flags, bool *exc)
Definition: execution.cc:654
static Local< Integer > IntegerToLocal(v8::internal::Handle< v8::internal::Object > obj)
V8EXPORT bool SetHiddenValue(Handle< String > key, Handle< Value > value)
Definition: api.cc:3286
intptr_t AdjustAmountOfExternalAllocatedMemory(intptr_t change_in_bytes)
Definition: heap-inl.h:463
V8EXPORT Local< String > ToDetailString() const
Definition: api.cc:2325
virtual Handle< String > GetJSON() const =0
static Handle< String > GetMessage(Handle< Object > data)
Definition: messages.cc:144
int max_executable_size()
Definition: v8.h:2611
static void SetWrapperClassId(Object **location, uint16_t class_id)
static Local< T > New(Handle< T > that)
Definition: v8.h:4030
Local< String > GetScriptNameOrSourceURL() const
Definition: api.cc:2061
double FastUI2D(unsigned x)
Definition: conversions.h:81
static Handle< Object > NewDate(double time, bool *exc)
Definition: execution.cc:645
V8EXPORT bool HasNamedLookupInterceptor()
Definition: api.cc:3144
Handle< JSBuiltinsObject > js_builtins_object()
Definition: isolate.h:646
static int GetIdentityHash(Handle< JSObject > obj)
Definition: objects.cc:3491
Definition: v8.h:104
V8EXPORT bool BooleanValue() const
Definition: api.cc:2532
static void UnregisterAll()
Definition: api.cc:515
uint32_t * stack_limit() const
Definition: v8.h:2613
static bool EnableAgent(const char *name, int port, bool wait_for_connection=false)
Handle< Object > ToObject(Handle< Object > object)
Definition: factory.cc:1222
static Local< Context > GetCalling()
Definition: api.cc:4454
V8EXPORT bool SetPrototype(Handle< Value > prototype)
Definition: api.cc:2903
void EnableSlidingStateWindow()
Definition: log.cc:1716
NeanderObject(int size)
Definition: api.cc:829
void(* WeakReferenceCallback)(Persistent< Value > object, void *parameter)
Definition: v8.h:137
int GetLineNumber() const
Definition: api.cc:1865
V8EXPORT bool IsFunction() const
Definition: api.cc:2147
static Local< Value > RangeError(Handle< String > message)
Definition: api.cc:5478
int * free_global_handle_count
Definition: heap.h:2086
static void SetMessageHandler(MessageHandler handler, bool message_handler_thread=false)
void(* MessageHandler)(const uint16_t *message, int length, ClientData *client_data)
Definition: v8-debug.h:224
Handle< Boolean > V8EXPORT False()
Definition: api.cc:576
void SetHiddenPrototype(bool value)
Definition: api.cc:1140
Definition: v8.h:592
Handle< FixedArray > CopyFixedArray(Handle< FixedArray > array)
Definition: factory.cc:516
static Handle< Object > Call(Handle< Object > callable, Handle< Object > receiver, int argc, Handle< Object > argv[], bool *pending_exception, bool convert_receiver=false)
Definition: execution.cc:144
static void DeleteAllSnapshots()
static SnapshotObjectId GetSnapshotObjectId(Handle< Object > obj)
Vector< const char > CStrVector(const char *data)
Definition: utils.h:525
static unsigned Encode(char *out, uchar c, int previous)
Definition: unicode-inl.h:81
int StrLength(const char *string)
Definition: utils.h:234
static Local< Context > ToLocal(v8::internal::Handle< v8::internal::Context > obj)
void SetNamedPropertyHandler(NamedPropertyGetter getter, NamedPropertySetter setter=0, NamedPropertyQuery query=0, NamedPropertyDeleter deleter=0, NamedPropertyEnumerator enumerator=0, Handle< Value > data=Handle< Value >())
Definition: api.cc:1309
intptr_t CommittedMemory()
Definition: heap.cc:197
intptr_t SizeOfObjects()
Definition: heap.cc:410
static void AddCallCompletedCallback(CallCompletedCallback callback)
Definition: api.cc:5305
RegisteredExtension(Extension *extension)
Definition: api.cc:505
Handle< Context > CreateEnvironment(Isolate *isolate, Handle< Object > global_object, v8::Handle< v8::ObjectTemplate > global_template, v8::ExtensionConfiguration *extensions)
Local< String > GetScriptName() const
Definition: api.cc:2045
V8EXPORT int64_t IntegerValue() const
Definition: api.cc:2567
Handle< JSArray > NewJSArrayWithElements(Handle< FixedArrayBase > elements, ElementsKind elements_kind=TERMINAL_FAST_ELEMENTS_KIND, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:1019
Context * context()
Definition: isolate.h:518
bool CanContinue() const
Definition: api.cc:1700
static SeqTwoByteString * cast(Object *obj)
V8EXPORT bool IsObject() const
Definition: api.cc:2169
void(* GCEpilogueCallback)(GCType type, GCCallbackFlags flags)
Definition: v8.h:2730
V8EXPORT void SetName(Handle< String > name)
Definition: api.cc:3653
#define EXCEPTION_PREAMBLE(isolate)
Definition: api.cc:80
Handle< Object > NewNumberFromInt(int32_t value, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:589
V8EXPORT double Value() const
Definition: api.cc:4074
bool IsCodeGenerationFromStringsAllowed()
Definition: api.cc:4517
static Local< Value > ReferenceError(Handle< String > message)
Definition: api.cc:5494
Local< Value > StackTrace() const
Definition: api.cc:1724
bool IsFreshUnusedString(Handle< String > string)
Definition: api.h:349
static void SetMessageHandler2(MessageHandler2 handler)
static V8EXPORT v8::Local< v8::String > Empty()
Definition: api.cc:4645
int GetScriptLineNumber(Handle< Script > script, int code_pos)
Definition: handles.cc:479
intptr_t * old_data_space_capacity
Definition: heap.h:2074
static void StopHeapObjectsTracking()
static Handle< JSFunction > InstantiateFunction(Handle< FunctionTemplateInfo > data, bool *exc)
Definition: execution.cc:697
V8EXPORT Local< Value > CallAsFunction(Handle< Object > recv, int argc, Handle< Value > argv[])
Definition: api.cc:3536
int GetEndPosition() const
Definition: api.cc:1891
const CpuProfileNode * GetTopDownRoot() const
Definition: api.cc:5915
V8EXPORT bool IsDate() const
Definition: api.cc:2231
static Local< Context > GetEntered()
Definition: api.cc:4429
void add(v8::internal::Handle< v8::internal::Object > value)
Definition: api.cc:866
Handle< Integer > ResourceColumnOffset() const
Definition: v8.h:4165
static int NumberOfHandles()
Definition: api.cc:712
static void WriteToFlat(String *source, sinkchar *sink, int from, int to)
Definition: objects.cc:6819
V8EXPORT int GetIndexedPropertiesExternalArrayDataLength()
Definition: api.cc:3512
static internal::Object ** CreateHandle(internal::Object *value)
Definition: api.cc:719
static size_t GetMemorySizeUsedByProfiler()
Definition: api.cc:6273
Handle< String > NewExternalStringFromTwoByte(const ExternalTwoByteString::Resource *resource)
Definition: factory.cc:279
V8EXPORT uint32_t Uint32Value() const
Definition: api.cc:2735
static double nan_value()
static Local< AccessorSignature > New(Handle< FunctionTemplate > receiver=Handle< FunctionTemplate >())
Definition: api.cc:993
static void * GetExternalPointerFromSmi(internal::Object *value)
Definition: v8.h:3965
static void SetDebugMessageDispatchHandler(DebugMessageDispatchHandler handler, bool provide_locker=false)
int * weak_global_handle_count
Definition: heap.h:2083
void Continue(InterruptFlag after_what)
Definition: execution.cc:488
void Exit()
Definition: api.cc:744
static void SetEntropySource(EntropySource source)
Definition: api.cc:4213
bool is_null() const
Definition: handles.h:87
Handle< Object > NewReferenceError(const char *type, Vector< Handle< Object > > args)
Definition: factory.cc:646
void SetGlobalGCEpilogueCallback(GCCallback callback)
Definition: heap.h:1114
V8EXPORT bool IsNumber() const
Definition: api.cc:2175
static void CancelDebugBreak(Isolate *isolate=NULL)
void DetachGlobal(Handle< Context > env)
Type GetType() const
Definition: api.cc:6105
void ReattachGlobal(Handle< Context > env, Handle< Object > global_object)
Handle< String > GetTitle() const
Definition: api.cc:6119
uint32_t SnapshotObjectId
Definition: v8-profiler.h:67
void FatalProcessOutOfMemory(const char *message)
ExternalStringTable * external_string_table()
Definition: heap.h:1539
static void DeleteAllProfiles()
Definition: api.cc:5970
V8EXPORT Local< String > StringValue() const
Definition: api.cc:4894
Local< Function > GetFunction()
Definition: api.cc:4551
static Handle< Object > DeleteProperty(Handle< JSObject > obj, Handle< String > name)
Definition: objects.cc:3827
V8EXPORT bool ForceSet(Handle< Value > key, Handle< Value > value, PropertyAttribute attribs=None)
Definition: api.cc:2799
V8EXPORT bool Delete(Handle< String > key)
Definition: api.cc:3045
static int GetCurrentThreadId()
Definition: api.cc:5340
static void set_raw_data(const byte *raw_data)
Definition: snapshot.h:56
int GetNodesCount() const
Definition: api.cc:6142
static Local< Value > SyntaxError(Handle< String > message)
Definition: api.cc:5511
Handle< Object > NewTypeError(const char *type, Vector< Handle< Object > > args)
Definition: factory.cc:614
static ThreadId FromInteger(int id)
Definition: isolate.h:174
static void AddCallCompletedCallback(CallCompletedCallback callback)
Definition: v8.cc:194
static Handle< Object > GetFunctionDelegate(Handle< Object > object)
Definition: execution.cc:223
static Handle< SharedFunctionInfo > Compile(Handle< String > source, Handle< Object > script_name, int line_offset, int column_offset, v8::Extension *extension, ScriptDataImpl *pre_data, Handle< Object > script_data, NativesFlag is_natives_code)
Definition: compiler.cc:473
int GetChildrenCount() const
Definition: api.cc:5863
V8EXPORT Local< Object > Clone()
Definition: api.cc:3237
static void DisableAgent()
#define EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, value)
Definition: api.cc:106
static int context_size()
Definition: snapshot.h:60
i::Handle< i::String > NewExternalStringHandle(i::Isolate *isolate, v8::String::ExternalStringResource *resource)
Definition: api.cc:4731
const HeapGraphNode * GetRoot() const
Definition: api.cc:6127
static bool SetDebugEventListener2(EventCallback2 that, Handle< Value > data=Handle< Value >())
V8EXPORT bool SetAccessor(Handle< String > name, AccessorGetter getter, AccessorSetter setter=0, Handle< Value > data=Handle< Value >(), AccessControl settings=DEFAULT, PropertyAttribute attribute=None)
Definition: api.cc:3085
V8EXPORT int GetIndexedPropertiesPixelDataLength()
Definition: api.cc:3425
bool(* NamedSecurityCallback)(Local< Object > host, Local< Value > key, AccessType type, Local< Value > data)
Definition: v8.h:2114
static void RemoveMemoryAllocationCallback(MemoryAllocationCallback callback)
Definition: api.cc:5297
Local< ObjectTemplate > PrototypeTemplate()
Definition: api.cc:920
Handle< Foreign > NewForeign(Address addr, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:406
V8EXPORT bool IsFalse() const
Definition: api.cc:2141
const int kHandleBlockSize
Definition: api.h:491
V8EXPORT Flags GetFlags() const
Definition: api.cc:5017
void set(int index, v8::internal::Object *value)
Definition: api.h:113
MUST_USE_RESULT MaybeObject * GetProperty(String *key)
Definition: objects-inl.h:851
#define ASSERT_EQ(v1, v2)
Definition: checks.h:271
void MarkAsUndetectable()
Definition: api.cc:1334
static void SetReturnAddressLocationResolver(ReturnAddressLocationResolver resolver)
Definition: v8.cc:161
static Local< Value > TypeError(Handle< String > message)
Definition: api.cc:5527
static int GetProfilesCount()
Definition: api.cc:5923
static void TearDown()
Definition: v8.cc:103
bool(* EntropySource)(unsigned char *buffer, size_t length)
Definition: v8.h:2904
static Local< Signature > New(Handle< FunctionTemplate > receiver=Handle< FunctionTemplate >(), int argc=0, Handle< FunctionTemplate > argv[]=0)
Definition: api.cc:970
static void Register(RegisteredExtension *that)
Definition: api.cc:509
static void SetGlobalGCPrologueCallback(GCCallback)
Definition: api.cc:5245
static Handle< Object > ToNumber(Handle< Object > obj, bool *exc)
Definition: execution.cc:609
void USE(T)
Definition: globals.h:303
void set_ignore_out_of_memory(bool value)
Definition: isolate.h:691
static V8EXPORT Local< Integer > New(int32_t value)
Definition: api.cc:5100
V8EXPORT int GetScriptLineNumber() const
Definition: api.cc:3691
static Handle< JSObject > InstantiateObject(Handle< ObjectTemplateInfo > data, bool *exc)
Definition: execution.cc:719
static void StartProfiling(const char *title)
static void RemoveGCEpilogueCallback(GCEpilogueCallback callback)
Definition: api.cc:5280
static void PrepareStressRun(int run)
Definition: api.cc:6303
Handle< StackTrace > GetStackTrace() const
Definition: api.cc:1819
V8EXPORT int64_t Value() const
Definition: api.cc:4088
void(* MessageCallback)(Handle< Message > message, Handle< Value > data)
Definition: v8.h:2633
static void SetCreateHistogramFunction(CreateHistogramCallback)
Definition: api.cc:5183
Local< T > Close(Handle< T > value)
Definition: v8.h:4149
V8EXPORT bool IsNumberObject() const
Definition: api.cc:2247
void MarkIndependent(Object **location)
static FixedArray * cast(Object *obj)
V8EXPORT int WriteAscii(char *buffer, int start=0, int length=-1, int options=NO_OPTIONS) const
Definition: api.cc:3960
static Local< Value > Call(v8::Handle< v8::Function > fun, Handle< Value > data=Handle< Value >())
static bool IsWeak(Object **location)
void Delete()
Definition: api.cc:5879
static void RemoveGCPrologueCallback(GCPrologueCallback callback)
Definition: api.cc:5266
Failure * TerminateExecution()
Definition: isolate.cc:912
static bool ReportApiFailure(const char *location, const char *message)
Definition: api.cc:219
Handle< Primitive > V8EXPORT Undefined()
Definition: api.cc:546
V8EXPORT Local< Value > GetRealNamedPropertyInPrototypeChain(Handle< String > key)
Definition: api.cc:3183
const size_t num_flags
Definition: flags.cc:178
static void EnableSlidingStateWindow()
Definition: api.cc:5196
static V8EXPORT Local< Number > New(double value)
Definition: api.cc:5087
void SetCreateHistogramFunction(CreateHistogramCallback f)
Definition: counters.h:51
intptr_t * old_pointer_space_capacity
Definition: heap.h:2072
ObjectSpace
Definition: v8.h:2670
static Handle< Object > GetElement(Handle< Object > object, uint32_t index)
Definition: objects.cc:244
static HeapSnapshot * FindSnapshot(unsigned uid)
bool IsEmpty() const
Definition: v8.h:208
Local< Value > Run()
Definition: api.cc:1590
#define FACTORY
Definition: isolate.h:1409
static V8EXPORT Local< String > Concat(Handle< String > left, Handle< String > right)
Definition: api.cc:4669
V8EXPORT double NumberValue() const
Definition: api.cc:4851
Logger * logger()
Definition: isolate.h:813
double FastI2D(int x)
Definition: conversions.h:73
V8EXPORT bool HasOwnProperty(Handle< String > key)
Definition: api.cc:3107
i::Handle< i::String > NewExternalAsciiStringHandle(i::Isolate *isolate, v8::String::ExternalAsciiStringResource *resource)
Definition: api.cc:4739
static int GetPersistentHandleCount()
Definition: api.cc:6267
Handle< Context > GetCallingGlobalContext()
Definition: isolate.cc:1324
void Reset(Input input)
Definition: unicode-inl.h:231
Object * get(int index)
Definition: objects-inl.h:1675
static Handle< Object > ToString(Handle< Object > obj, bool *exc)
Definition: execution.cc:614
static void DeleteAllProfiles()
Handle< Value > GetHeapValue() const
Definition: api.cc:6077
void RecordStats(HeapStats *stats, bool take_snapshot=false)
Definition: heap.cc:5799
unsigned GetUid() const
Definition: api.cc:5891
static Persistent< Context > New(ExtensionConfiguration *extensions=NULL, Handle< ObjectTemplate > global_template=Handle< ObjectTemplate >(), Handle< Value > global_object=Handle< Value >())
Definition: api.cc:4308
void RegisterTryCatchHandler(v8::TryCatch *that)
Definition: isolate.cc:481
bool IsInstanceOf(FunctionTemplateInfo *type)
Definition: objects-inl.h:136
bool IsInGCPostProcessing()
Definition: heap.h:1282
Type GetType() const
Definition: api.cc:6033
static Local< StackTrace > CurrentStackTrace(int frame_limit, StackTraceOptions options=kOverview)
Definition: api.cc:1998
static Local< TypeSwitch > New(Handle< FunctionTemplate > type)
Definition: api.cc:999
V8EXPORT Local< Object > ToObject() const
Definition: api.cc:2345
V8EXPORT bool IsArray() const
Definition: api.cc:2163
bool IsProfilerPaused()
Definition: log.cc:1271
const uintptr_t kEncodablePointerMask
Definition: v8.h:3901
Handle< Struct > NewStruct(InstanceType type)
Definition: factory.cc:350
bool has_scheduled_exception()
Definition: isolate.h:599
static bool IsLeadSurrogate(int code)
Definition: unicode.h:120
static void LowMemoryNotification()
Definition: api.cc:4277
V8EXPORT uint32_t Length() const
Definition: api.cc:5040
Handle< Object > ForceSetProperty(Handle< JSObject > object, Handle< Object > key, Handle< Object > value, PropertyAttributes attributes)
Definition: handles.cc:246
const char * name_
Definition: flags.cc:1352
static ScriptData * New(const char *data, int length)
Definition: api.cc:1475
static const CpuProfile * StopProfiling(Handle< String > title, Handle< Value > security_token=Handle< Value >())
Definition: api.cc:5959
V8EXPORT Local< Boolean > ToBoolean() const
Definition: api.cc:2365
StringInputBuffer * write_input_buffer()
Definition: isolate.h:863
V8EXPORT Local< Integer > ToInteger() const
Definition: api.cc:2402
static void SendCommand(const uint16_t *command, int length, ClientData *client_data=NULL, Isolate *isolate=NULL)
intptr_t * map_space_capacity
Definition: heap.h:2078
static bool IsTrailSurrogate(int code)
Definition: unicode.h:124
static void SetFlagsFromCommandLine(int *argc, char **argv, bool remove_flags)
Definition: api.cc:480
static V8EXPORT Local< External > New(void *value)
Definition: api.cc:4628
static void DebugBreak(Isolate *isolate=NULL)
static const HeapSnapshot * GetSnapshot(int index)
Definition: api.cc:6189
void Delete()
Definition: api.cc:6093
AsciiValue(Handle< v8::Value > obj)
Definition: api.cc:5437
Handle< Boolean >(* IndexedPropertyDeleter)(uint32_t index, const AccessorInfo &info)
Definition: v8.h:2088
void MakeWeak(Object **location, void *parameter, WeakReferenceCallback callback)
V8EXPORT bool IsInt32() const
Definition: api.cc:2197
Handle< Object > SetPrototype(Handle< JSFunction > function, Handle< Object > prototype)
Definition: handles.cc:221
V8EXPORT bool HasRealNamedProperty(Handle< String > key)
Definition: api.cc:3116
#define STATIC_ASSERT(test)
Definition: checks.h:283
static void StartHeapObjectsTracking()
Definition: api.cc:6232
unsigned GetUid() const
Definition: api.cc:6112
static void StartHeapObjectsTracking()
static V8EXPORT Local< String > NewExternal(ExternalStringResource *resource)
Definition: api.cc:4747
static Local< Value > GetMirror(v8::Handle< v8::Value > obj)
void DeleteArray(T *array)
Definition: allocation.h:91
bool V8EXPORT SetResourceConstraints(ResourceConstraints *constraints)
Definition: api.cc:593
intptr_t * memory_allocator_capacity
Definition: heap.h:2088
int GetStartColumn() const
Definition: api.cc:1902
V8EXPORT Handle< Value > GetInferredName() const
Definition: api.cc:3668
static ConsString * cast(Object *obj)
static Handle< Object > TryGetConstructorDelegate(Handle< Object > object, bool *has_pending_exception)
Definition: execution.cc:307
#define FUNCTION_ADDR(f)
Definition: globals.h:307
V8EXPORT Local< Object > FindInstanceInPrototypeChain(Handle< FunctionTemplate > tmpl)
Definition: api.cc:2920
static bool Initialize(const char *snapshot_file=NULL)
void SetStackLimit(uintptr_t limit)
Definition: execution.cc:357
CompressedStartupDataItems
Definition: api.cc:377
static FixedArrayBase * cast(Object *object)
Definition: objects-inl.h:1669
Handle< Value > V8EXPORT ThrowException(Handle< Value > exception)
Definition: api.cc:485
static SnapshotObjectId GetSnapshotObjectId(Handle< Value > value)
Definition: api.cc:6205
Handle< String > NewConsString(Handle< String > first, Handle< String > second)
Definition: factory.cc:243
static const int kMaxValue
Definition: objects.h:1006
static StartupData::CompressionAlgorithm GetCompressedStartupDataAlgorithm()
Definition: api.cc:368
intptr_t * old_data_space_size
Definition: heap.h:2073
virtual ~StartupDataDecompressor()
Definition: api.cc:335
void Reset()
Definition: api.cc:1753
void ReadOnlyPrototype()
Definition: api.cc:1150
static void DeoptimizeAll()
Definition: api.cc:6338
const HeapGraphNode * GetToNode() const
Definition: api.cc:6019
Handle< Value > GetSecurityToken()
Definition: api.cc:4406
Handle< Array >(* IndexedPropertyEnumerator)(const AccessorInfo &info)
Definition: v8.h:2095
static void FatalProcessOutOfMemory(const char *location, bool take_snapshot=false)
V8EXPORT int32_t Value() const
Definition: api.cc:4099
Handle< Value >(* AccessorGetter)(Local< String > property, const AccessorInfo &info)
Definition: v8.h:1424
#define ARRAY_SIZE(a)
Definition: globals.h:295
static void ProcessDebugMessages()
static int raw_size()
Definition: snapshot.h:55
Definition: v8.h:105
const int kCharSize
Definition: globals.h:229
static const byte * context_data()
Definition: snapshot.h:59
int match(Handle< Value > value)
Definition: api.cc:1022
static void PauseProfiler()
Definition: api.cc:5322
void Serialize(OutputStream *stream, SerializationFormat format) const
Definition: api.cc:6164
Local< v8::Message > Message() const
Definition: api.cc:1742
V8EXPORT int Write(uint16_t *buffer, int start=0, int length=-1, int options=NO_OPTIONS) const
Definition: api.cc:3994
static Handle< Object > TryGetFunctionDelegate(Handle< Object > object, bool *has_pending_exception)
Definition: execution.cc:250
AccessControl
Definition: v8.h:1446
void Inherit(Handle< FunctionTemplate > parent)
Definition: api.cc:935
static HeapSnapshot * TakeSnapshot(const char *name, int type, v8::ActivityControl *control)
PropertyAttribute
Definition: v8.h:1400
static void AddImplicitReferences(Persistent< Object > parent, Persistent< Value > *children, size_t length)
Definition: api.cc:5223
static JSObject * cast(Object *obj)
static bool Initialize()
Definition: api.cc:4204
FlagType type() const
Definition: flags.cc:1358
static void SetRawScriptsSource(Vector< const char > raw_source)
Local< String > GetFunctionName() const
Definition: api.cc:2077
Local< String > GetSourceLine() const
Definition: api.cc:1940
static V8EXPORT Local< Object > New()
Definition: api.cc:4829
int FastD2I(double x)
Definition: conversions.h:64
static const int kNoPreviousCharacter
Definition: unicode.h:132
static void SetCounterFunction(CounterLookupCallback)
Definition: api.cc:5177
v8::internal::Object * get(int index)
Definition: api.h:107
V8EXPORT Local< Uint32 > ToArrayIndex() const
Definition: api.cc:2625
Handle< T > CloseAndEscape(Handle< T > handle_value)
Definition: handles-inl.h:113
void AddMemoryAllocationCallback(MemoryAllocationCallback callback, ObjectSpace space, AllocationAction action)
Definition: spaces.cc:668
Handle< Object > NewError(const char *maker, const char *type, Handle< JSArray > args)
Definition: factory.cc:719
int size()
Definition: api.cc:839
int GetLineNumber() const
Definition: api.cc:5821
static void SetGlobalGCEpilogueCallback(GCCallback)
Definition: api.cc:5252
static void DeleteExtensions(Isolate *isolate)
Definition: handles.cc:99
V8EXPORT uint32_t Value() const
Definition: api.cc:4110
static v8::internal::Handle< v8::internal::TemplateInfo > OpenHandle(const Template *that)
V8EXPORT int GetIdentityHash()
Definition: api.cc:3276
static T ** CreateHandle(T *value, Isolate *isolate)
Definition: handles-inl.h:132
virtual OutputEncoding GetOutputEncoding()
Definition: v8.h:3802
void SetAccessCheckCallbacks(NamedSecurityCallback named_handler, IndexedSecurityCallback indexed_handler, Handle< Value > data=Handle< Value >(), bool turned_on_by_default=true)
Definition: api.cc:1347
Handle< Boolean >(* NamedPropertyDeleter)(Local< String > property, const AccessorInfo &info)
Definition: v8.h:2049
V8EXPORT bool Value() const
Definition: api.cc:4081
V8EXPORT bool Set(Handle< Value > key, Handle< Value > value, PropertyAttribute attribs=None)
Definition: api.cc:2757
double GetTotalSamplesCount() const
Definition: api.cc:5842
int GetFrameCount() const
Definition: api.cc:1982
Handle< JSObject > Copy(Handle< JSObject > obj)
Definition: handles.cc:335
static bool IdleNotification(int hint=1000)
Definition: api.cc:4268
V8EXPORT double NumberValue() const
Definition: api.cc:4924
static v8::Testing::StressType stress_type()
Definition: api.h:564
static void IgnoreOutOfMemoryException()
Definition: api.cc:5125
static JSFunction * cast(Object *obj)