v8  3.25.30(node0.11.13)
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 <string.h> // For memcpy, strlen.
31 #include <cmath> // For isnan.
32 #include "../include/v8-debug.h"
33 #include "../include/v8-profiler.h"
34 #include "../include/v8-testing.h"
35 #include "assert-scope.h"
36 #include "bootstrapper.h"
37 #include "code-stubs.h"
38 #include "compiler.h"
39 #include "conversions-inl.h"
40 #include "counters.h"
41 #include "cpu-profiler.h"
42 #include "debug.h"
43 #include "deoptimizer.h"
44 #include "execution.h"
45 #include "global-handles.h"
46 #include "heap-profiler.h"
48 #include "icu_util.h"
49 #include "json-parser.h"
50 #include "messages.h"
51 #ifdef COMPRESS_STARTUP_DATA_BZ2
52 #include "natives.h"
53 #endif
54 #include "parser.h"
55 #include "platform.h"
56 #include "platform/time.h"
57 #include "profile-generator-inl.h"
58 #include "property-details.h"
59 #include "property.h"
60 #include "runtime.h"
61 #include "runtime-profiler.h"
63 #include "snapshot.h"
64 #include "unicode-inl.h"
66 #include "v8threads.h"
67 #include "version.h"
68 #include "vm-state-inl.h"
69 
70 
71 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr))
72 
73 #define ENTER_V8(isolate) \
74  ASSERT((isolate)->IsInitialized()); \
75  i::VMState<i::OTHER> __state__((isolate))
76 
77 namespace v8 {
78 
79 #define ON_BAILOUT(isolate, location, code) \
80  if (IsExecutionTerminatingCheck(isolate)) { \
81  code; \
82  UNREACHABLE(); \
83  }
84 
85 
86 #define EXCEPTION_PREAMBLE(isolate) \
87  (isolate)->handle_scope_implementer()->IncrementCallDepth(); \
88  ASSERT(!(isolate)->external_caught_exception()); \
89  bool has_pending_exception = false
90 
91 
92 #define EXCEPTION_BAILOUT_CHECK_GENERIC(isolate, value, do_callback) \
93  do { \
94  i::HandleScopeImplementer* handle_scope_implementer = \
95  (isolate)->handle_scope_implementer(); \
96  handle_scope_implementer->DecrementCallDepth(); \
97  if (has_pending_exception) { \
98  bool call_depth_is_zero = handle_scope_implementer->CallDepthIsZero(); \
99  (isolate)->OptionalRescheduleException(call_depth_is_zero); \
100  do_callback \
101  return value; \
102  } \
103  do_callback \
104  } while (false)
105 
106 
107 #define EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, value) \
108  EXCEPTION_BAILOUT_CHECK_GENERIC( \
109  isolate, value, i::V8::FireCallCompletedCallback(isolate);)
110 
111 
112 #define EXCEPTION_BAILOUT_CHECK(isolate, value) \
113  EXCEPTION_BAILOUT_CHECK_GENERIC(isolate, value, ;)
114 
115 
116 // --- E x c e p t i o n B e h a v i o r ---
117 
118 
119 void i::FatalProcessOutOfMemory(const char* location) {
120  i::V8::FatalProcessOutOfMemory(location, false);
121 }
122 
123 
124 // When V8 cannot allocated memory FatalProcessOutOfMemory is called.
125 // The default fatal error handler is called and execution is stopped.
126 void i::V8::FatalProcessOutOfMemory(const char* location, bool take_snapshot) {
128  int start_marker;
129  heap_stats.start_marker = &start_marker;
130  int new_space_size;
131  heap_stats.new_space_size = &new_space_size;
132  int new_space_capacity;
133  heap_stats.new_space_capacity = &new_space_capacity;
134  intptr_t old_pointer_space_size;
135  heap_stats.old_pointer_space_size = &old_pointer_space_size;
136  intptr_t old_pointer_space_capacity;
137  heap_stats.old_pointer_space_capacity = &old_pointer_space_capacity;
138  intptr_t old_data_space_size;
139  heap_stats.old_data_space_size = &old_data_space_size;
140  intptr_t old_data_space_capacity;
141  heap_stats.old_data_space_capacity = &old_data_space_capacity;
142  intptr_t code_space_size;
143  heap_stats.code_space_size = &code_space_size;
144  intptr_t code_space_capacity;
145  heap_stats.code_space_capacity = &code_space_capacity;
146  intptr_t map_space_size;
147  heap_stats.map_space_size = &map_space_size;
148  intptr_t map_space_capacity;
149  heap_stats.map_space_capacity = &map_space_capacity;
150  intptr_t cell_space_size;
151  heap_stats.cell_space_size = &cell_space_size;
152  intptr_t cell_space_capacity;
153  heap_stats.cell_space_capacity = &cell_space_capacity;
154  intptr_t property_cell_space_size;
155  heap_stats.property_cell_space_size = &property_cell_space_size;
156  intptr_t property_cell_space_capacity;
157  heap_stats.property_cell_space_capacity = &property_cell_space_capacity;
158  intptr_t lo_space_size;
159  heap_stats.lo_space_size = &lo_space_size;
160  int global_handle_count;
161  heap_stats.global_handle_count = &global_handle_count;
162  int weak_global_handle_count;
163  heap_stats.weak_global_handle_count = &weak_global_handle_count;
164  int pending_global_handle_count;
165  heap_stats.pending_global_handle_count = &pending_global_handle_count;
166  int near_death_global_handle_count;
167  heap_stats.near_death_global_handle_count = &near_death_global_handle_count;
168  int free_global_handle_count;
169  heap_stats.free_global_handle_count = &free_global_handle_count;
170  intptr_t memory_allocator_size;
171  heap_stats.memory_allocator_size = &memory_allocator_size;
172  intptr_t memory_allocator_capacity;
173  heap_stats.memory_allocator_capacity = &memory_allocator_capacity;
174  int objects_per_type[LAST_TYPE + 1] = {0};
175  heap_stats.objects_per_type = objects_per_type;
176  int size_per_type[LAST_TYPE + 1] = {0};
177  heap_stats.size_per_type = size_per_type;
178  int os_error;
179  heap_stats.os_error = &os_error;
180  int end_marker;
181  heap_stats.end_marker = &end_marker;
182  i::Isolate* isolate = i::Isolate::Current();
183  if (isolate->heap()->HasBeenSetUp()) {
184  // BUG(1718): Don't use the take_snapshot since we don't support
185  // HeapIterator here without doing a special GC.
186  isolate->heap()->RecordStats(&heap_stats, false);
187  }
188  Utils::ApiCheck(false, location, "Allocation failed - process out of memory");
189  // If the fatal error handler returns, we stop execution.
190  FATAL("API fatal error handler returned after process out of memory");
191 }
192 
193 
194 void Utils::ReportApiFailure(const char* location, const char* message) {
195  i::Isolate* isolate = i::Isolate::Current();
196  FatalErrorCallback callback = isolate->exception_behavior();
197  if (callback == NULL) {
198  i::OS::PrintError("\n#\n# Fatal error in %s\n# %s\n#\n\n",
199  location, message);
200  i::OS::Abort();
201  } else {
202  callback(location, message);
203  }
204  isolate->SignalFatalError();
205 }
206 
207 
208 bool V8::IsDead() {
209  i::Isolate* isolate = i::Isolate::Current();
210  return isolate->IsDead();
211 }
212 
213 
214 static inline bool IsExecutionTerminatingCheck(i::Isolate* isolate) {
215  if (!isolate->IsInitialized()) return false;
216  if (isolate->has_scheduled_exception()) {
217  return isolate->scheduled_exception() ==
218  isolate->heap()->termination_exception();
219  }
220  return false;
221 }
222 
223 
224 // --- S t a t i c s ---
225 
226 
227 static bool InitializeHelper(i::Isolate* isolate) {
228  // If the isolate has a function entry hook, it needs to re-build all its
229  // code stubs with entry hooks embedded, so let's deserialize a snapshot.
230  if (isolate == NULL || isolate->function_entry_hook() == NULL) {
232  return true;
233  }
234  return i::V8::Initialize(NULL);
235 }
236 
237 
238 static inline bool EnsureInitializedForIsolate(i::Isolate* isolate,
239  const char* location) {
240  return (isolate != NULL && isolate->IsInitialized()) ||
241  Utils::ApiCheck(InitializeHelper(isolate),
242  location,
243  "Error initializing V8");
244 }
245 
246 
247 // Some initializing API functions are called early and may be
248 // called on a thread different from static initializer thread.
249 // If Isolate API is used, Isolate::Enter() will initialize TLS so
250 // Isolate::Current() works. If it's a legacy case, then the thread
251 // may not have TLS initialized yet. However, in initializing APIs it
252 // may be too early to call EnsureInitialized() - some pre-init
253 // parameters still have to be configured.
254 static inline i::Isolate* EnterIsolateIfNeeded() {
255  i::Isolate* isolate = i::Isolate::UncheckedCurrent();
256  if (isolate != NULL)
257  return isolate;
258 
260  isolate = i::Isolate::Current();
261  return isolate;
262 }
263 
264 
266  : raw_data(i::NewArray<char*>(V8::GetCompressedStartupDataCount())) {
267  for (int i = 0; i < V8::GetCompressedStartupDataCount(); ++i) {
268  raw_data[i] = NULL;
269  }
270 }
271 
272 
274  for (int i = 0; i < V8::GetCompressedStartupDataCount(); ++i) {
275  i::DeleteArray(raw_data[i]);
276  }
277  i::DeleteArray(raw_data);
278 }
279 
280 
282  int compressed_data_count = V8::GetCompressedStartupDataCount();
283  StartupData* compressed_data =
284  i::NewArray<StartupData>(compressed_data_count);
285  V8::GetCompressedStartupData(compressed_data);
286  for (int i = 0; i < compressed_data_count; ++i) {
287  char* decompressed = raw_data[i] =
288  i::NewArray<char>(compressed_data[i].raw_size);
289  if (compressed_data[i].compressed_size != 0) {
290  int result = DecompressData(decompressed,
291  &compressed_data[i].raw_size,
292  compressed_data[i].data,
293  compressed_data[i].compressed_size);
294  if (result != 0) return result;
295  } else {
296  ASSERT_EQ(0, compressed_data[i].raw_size);
297  }
298  compressed_data[i].data = decompressed;
299  }
300  V8::SetDecompressedStartupData(compressed_data);
301  i::DeleteArray(compressed_data);
302  return 0;
303 }
304 
305 
307 #ifdef COMPRESS_STARTUP_DATA_BZ2
308  return StartupData::kBZip2;
309 #else
311 #endif
312 }
313 
314 
321 };
322 
323 
325 #ifdef COMPRESS_STARTUP_DATA_BZ2
327 #else
328  return 0;
329 #endif
330 }
331 
332 
334 #ifdef COMPRESS_STARTUP_DATA_BZ2
335  compressed_data[kSnapshot].data =
336  reinterpret_cast<const char*>(i::Snapshot::data());
337  compressed_data[kSnapshot].compressed_size = i::Snapshot::size();
338  compressed_data[kSnapshot].raw_size = i::Snapshot::raw_size();
339 
340  compressed_data[kSnapshotContext].data =
341  reinterpret_cast<const char*>(i::Snapshot::context_data());
342  compressed_data[kSnapshotContext].compressed_size =
345 
347  compressed_data[kLibraries].data =
348  reinterpret_cast<const char*>(libraries_source.start());
349  compressed_data[kLibraries].compressed_size = libraries_source.length();
351 
352  i::Vector<const i::byte> exp_libraries_source =
354  compressed_data[kExperimentalLibraries].data =
355  reinterpret_cast<const char*>(exp_libraries_source.start());
356  compressed_data[kExperimentalLibraries].compressed_size =
357  exp_libraries_source.length();
358  compressed_data[kExperimentalLibraries].raw_size =
360 #endif
361 }
362 
363 
364 void V8::SetDecompressedStartupData(StartupData* decompressed_data) {
365 #ifdef COMPRESS_STARTUP_DATA_BZ2
366  ASSERT_EQ(i::Snapshot::raw_size(), decompressed_data[kSnapshot].raw_size);
368  reinterpret_cast<const i::byte*>(decompressed_data[kSnapshot].data));
369 
371  decompressed_data[kSnapshotContext].raw_size);
373  reinterpret_cast<const i::byte*>(
374  decompressed_data[kSnapshotContext].data));
375 
377  decompressed_data[kLibraries].raw_size);
378  i::Vector<const char> libraries_source(
379  decompressed_data[kLibraries].data,
380  decompressed_data[kLibraries].raw_size);
381  i::Natives::SetRawScriptsSource(libraries_source);
382 
384  decompressed_data[kExperimentalLibraries].raw_size);
385  i::Vector<const char> exp_libraries_source(
386  decompressed_data[kExperimentalLibraries].data,
387  decompressed_data[kExperimentalLibraries].raw_size);
388  i::ExperimentalNatives::SetRawScriptsSource(exp_libraries_source);
389 #endif
390 }
391 
392 
394  i::Isolate* isolate = EnterIsolateIfNeeded();
395  isolate->set_exception_behavior(that);
396 }
397 
398 
401  i::Isolate* isolate = EnterIsolateIfNeeded();
402  isolate->set_allow_code_gen_callback(callback);
403 }
404 
405 
406 void V8::SetFlagsFromString(const char* str, int length) {
407  i::FlagList::SetFlagsFromString(str, length);
408 }
409 
410 
411 void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) {
412  i::FlagList::SetFlagsFromCommandLine(argc, argv, remove_flags);
413 }
414 
415 
416 RegisteredExtension* RegisteredExtension::first_extension_ = NULL;
417 
418 
420  : extension_(extension) { }
421 
422 
424  that->next_ = first_extension_;
425  first_extension_ = that;
426 }
427 
428 
430  RegisteredExtension* re = first_extension_;
431  while (re != NULL) {
432  RegisteredExtension* next = re->next();
433  delete re;
434  re = next;
435  }
436 }
437 
438 
440  RegisteredExtension* extension = new RegisteredExtension(that);
442 }
443 
444 
446  const char* source,
447  int dep_count,
448  const char** deps,
449  int source_length)
450  : name_(name),
451  source_length_(source_length >= 0 ?
452  source_length :
453  (source ? static_cast<int>(strlen(source)) : 0)),
454  source_(source, source_length_),
455  dep_count_(dep_count),
456  deps_(deps),
457  auto_enable_(false) {
458  CHECK(source != NULL || source_length_ == 0);
459 }
460 
461 
463  : max_young_space_size_(0),
464  max_old_space_size_(0),
465  max_executable_size_(0),
466  stack_limit_(NULL),
467  max_available_threads_(0) { }
468 
469 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory,
470  uint32_t number_of_processors) {
471  const int lump_of_memory = (i::kPointerSize / 4) * i::MB;
472 #if V8_OS_ANDROID
473  // Android has higher physical memory requirements before raising the maximum
474  // heap size limits since it has no swap space.
475  const uint64_t low_limit = 512ul * i::MB;
476  const uint64_t medium_limit = 1ul * i::GB;
477  const uint64_t high_limit = 2ul * i::GB;
478 #else
479  const uint64_t low_limit = 512ul * i::MB;
480  const uint64_t medium_limit = 768ul * i::MB;
481  const uint64_t high_limit = 1ul * i::GB;
482 #endif
483 
484  // The young_space_size should be a power of 2 and old_generation_size should
485  // be a multiple of Page::kPageSize.
486  if (physical_memory <= low_limit) {
487  set_max_young_space_size(2 * lump_of_memory);
488  set_max_old_space_size(128 * lump_of_memory);
489  set_max_executable_size(96 * lump_of_memory);
490  } else if (physical_memory <= medium_limit) {
491  set_max_young_space_size(8 * lump_of_memory);
492  set_max_old_space_size(256 * lump_of_memory);
493  set_max_executable_size(192 * lump_of_memory);
494  } else if (physical_memory <= high_limit) {
495  set_max_young_space_size(16 * lump_of_memory);
496  set_max_old_space_size(512 * lump_of_memory);
497  set_max_executable_size(256 * lump_of_memory);
498  } else {
499  set_max_young_space_size(16 * lump_of_memory);
500  set_max_old_space_size(700 * lump_of_memory);
501  set_max_executable_size(256 * lump_of_memory);
502  }
503 
504  set_max_available_threads(i::Max(i::Min(number_of_processors, 4u), 1u));
505 }
506 
507 
509  ResourceConstraints* constraints) {
510  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
511  int young_space_size = constraints->max_young_space_size();
512  int old_gen_size = constraints->max_old_space_size();
513  int max_executable_size = constraints->max_executable_size();
514  if (young_space_size != 0 || old_gen_size != 0 || max_executable_size != 0) {
515  // After initialization it's too late to change Heap constraints.
516  ASSERT(!isolate->IsInitialized());
517  bool result = isolate->heap()->ConfigureHeap(young_space_size / 2,
518  old_gen_size,
519  max_executable_size);
520  if (!result) return false;
521  }
522  if (constraints->stack_limit() != NULL) {
523  uintptr_t limit = reinterpret_cast<uintptr_t>(constraints->stack_limit());
524  isolate->stack_guard()->SetStackLimit(limit);
525  }
526 
527  isolate->set_max_available_threads(constraints->max_available_threads());
528  return true;
529 }
530 
531 
532 i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) {
533  LOG_API(isolate, "Persistent::New");
534  i::Handle<i::Object> result = isolate->global_handles()->Create(*obj);
535 #ifdef DEBUG
536  (*obj)->Verify();
537 #endif // DEBUG
538  return result.location();
539 }
540 
541 
542 i::Object** V8::CopyPersistent(i::Object** obj) {
544 #ifdef DEBUG
545  (*obj)->Verify();
546 #endif // DEBUG
547  return result.location();
548 }
549 
550 
551 void V8::MakeWeak(i::Object** object,
552  void* parameters,
553  WeakCallback weak_callback) {
554  i::GlobalHandles::MakeWeak(object, parameters, weak_callback);
555 }
556 
557 
558 void* V8::ClearWeak(i::Object** obj) {
560 }
561 
562 
563 void V8::DisposeGlobal(i::Object** obj) {
565 }
566 
567 
568 void V8::Eternalize(Isolate* v8_isolate, Value* value, int* index) {
569  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
570  i::Object* object = *Utils::OpenHandle(value);
571  isolate->eternal_handles()->Create(isolate, object, index);
572 }
573 
574 
575 Local<Value> V8::GetEternal(Isolate* v8_isolate, int index) {
576  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
577  return Utils::ToLocal(isolate->eternal_handles()->Get(index));
578 }
579 
580 
581 // --- H a n d l e s ---
582 
583 
585  Initialize(isolate);
586 }
587 
588 
590  i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
591  // We do not want to check the correct usage of the Locker class all over the
592  // place, so we do it only here: Without a HandleScope, an embedder can do
593  // almost nothing, so it is enough to check in this central place.
595  internal_isolate->thread_manager()->IsLockedByCurrentThread(),
596  "HandleScope::HandleScope",
597  "Entering the V8 API without proper locking in place");
598  i::HandleScopeData* current = internal_isolate->handle_scope_data();
599  isolate_ = internal_isolate;
600  prev_next_ = current->next;
601  prev_limit_ = current->limit;
602  current->level++;
603 }
604 
605 
607  i::HandleScope::CloseScope(isolate_, prev_next_, prev_limit_);
608 }
609 
610 
613  reinterpret_cast<i::Isolate*>(isolate));
614 }
615 
616 
618  return i::HandleScope::CreateHandle(isolate, value);
619 }
620 
621 
623  i::Object* value) {
624  ASSERT(heap_object->IsHeapObject());
625  return i::HandleScope::CreateHandle(heap_object->GetIsolate(), value);
626 }
627 
628 
630  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
631  escape_slot_ = CreateHandle(isolate, isolate->heap()->the_hole_value());
632  Initialize(v8_isolate);
633 }
634 
635 
637  i::Heap* heap = reinterpret_cast<i::Isolate*>(GetIsolate())->heap();
638  Utils::ApiCheck(*escape_slot_ == heap->the_hole_value(),
639  "EscapeableHandleScope::Escape",
640  "Escape value set twice");
641  if (escape_value == NULL) {
642  *escape_slot_ = heap->undefined_value();
643  return NULL;
644  }
645  *escape_slot_ = *escape_value;
646  return escape_slot_;
647 }
648 
649 
652  i::Isolate* isolate = env->GetIsolate();
653  ENTER_V8(isolate);
655  impl->EnterContext(env);
656  impl->SaveContext(isolate->context());
657  isolate->set_context(*env);
658 }
659 
660 
663  i::Isolate* isolate = env->GetIsolate();
664  ENTER_V8(isolate);
666  if (!Utils::ApiCheck(impl->LastEnteredContextWas(env),
667  "v8::Context::Exit()",
668  "Cannot exit non-entered context")) {
669  return;
670  }
671  impl->LeaveContext();
672  isolate->set_context(impl->RestoreContext());
673 }
674 
675 
676 static void* DecodeSmiToAligned(i::Object* value, const char* location) {
677  Utils::ApiCheck(value->IsSmi(), location, "Not a Smi");
678  return reinterpret_cast<void*>(value);
679 }
680 
681 
682 static i::Smi* EncodeAlignedAsSmi(void* value, const char* location) {
683  i::Smi* smi = reinterpret_cast<i::Smi*>(value);
684  Utils::ApiCheck(smi->IsSmi(), location, "Pointer is not aligned");
685  return smi;
686 }
687 
688 
689 static i::Handle<i::FixedArray> EmbedderDataFor(Context* context,
690  int index,
691  bool can_grow,
692  const char* location) {
694  bool ok =
695  Utils::ApiCheck(env->IsNativeContext(),
696  location,
697  "Not a native context") &&
698  Utils::ApiCheck(index >= 0, location, "Negative index");
699  if (!ok) return i::Handle<i::FixedArray>();
700  i::Handle<i::FixedArray> data(env->embedder_data());
701  if (index < data->length()) return data;
702  if (!Utils::ApiCheck(can_grow, location, "Index too large")) {
703  return i::Handle<i::FixedArray>();
704  }
705  int new_size = i::Max(index, data->length() << 1) + 1;
706  data = env->GetIsolate()->factory()->CopySizeFixedArray(data, new_size);
707  env->set_embedder_data(*data);
708  return data;
709 }
710 
711 
712 v8::Local<v8::Value> Context::SlowGetEmbedderData(int index) {
713  const char* location = "v8::Context::GetEmbedderData()";
714  i::Handle<i::FixedArray> data = EmbedderDataFor(this, index, false, location);
715  if (data.is_null()) return Local<Value>();
716  i::Handle<i::Object> result(data->get(index), data->GetIsolate());
717  return Utils::ToLocal(result);
718 }
719 
720 
722  const char* location = "v8::Context::SetEmbedderData()";
723  i::Handle<i::FixedArray> data = EmbedderDataFor(this, index, true, location);
724  if (data.is_null()) return;
726  data->set(index, *val);
727  ASSERT_EQ(*Utils::OpenHandle(*value),
729 }
730 
731 
732 void* Context::SlowGetAlignedPointerFromEmbedderData(int index) {
733  const char* location = "v8::Context::GetAlignedPointerFromEmbedderData()";
734  i::Handle<i::FixedArray> data = EmbedderDataFor(this, index, false, location);
735  if (data.is_null()) return NULL;
736  return DecodeSmiToAligned(data->get(index), location);
737 }
738 
739 
740 void Context::SetAlignedPointerInEmbedderData(int index, void* value) {
741  const char* location = "v8::Context::SetAlignedPointerInEmbedderData()";
742  i::Handle<i::FixedArray> data = EmbedderDataFor(this, index, true, location);
743  data->set(index, EncodeAlignedAsSmi(value, location));
745 }
746 
747 
748 // --- N e a n d e r ---
749 
750 
751 // A constructor cannot easily return an error value, therefore it is necessary
752 // to check for a dead VM with ON_BAILOUT before constructing any Neander
753 // objects. To remind you about this there is no HandleScope in the
754 // NeanderObject constructor. When you add one to the site calling the
755 // constructor you should check that you ensured the VM was not dead first.
757  EnsureInitializedForIsolate(isolate, "v8::Nowhere");
758  ENTER_V8(isolate);
759  value_ = isolate->factory()->NewNeanderObject();
760  i::Handle<i::FixedArray> elements = isolate->factory()->NewFixedArray(size);
761  value_->set_elements(*elements);
762 }
763 
764 
766  return i::FixedArray::cast(value_->elements())->length();
767 }
768 
769 
770 NeanderArray::NeanderArray(v8::internal::Isolate* isolate) : obj_(isolate, 2) {
771  obj_.set(0, i::Smi::FromInt(0));
772 }
773 
774 
776  return i::Smi::cast(obj_.get(0))->value();
777 }
778 
779 
781  ASSERT(0 <= offset);
782  ASSERT(offset < length());
783  return obj_.get(offset + 1);
784 }
785 
786 
787 // This method cannot easily return an error value, therefore it is necessary
788 // to check for a dead VM with ON_BAILOUT before calling it. To remind you
789 // about this there is no HandleScope in this method. When you add one to the
790 // site calling this method you should check that you ensured the VM was not
791 // dead first.
793  int length = this->length();
794  int size = obj_.size();
795  if (length == size - 1) {
796  i::Factory* factory = i::Isolate::Current()->factory();
797  i::Handle<i::FixedArray> new_elms = factory->NewFixedArray(2 * size);
798  for (int i = 0; i < length; i++)
799  new_elms->set(i + 1, get(i));
800  obj_.value()->set_elements(*new_elms);
801  }
802  obj_.set(length + 1, *value);
803  obj_.set(0, i::Smi::FromInt(length + 1));
804 }
805 
806 
807 void NeanderArray::set(int index, i::Object* value) {
808  if (index < 0 || index >= this->length()) return;
809  obj_.set(index + 1, value);
810 }
811 
812 
813 // --- T e m p l a t e ---
814 
815 
816 static void InitializeTemplate(i::Handle<i::TemplateInfo> that, int type) {
817  that->set_tag(i::Smi::FromInt(type));
818 }
819 
820 
821 static void TemplateSet(i::Isolate* isolate,
822  v8::Template* templ,
823  int length,
824  v8::Handle<v8::Data>* data) {
825  i::Handle<i::Object> list(Utils::OpenHandle(templ)->property_list(), isolate);
826  if (list->IsUndefined()) {
827  list = NeanderArray(isolate).value();
828  Utils::OpenHandle(templ)->set_property_list(*list);
829  }
830  NeanderArray array(list);
831  array.add(isolate->factory()->NewNumberFromInt(length));
832  for (int i = 0; i < length; i++) {
833  i::Handle<i::Object> value = data[i].IsEmpty() ?
834  i::Handle<i::Object>(isolate->factory()->undefined_value()) :
835  Utils::OpenHandle(*data[i]);
836  array.add(value);
837  }
838 }
839 
840 
842  v8::Handle<Data> value,
843  v8::PropertyAttribute attribute) {
844  i::Isolate* isolate = i::Isolate::Current();
845  ENTER_V8(isolate);
846  i::HandleScope scope(isolate);
847  const int kSize = 3;
848  v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
849  v8::Handle<v8::Data> data[kSize] = {
850  name,
851  value,
852  v8::Integer::New(v8_isolate, attribute)};
853  TemplateSet(isolate, this, kSize, data);
854 }
855 
856 
861  v8::PropertyAttribute attribute,
862  v8::AccessControl access_control) {
863  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
864  ENTER_V8(isolate);
865  ASSERT(!name.IsEmpty());
866  ASSERT(!getter.IsEmpty() || !setter.IsEmpty());
867  i::HandleScope scope(isolate);
868  const int kSize = 5;
869  v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
870  v8::Handle<v8::Data> data[kSize] = {
871  name,
872  getter,
873  setter,
874  v8::Integer::New(v8_isolate, attribute),
875  v8::Integer::New(v8_isolate, access_control)};
876  TemplateSet(isolate, this, kSize, data);
877 }
878 
879 
880 // --- F u n c t i o n T e m p l a t e ---
881 static void InitializeFunctionTemplate(
884  info->set_flag(0);
885 }
886 
887 
889  i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate();
890  ENTER_V8(i_isolate);
892  i_isolate);
893  if (result->IsUndefined()) {
894  v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(i_isolate);
895  result = Utils::OpenHandle(*ObjectTemplate::New(isolate));
896  Utils::OpenHandle(this)->set_prototype_template(*result);
897  }
898  return ToApiHandle<ObjectTemplate>(result);
899 }
900 
901 
903  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
904  ENTER_V8(isolate);
905  Utils::OpenHandle(this)->set_parent_template(*Utils::OpenHandle(*value));
906 }
907 
908 
909 static Local<FunctionTemplate> FunctionTemplateNew(
910  i::Isolate* isolate,
911  FunctionCallback callback,
912  v8::Handle<Value> data,
913  v8::Handle<Signature> signature,
914  int length,
915  bool do_not_cache) {
916  i::Handle<i::Struct> struct_obj =
920  InitializeFunctionTemplate(obj);
921  obj->set_do_not_cache(do_not_cache);
922  int next_serial_number = 0;
923  if (!do_not_cache) {
924  next_serial_number = isolate->next_serial_number() + 1;
925  isolate->set_next_serial_number(next_serial_number);
926  }
927  obj->set_serial_number(i::Smi::FromInt(next_serial_number));
928  if (callback != 0) {
929  if (data.IsEmpty()) {
930  data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
931  }
932  Utils::ToLocal(obj)->SetCallHandler(callback, data);
933  }
934  obj->set_length(length);
935  obj->set_undetectable(false);
936  obj->set_needs_access_check(false);
937  if (!signature.IsEmpty())
938  obj->set_signature(*Utils::OpenHandle(*signature));
939  return Utils::ToLocal(obj);
940 }
941 
943  Isolate* isolate,
944  FunctionCallback callback,
945  v8::Handle<Value> data,
946  v8::Handle<Signature> signature,
947  int length) {
948  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
949  EnsureInitializedForIsolate(i_isolate, "v8::FunctionTemplate::New()");
950  LOG_API(i_isolate, "FunctionTemplate::New");
951  ENTER_V8(i_isolate);
952  return FunctionTemplateNew(
953  i_isolate, callback, data, signature, length, false);
954 }
955 
956 
958  Handle<FunctionTemplate> receiver, int argc,
959  Handle<FunctionTemplate> argv[]) {
960  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
961  EnsureInitializedForIsolate(i_isolate, "v8::Signature::New()");
962  LOG_API(i_isolate, "Signature::New");
963  ENTER_V8(i_isolate);
964  i::Handle<i::Struct> struct_obj =
968  if (!receiver.IsEmpty()) obj->set_receiver(*Utils::OpenHandle(*receiver));
969  if (argc > 0) {
970  i::Handle<i::FixedArray> args = i_isolate->factory()->NewFixedArray(argc);
971  for (int i = 0; i < argc; i++) {
972  if (!argv[i].IsEmpty())
973  args->set(i, *Utils::OpenHandle(*argv[i]));
974  }
975  obj->set_args(*args);
976  }
977  return Utils::ToLocal(obj);
978 }
979 
980 
982  Isolate* isolate,
983  Handle<FunctionTemplate> receiver) {
985 }
986 
987 
988 template<typename Operation>
989 static Local<Operation> NewDescriptor(
990  Isolate* isolate,
992  Data* previous_descriptor) {
993  i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
996  if (previous_descriptor != NULL) {
997  previous = Utils::OpenHandle(
998  static_cast<DeclaredAccessorDescriptor*>(previous_descriptor));
999  }
1001  i::DeclaredAccessorDescriptor::Create(internal_isolate, data, previous);
1002  return Utils::Convert<i::DeclaredAccessorDescriptor, Operation>(descriptor);
1003 }
1004 
1005 
1006 Local<RawOperationDescriptor>
1008  Isolate* isolate,
1009  int internal_field) {
1012  data.object_dereference_descriptor.internal_field = internal_field;
1013  return NewDescriptor<RawOperationDescriptor>(isolate, data, NULL);
1014 }
1015 
1016 
1018  Isolate* isolate,
1019  int16_t byte_offset) {
1022  data.pointer_shift_descriptor.byte_offset = byte_offset;
1023  return NewDescriptor<RawOperationDescriptor>(isolate, data, this);
1024 }
1025 
1026 
1028  Isolate* isolate) {
1031  return NewDescriptor<DeclaredAccessorDescriptor>(isolate, data, this);
1032 }
1033 
1034 
1036  Isolate* isolate) {
1039  return NewDescriptor<RawOperationDescriptor>(isolate, data, this);
1040 }
1041 
1042 
1044  Isolate* isolate,
1045  void* compare_value) {
1048  data.pointer_compare_descriptor.compare_value = compare_value;
1049  return NewDescriptor<DeclaredAccessorDescriptor>(isolate, data, this);
1050 }
1051 
1052 
1054  Isolate* isolate,
1056  uint8_t bool_offset) {
1059  data.primitive_value_descriptor.data_type = data_type;
1060  data.primitive_value_descriptor.bool_offset = bool_offset;
1061  return NewDescriptor<DeclaredAccessorDescriptor>(isolate, data, this);
1062 }
1063 
1064 
1065 template<typename T>
1066 static Local<DeclaredAccessorDescriptor> NewBitmaskCompare(
1067  Isolate* isolate,
1068  T bitmask,
1069  T compare_value,
1070  RawOperationDescriptor* operation) {
1073  data.bitmask_compare_descriptor.bitmask = bitmask;
1074  data.bitmask_compare_descriptor.compare_value = compare_value;
1075  data.bitmask_compare_descriptor.size = sizeof(T);
1076  return NewDescriptor<DeclaredAccessorDescriptor>(isolate, data, operation);
1077 }
1078 
1079 
1081  Isolate* isolate,
1082  uint8_t bitmask,
1083  uint8_t compare_value) {
1084  return NewBitmaskCompare(isolate, bitmask, compare_value, this);
1085 }
1086 
1087 
1089  Isolate* isolate,
1090  uint16_t bitmask,
1091  uint16_t compare_value) {
1092  return NewBitmaskCompare(isolate, bitmask, compare_value, this);
1093 }
1094 
1095 
1097  Isolate* isolate,
1098  uint32_t bitmask,
1099  uint32_t compare_value) {
1100  return NewBitmaskCompare(isolate, bitmask, compare_value, this);
1101 }
1102 
1103 
1105  Handle<FunctionTemplate> types[1] = { type };
1106  return TypeSwitch::New(1, types);
1107 }
1108 
1109 
1111  i::Isolate* isolate = i::Isolate::Current();
1112  EnsureInitializedForIsolate(isolate, "v8::TypeSwitch::New()");
1113  LOG_API(isolate, "TypeSwitch::New");
1114  ENTER_V8(isolate);
1115  i::Handle<i::FixedArray> vector = isolate->factory()->NewFixedArray(argc);
1116  for (int i = 0; i < argc; i++)
1117  vector->set(i, *Utils::OpenHandle(*types[i]));
1118  i::Handle<i::Struct> struct_obj =
1122  obj->set_types(*vector);
1123  return Utils::ToLocal(obj);
1124 }
1125 
1126 
1128  i::Isolate* isolate = i::Isolate::Current();
1129  LOG_API(isolate, "TypeSwitch::match");
1130  USE(isolate);
1133  i::FixedArray* types = i::FixedArray::cast(info->types());
1134  for (int i = 0; i < types->length(); i++) {
1135  if (i::FunctionTemplateInfo::cast(types->get(i))->IsTemplateFor(*obj))
1136  return i + 1;
1137  }
1138  return 0;
1139 }
1140 
1141 
1142 #define SET_FIELD_WRAPPED(obj, setter, cdata) do { \
1143  i::Handle<i::Object> foreign = FromCData(obj->GetIsolate(), cdata); \
1144  (obj)->setter(*foreign); \
1145  } while (false)
1146 
1147 
1149  v8::Handle<Value> data) {
1150  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1151  ENTER_V8(isolate);
1152  i::HandleScope scope(isolate);
1153  i::Handle<i::Struct> struct_obj =
1157  SET_FIELD_WRAPPED(obj, set_callback, callback);
1158  if (data.IsEmpty()) {
1159  data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
1160  }
1161  obj->set_data(*Utils::OpenHandle(*data));
1162  Utils::OpenHandle(this)->set_call_code(*obj);
1163 }
1164 
1165 
1166 static i::Handle<i::AccessorInfo> SetAccessorInfoProperties(
1169  v8::AccessControl settings,
1170  v8::PropertyAttribute attributes,
1171  v8::Handle<AccessorSignature> signature) {
1172  obj->set_name(*Utils::OpenHandle(*name));
1173  if (settings & ALL_CAN_READ) obj->set_all_can_read(true);
1174  if (settings & ALL_CAN_WRITE) obj->set_all_can_write(true);
1175  if (settings & PROHIBITS_OVERWRITING) obj->set_prohibits_overwriting(true);
1176  obj->set_property_attributes(static_cast<PropertyAttributes>(attributes));
1177  if (!signature.IsEmpty()) {
1178  obj->set_expected_receiver_type(*Utils::OpenHandle(*signature));
1179  }
1180  return obj;
1181 }
1182 
1183 
1184 template<typename Getter, typename Setter>
1185 static i::Handle<i::AccessorInfo> MakeAccessorInfo(
1186  v8::Handle<String> name,
1187  Getter getter,
1188  Setter setter,
1189  v8::Handle<Value> data,
1190  v8::AccessControl settings,
1191  v8::PropertyAttribute attributes,
1192  v8::Handle<AccessorSignature> signature) {
1193  i::Isolate* isolate = Utils::OpenHandle(*name)->GetIsolate();
1195  isolate->factory()->NewExecutableAccessorInfo();
1196  SET_FIELD_WRAPPED(obj, set_getter, getter);
1197  SET_FIELD_WRAPPED(obj, set_setter, setter);
1198  if (data.IsEmpty()) {
1199  data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
1200  }
1201  obj->set_data(*Utils::OpenHandle(*data));
1202  return SetAccessorInfoProperties(obj, name, settings, attributes, signature);
1203 }
1204 
1205 
1206 static i::Handle<i::AccessorInfo> MakeAccessorInfo(
1207  v8::Handle<String> name,
1209  void* setter_ignored,
1210  void* data_ignored,
1211  v8::AccessControl settings,
1212  v8::PropertyAttribute attributes,
1213  v8::Handle<AccessorSignature> signature) {
1214  i::Isolate* isolate = Utils::OpenHandle(*name)->GetIsolate();
1215  if (descriptor.IsEmpty()) return i::Handle<i::DeclaredAccessorInfo>();
1217  isolate->factory()->NewDeclaredAccessorInfo();
1218  obj->set_descriptor(*Utils::OpenHandle(*descriptor));
1219  return SetAccessorInfoProperties(obj, name, settings, attributes, signature);
1220 }
1221 
1222 
1224  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1225  if (!Utils::ApiCheck(this != NULL,
1226  "v8::FunctionTemplate::InstanceTemplate()",
1227  "Reading from empty handle")) {
1228  return Local<ObjectTemplate>();
1229  }
1230  ENTER_V8(isolate);
1232  if (handle->instance_template()->IsUndefined()) {
1233  Local<ObjectTemplate> templ =
1234  ObjectTemplate::New(isolate, ToApiHandle<FunctionTemplate>(handle));
1235  handle->set_instance_template(*Utils::OpenHandle(*templ));
1236  }
1238  i::ObjectTemplateInfo::cast(handle->instance_template()));
1239  return Utils::ToLocal(result);
1240 }
1241 
1242 
1244  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1245  ENTER_V8(isolate);
1246  Utils::OpenHandle(this)->set_length(length);
1247 }
1248 
1249 
1251  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1252  ENTER_V8(isolate);
1253  Utils::OpenHandle(this)->set_class_name(*Utils::OpenHandle(*name));
1254 }
1255 
1256 
1258  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1259  ENTER_V8(isolate);
1260  Utils::OpenHandle(this)->set_hidden_prototype(value);
1261 }
1262 
1263 
1265  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1266  ENTER_V8(isolate);
1267  Utils::OpenHandle(this)->set_read_only_prototype(true);
1268 }
1269 
1270 
1272  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1273  ENTER_V8(isolate);
1274  Utils::OpenHandle(this)->set_remove_prototype(true);
1275 }
1276 
1277 
1278 // --- O b j e c t T e m p l a t e ---
1279 
1280 
1282  return New(reinterpret_cast<i::Isolate*>(isolate), Local<FunctionTemplate>());
1283 }
1284 
1285 
1287  return New(i::Isolate::Current(), Local<FunctionTemplate>());
1288 }
1289 
1290 
1292  i::Isolate* isolate,
1293  v8::Handle<FunctionTemplate> constructor) {
1294  EnsureInitializedForIsolate(isolate, "v8::ObjectTemplate::New()");
1295  LOG_API(isolate, "ObjectTemplate::New");
1296  ENTER_V8(isolate);
1297  i::Handle<i::Struct> struct_obj =
1301  InitializeTemplate(obj, Consts::OBJECT_TEMPLATE);
1302  if (!constructor.IsEmpty())
1303  obj->set_constructor(*Utils::OpenHandle(*constructor));
1304  obj->set_internal_field_count(i::Smi::FromInt(0));
1305  return Utils::ToLocal(obj);
1306 }
1307 
1308 
1309 // Ensure that the object template has a constructor. If no
1310 // constructor is available we create one.
1311 static i::Handle<i::FunctionTemplateInfo> EnsureConstructor(
1312  i::Isolate* isolate,
1313  ObjectTemplate* object_template) {
1314  i::Object* obj = Utils::OpenHandle(object_template)->constructor();
1315  if (!obj ->IsUndefined()) {
1317  return i::Handle<i::FunctionTemplateInfo>(info, isolate);
1318  }
1319  Local<FunctionTemplate> templ =
1320  FunctionTemplate::New(reinterpret_cast<Isolate*>(isolate));
1322  constructor->set_instance_template(*Utils::OpenHandle(object_template));
1323  Utils::OpenHandle(object_template)->set_constructor(*constructor);
1324  return constructor;
1325 }
1326 
1327 
1328 static inline void AddPropertyToTemplate(
1331  i::Isolate* isolate = info->GetIsolate();
1332  i::Handle<i::Object> list(info->property_accessors(), isolate);
1333  if (list->IsUndefined()) {
1334  list = NeanderArray(isolate).value();
1335  info->set_property_accessors(*list);
1336  }
1337  NeanderArray array(list);
1338  array.add(obj);
1339 }
1340 
1341 
1342 static inline i::Handle<i::TemplateInfo> GetTemplateInfo(
1343  i::Isolate* isolate,
1344  Template* template_obj) {
1345  return Utils::OpenHandle(template_obj);
1346 }
1347 
1348 
1349 // TODO(dcarney): remove this with ObjectTemplate::SetAccessor
1350 static inline i::Handle<i::TemplateInfo> GetTemplateInfo(
1351  i::Isolate* isolate,
1352  ObjectTemplate* object_template) {
1353  EnsureConstructor(isolate, object_template);
1354  return Utils::OpenHandle(object_template);
1355 }
1356 
1357 
1358 template<typename Setter, typename Getter, typename Data, typename Template>
1359 static bool TemplateSetAccessor(
1360  Template* template_obj,
1361  v8::Local<String> name,
1362  Getter getter,
1363  Setter setter,
1364  Data data,
1365  AccessControl settings,
1366  PropertyAttribute attribute,
1367  v8::Local<AccessorSignature> signature) {
1368  i::Isolate* isolate = Utils::OpenHandle(template_obj)->GetIsolate();
1369  ENTER_V8(isolate);
1370  i::HandleScope scope(isolate);
1371  i::Handle<i::AccessorInfo> obj = MakeAccessorInfo(
1372  name, getter, setter, data, settings, attribute, signature);
1373  if (obj.is_null()) return false;
1374  i::Handle<i::TemplateInfo> info = GetTemplateInfo(isolate, template_obj);
1375  AddPropertyToTemplate(info, obj);
1376  return true;
1377 }
1378 
1379 
1381  Local<String> name,
1383  PropertyAttribute attribute,
1384  Local<AccessorSignature> signature,
1385  AccessControl settings) {
1386  void* null = NULL;
1387  return TemplateSetAccessor(
1388  this, name, descriptor, null, null, settings, attribute, signature);
1389 }
1390 
1391 
1393  AccessorGetterCallback getter,
1394  AccessorSetterCallback setter,
1395  v8::Handle<Value> data,
1396  PropertyAttribute attribute,
1397  v8::Local<AccessorSignature> signature,
1398  AccessControl settings) {
1399  TemplateSetAccessor(
1400  this, name, getter, setter, data, settings, attribute, signature);
1401 }
1402 
1403 
1405  AccessorGetterCallback getter,
1406  AccessorSetterCallback setter,
1407  v8::Handle<Value> data,
1408  AccessControl settings,
1409  PropertyAttribute attribute,
1410  v8::Handle<AccessorSignature> signature) {
1411  TemplateSetAccessor(
1412  this, name, getter, setter, data, settings, attribute, signature);
1413 }
1414 
1415 
1422  Handle<Value> data) {
1423  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1424  ENTER_V8(isolate);
1425  i::HandleScope scope(isolate);
1426  EnsureConstructor(isolate, this);
1428  Utils::OpenHandle(this)->constructor());
1429  i::Handle<i::FunctionTemplateInfo> cons(constructor);
1430  i::Handle<i::Struct> struct_obj =
1434 
1435  if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter);
1436  if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter);
1437  if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query);
1438  if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover);
1439  if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator);
1440 
1441  if (data.IsEmpty()) {
1442  data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
1443  }
1444  obj->set_data(*Utils::OpenHandle(*data));
1445  cons->set_named_property_handler(*obj);
1446 }
1447 
1448 
1450  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1451  ENTER_V8(isolate);
1452  i::HandleScope scope(isolate);
1453  EnsureConstructor(isolate, this);
1454  i::FunctionTemplateInfo* constructor =
1455  i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor());
1456  i::Handle<i::FunctionTemplateInfo> cons(constructor);
1457  cons->set_undetectable(true);
1458 }
1459 
1460 
1462  NamedSecurityCallback named_callback,
1463  IndexedSecurityCallback indexed_callback,
1464  Handle<Value> data,
1465  bool turned_on_by_default) {
1466  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1467  ENTER_V8(isolate);
1468  i::HandleScope scope(isolate);
1469  EnsureConstructor(isolate, this);
1470 
1471  i::Handle<i::Struct> struct_info =
1475 
1476  SET_FIELD_WRAPPED(info, set_named_callback, named_callback);
1477  SET_FIELD_WRAPPED(info, set_indexed_callback, indexed_callback);
1478 
1479  if (data.IsEmpty()) {
1480  data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
1481  }
1482  info->set_data(*Utils::OpenHandle(*data));
1483 
1484  i::FunctionTemplateInfo* constructor =
1485  i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor());
1486  i::Handle<i::FunctionTemplateInfo> cons(constructor);
1487  cons->set_access_check_info(*info);
1488  cons->set_needs_access_check(turned_on_by_default);
1489 }
1490 
1491 
1498  Handle<Value> data) {
1499  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1500  ENTER_V8(isolate);
1501  i::HandleScope scope(isolate);
1502  EnsureConstructor(isolate, this);
1504  Utils::OpenHandle(this)->constructor());
1505  i::Handle<i::FunctionTemplateInfo> cons(constructor);
1506  i::Handle<i::Struct> struct_obj =
1510 
1511  if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter);
1512  if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter);
1513  if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query);
1514  if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover);
1515  if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator);
1516 
1517  if (data.IsEmpty()) {
1518  data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
1519  }
1520  obj->set_data(*Utils::OpenHandle(*data));
1521  cons->set_indexed_property_handler(*obj);
1522 }
1523 
1524 
1526  Handle<Value> data) {
1527  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1528  ENTER_V8(isolate);
1529  i::HandleScope scope(isolate);
1530  EnsureConstructor(isolate, this);
1532  Utils::OpenHandle(this)->constructor());
1533  i::Handle<i::FunctionTemplateInfo> cons(constructor);
1534  i::Handle<i::Struct> struct_obj =
1538  SET_FIELD_WRAPPED(obj, set_callback, callback);
1539  if (data.IsEmpty()) {
1540  data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
1541  }
1542  obj->set_data(*Utils::OpenHandle(*data));
1543  cons->set_instance_call_handler(*obj);
1544 }
1545 
1546 
1549 }
1550 
1551 
1553  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1554  if (!Utils::ApiCheck(i::Smi::IsValid(value),
1555  "v8::ObjectTemplate::SetInternalFieldCount()",
1556  "Invalid internal field count")) {
1557  return;
1558  }
1559  ENTER_V8(isolate);
1560  if (value > 0) {
1561  // The internal field count is set by the constructor function's
1562  // construct code, so we ensure that there is a constructor
1563  // function to do the setting.
1564  EnsureConstructor(isolate, this);
1565  }
1566  Utils::OpenHandle(this)->set_internal_field_count(i::Smi::FromInt(value));
1567 }
1568 
1569 
1570 // --- S c r i p t D a t a ---
1571 
1572 
1574  i::Handle<i::String> str = Utils::OpenHandle(*source);
1575  i::Isolate* isolate = str->GetIsolate();
1576  if (str->IsExternalTwoByteString()) {
1578  i::Handle<i::ExternalTwoByteString>::cast(str), 0, str->length());
1579  return i::PreParserApi::PreParse(isolate, &stream);
1580  } else {
1581  i::GenericStringUtf16CharacterStream stream(str, 0, str->length());
1582  return i::PreParserApi::PreParse(isolate, &stream);
1583  }
1584 }
1585 
1586 
1587 ScriptData* ScriptData::New(const char* data, int length) {
1588  // Return an empty ScriptData if the length is obviously invalid.
1589  if (length % sizeof(unsigned) != 0) {
1590  return new i::ScriptDataImpl();
1591  }
1592 
1593  // Copy the data to ensure it is properly aligned.
1594  int deserialized_data_length = length / sizeof(unsigned);
1595  // If aligned, don't create a copy of the data.
1596  if (reinterpret_cast<intptr_t>(data) % sizeof(unsigned) == 0) {
1597  return new i::ScriptDataImpl(data, length);
1598  }
1599  // Copy the data to align it.
1600  unsigned* deserialized_data = i::NewArray<unsigned>(deserialized_data_length);
1601  i::CopyBytes(reinterpret_cast<char*>(deserialized_data),
1602  data, static_cast<size_t>(length));
1603 
1604  return new i::ScriptDataImpl(
1605  i::Vector<unsigned>(deserialized_data, deserialized_data_length));
1606 }
1607 
1608 
1609 // --- S c r i p t s ---
1610 
1611 
1612 // Internally, UnboundScript is a SharedFunctionInfo, and Script is a
1613 // JSFunction.
1614 
1615 ScriptCompiler::CachedData::CachedData(const uint8_t* data_, int length_,
1616  BufferPolicy buffer_policy_)
1617  : data(data_), length(length_), buffer_policy(buffer_policy_) {}
1618 
1619 
1621  if (buffer_policy == BufferOwned) {
1622  delete[] data;
1623  }
1624 }
1625 
1626 
1631  function_info(i::SharedFunctionInfo::cast(*obj), obj->GetIsolate());
1632  i::Handle<i::JSFunction> function =
1633  obj->GetIsolate()->factory()->NewFunctionFromSharedFunctionInfo(
1634  function_info, obj->GetIsolate()->global_context());
1635  return ToApiHandle<Script>(function);
1636 }
1637 
1638 
1642  i::Isolate* isolate = obj->GetIsolate();
1643  ON_BAILOUT(isolate, "v8::UnboundScript::GetId()", return -1);
1644  LOG_API(isolate, "v8::UnboundScript::GetId");
1645  {
1646  i::HandleScope scope(isolate);
1647  i::Handle<i::SharedFunctionInfo> function_info(
1649  i::Handle<i::Script> script(i::Script::cast(function_info->script()));
1650  return script->id()->value();
1651  }
1652 }
1653 
1654 
1655 int UnboundScript::GetLineNumber(int code_pos) {
1658  i::Isolate* isolate = obj->GetIsolate();
1659  ON_BAILOUT(isolate, "v8::UnboundScript::GetLineNumber()", return -1);
1660  LOG_API(isolate, "UnboundScript::GetLineNumber");
1661  if (obj->IsScript()) {
1662  i::Handle<i::Script> script(i::Script::cast(*obj));
1663  return i::GetScriptLineNumber(script, code_pos);
1664  } else {
1665  return -1;
1666  }
1667 }
1668 
1669 
1673  i::Isolate* isolate = obj->GetIsolate();
1674  ON_BAILOUT(isolate, "v8::UnboundScript::GetName()",
1675  return Handle<String>());
1676  LOG_API(isolate, "UnboundScript::GetName");
1677  if (obj->IsScript()) {
1678  i::Object* name = i::Script::cast(*obj)->name();
1679  return Utils::ToLocal(i::Handle<i::Object>(name, isolate));
1680  } else {
1681  return Handle<String>();
1682  }
1683 }
1684 
1685 
1687  // If execution is terminating, Compile(..)->Run() requires this
1688  // check.
1689  if (this == NULL) return Local<Value>();
1692  i::Isolate* isolate = obj->GetIsolate();
1693  ON_BAILOUT(isolate, "v8::Script::Run()", return Local<Value>());
1694  LOG_API(isolate, "Script::Run");
1695  ENTER_V8(isolate);
1696  i::Logger::TimerEventScope timer_scope(
1697  isolate, i::Logger::TimerEventScope::v8_execute);
1698  i::Object* raw_result = NULL;
1699  {
1700  i::HandleScope scope(isolate);
1703  EXCEPTION_PREAMBLE(isolate);
1704  i::Handle<i::Object> receiver(
1705  isolate->context()->global_proxy(), isolate);
1707  isolate, fun, receiver, 0, NULL, &has_pending_exception);
1709  raw_result = *result;
1710  }
1711  i::Handle<i::Object> result(raw_result, isolate);
1712  return Utils::ToLocal(result);
1713 }
1714 
1715 
1718  return ToApiHandle<UnboundScript>(
1720 }
1721 
1722 
1724  Isolate* v8_isolate,
1725  Source* source,
1726  CompileOptions options) {
1727  i::ScriptDataImpl* script_data_impl = NULL;
1728  i::CachedDataMode cached_data_mode = i::NO_CACHED_DATA;
1729  if (options & kProduceDataToCache) {
1730  cached_data_mode = i::PRODUCE_CACHED_DATA;
1731  ASSERT(source->cached_data == NULL);
1732  if (source->cached_data) {
1733  // Asked to produce cached data even though there is some already -> not
1734  // good. In release mode, try to do the right thing: Just regenerate the
1735  // data.
1736  delete source->cached_data;
1737  source->cached_data = NULL;
1738  }
1739  } else if (source->cached_data) {
1740  // FIXME(marja): Make compiler use CachedData directly. Aligning needs to be
1741  // taken care of.
1742  script_data_impl = static_cast<i::ScriptDataImpl*>(ScriptData::New(
1743  reinterpret_cast<const char*>(source->cached_data->data),
1744  source->cached_data->length));
1745  // We assert that the pre-data is sane, even though we can actually
1746  // handle it if it turns out not to be in release mode.
1747  ASSERT(script_data_impl->SanityCheck());
1748  if (script_data_impl->SanityCheck()) {
1749  cached_data_mode = i::CONSUME_CACHED_DATA;
1750  } else {
1751  // If the pre-data isn't sane we simply ignore it.
1752  delete script_data_impl;
1753  script_data_impl = NULL;
1754  delete source->cached_data;
1755  source->cached_data = NULL;
1756  }
1757  }
1758 
1759  i::Handle<i::String> str = Utils::OpenHandle(*(source->source_string));
1760  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
1761  ON_BAILOUT(isolate, "v8::ScriptCompiler::CompileUnbound()",
1762  return Local<UnboundScript>());
1763  LOG_API(isolate, "ScriptCompiler::CompileUnbound");
1764  ENTER_V8(isolate);
1765  i::SharedFunctionInfo* raw_result = NULL;
1766  { i::HandleScope scope(isolate);
1767  i::Handle<i::Object> name_obj;
1768  int line_offset = 0;
1769  int column_offset = 0;
1770  bool is_shared_cross_origin = false;
1771  if (!source->resource_name.IsEmpty()) {
1772  name_obj = Utils::OpenHandle(*(source->resource_name));
1773  }
1774  if (!source->resource_line_offset.IsEmpty()) {
1775  line_offset = static_cast<int>(source->resource_line_offset->Value());
1776  }
1777  if (!source->resource_column_offset.IsEmpty()) {
1778  column_offset =
1779  static_cast<int>(source->resource_column_offset->Value());
1780  }
1781  if (!source->resource_is_shared_cross_origin.IsEmpty()) {
1782  v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
1783  is_shared_cross_origin =
1784  source->resource_is_shared_cross_origin == v8::True(v8_isolate);
1785  }
1786  EXCEPTION_PREAMBLE(isolate);
1789  name_obj,
1790  line_offset,
1791  column_offset,
1792  is_shared_cross_origin,
1793  isolate->global_context(),
1794  NULL,
1795  &script_data_impl,
1796  cached_data_mode,
1798  has_pending_exception = result.is_null();
1800  raw_result = *result;
1801  if ((options & kProduceDataToCache) && script_data_impl != NULL) {
1802  // script_data_impl now contains the data that was generated. source will
1803  // take the ownership.
1804  source->cached_data = new CachedData(
1805  reinterpret_cast<const uint8_t*>(script_data_impl->Data()),
1806  script_data_impl->Length(), CachedData::BufferOwned);
1807  script_data_impl->owns_store_ = false;
1808  }
1809  delete script_data_impl;
1810  }
1811  i::Handle<i::SharedFunctionInfo> result(raw_result, isolate);
1812  return ToApiHandle<UnboundScript>(result);
1813 }
1814 
1815 
1817  Isolate* v8_isolate,
1818  Source* source,
1819  CompileOptions options) {
1820  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
1821  ON_BAILOUT(isolate, "v8::ScriptCompiler::Compile()",
1822  return Local<Script>());
1823  LOG_API(isolate, "ScriptCompiler::CompiletBound()");
1824  ENTER_V8(isolate);
1825  Local<UnboundScript> generic =
1826  CompileUnbound(v8_isolate, source, options);
1827  if (generic.IsEmpty()) return Local<Script>();
1828  return generic->BindToCurrentContext();
1829 }
1830 
1831 
1833  v8::ScriptOrigin* origin,
1834  ScriptData* script_data) {
1835  i::Handle<i::String> str = Utils::OpenHandle(*source);
1836  ScriptCompiler::CachedData* cached_data = NULL;
1837  if (script_data) {
1838  cached_data = new ScriptCompiler::CachedData(
1839  reinterpret_cast<const uint8_t*>(script_data->Data()),
1840  script_data->Length());
1841  }
1842  if (origin) {
1843  ScriptCompiler::Source script_source(source, *origin, cached_data);
1844  return ScriptCompiler::Compile(
1845  reinterpret_cast<v8::Isolate*>(str->GetIsolate()),
1846  &script_source);
1847  }
1848  ScriptCompiler::Source script_source(source, cached_data);
1849  return ScriptCompiler::Compile(
1850  reinterpret_cast<v8::Isolate*>(str->GetIsolate()),
1851  &script_source);
1852 }
1853 
1854 
1856  v8::Handle<String> file_name) {
1857  ScriptOrigin origin(file_name);
1858  return Compile(source, &origin);
1859 }
1860 
1861 
1862 // --- E x c e p t i o n s ---
1863 
1864 
1866  : isolate_(i::Isolate::Current()),
1867  next_(isolate_->try_catch_handler_address()),
1868  is_verbose_(false),
1869  can_continue_(true),
1870  capture_message_(true),
1871  rethrow_(false),
1872  has_terminated_(false) {
1873  Reset();
1874  isolate_->RegisterTryCatchHandler(this);
1875 }
1876 
1877 
1879  ASSERT(isolate_ == i::Isolate::Current());
1880  if (rethrow_) {
1881  v8::Isolate* isolate = reinterpret_cast<Isolate*>(isolate_);
1882  v8::HandleScope scope(isolate);
1884  if (HasCaught() && capture_message_) {
1885  // If an exception was caught and rethrow_ is indicated, the saved
1886  // message, script, and location need to be restored to Isolate TLS
1887  // for reuse. capture_message_ needs to be disabled so that DoThrow()
1888  // does not create a new message.
1889  isolate_->thread_local_top()->rethrowing_message_ = true;
1890  isolate_->RestorePendingMessageFromTryCatch(this);
1891  }
1892  isolate_->UnregisterTryCatchHandler(this);
1893  reinterpret_cast<Isolate*>(isolate_)->ThrowException(exc);
1894  ASSERT(!isolate_->thread_local_top()->rethrowing_message_);
1895  } else {
1896  isolate_->UnregisterTryCatchHandler(this);
1897  }
1898 }
1899 
1900 
1902  return !reinterpret_cast<i::Object*>(exception_)->IsTheHole();
1903 }
1904 
1905 
1907  return can_continue_;
1908 }
1909 
1910 
1912  return has_terminated_;
1913 }
1914 
1915 
1917  if (!HasCaught()) return v8::Local<v8::Value>();
1918  rethrow_ = true;
1919  return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate_));
1920 }
1921 
1922 
1924  ASSERT(isolate_ == i::Isolate::Current());
1925  if (HasCaught()) {
1926  // Check for out of memory exception.
1927  i::Object* exception = reinterpret_cast<i::Object*>(exception_);
1928  return v8::Utils::ToLocal(i::Handle<i::Object>(exception, isolate_));
1929  } else {
1930  return v8::Local<Value>();
1931  }
1932 }
1933 
1934 
1936  ASSERT(isolate_ == i::Isolate::Current());
1937  if (HasCaught()) {
1938  i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_);
1939  if (!raw_obj->IsJSObject()) return v8::Local<Value>();
1940  i::HandleScope scope(isolate_);
1941  i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj), isolate_);
1942  i::Handle<i::String> name = isolate_->factory()->stack_string();
1943  if (!i::JSReceiver::HasProperty(obj, name)) return v8::Local<Value>();
1944  i::Handle<i::Object> value = i::GetProperty(isolate_, obj, name);
1945  if (value.is_null()) return v8::Local<Value>();
1946  return v8::Utils::ToLocal(scope.CloseAndEscape(value));
1947  } else {
1948  return v8::Local<Value>();
1949  }
1950 }
1951 
1952 
1954  ASSERT(isolate_ == i::Isolate::Current());
1955  i::Object* message = reinterpret_cast<i::Object*>(message_obj_);
1956  ASSERT(message->IsJSMessageObject() || message->IsTheHole());
1957  if (HasCaught() && !message->IsTheHole()) {
1958  return v8::Utils::MessageToLocal(i::Handle<i::Object>(message, isolate_));
1959  } else {
1960  return v8::Local<v8::Message>();
1961  }
1962 }
1963 
1964 
1966  ASSERT(isolate_ == i::Isolate::Current());
1967  i::Object* the_hole = isolate_->heap()->the_hole_value();
1968  exception_ = the_hole;
1969  message_obj_ = the_hole;
1970  message_script_ = the_hole;
1971  message_start_pos_ = 0;
1972  message_end_pos_ = 0;
1973 }
1974 
1975 
1976 void v8::TryCatch::SetVerbose(bool value) {
1977  is_verbose_ = value;
1978 }
1979 
1980 
1982  capture_message_ = value;
1983 }
1984 
1985 
1986 // --- M e s s a g e ---
1987 
1988 
1990  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1991  ON_BAILOUT(isolate, "v8::Message::Get()", return Local<String>());
1992  ENTER_V8(isolate);
1993  EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
1995  i::Handle<i::String> raw_result = i::MessageHandler::GetMessage(isolate, obj);
1996  Local<String> result = Utils::ToLocal(raw_result);
1997  return scope.Escape(result);
1998 }
1999 
2000 
2002  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2003  ENTER_V8(isolate);
2004  EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
2007  // Return this.script.name.
2008  i::Handle<i::JSValue> script =
2010  isolate));
2011  i::Handle<i::Object> resource_name(i::Script::cast(script->value())->name(),
2012  isolate);
2013  return scope.Escape(Utils::ToLocal(resource_name));
2014 }
2015 
2016 
2018  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2019  ENTER_V8(isolate);
2020  EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
2023  i::Handle<i::Object> stackFramesObj(message->stack_frames(), isolate);
2024  if (!stackFramesObj->IsJSArray()) return v8::Handle<v8::StackTrace>();
2025  i::Handle<i::JSArray> stackTrace =
2026  i::Handle<i::JSArray>::cast(stackFramesObj);
2027  return scope.Escape(Utils::StackTraceToLocal(stackTrace));
2028 }
2029 
2030 
2031 static i::Handle<i::Object> CallV8HeapFunction(const char* name,
2032  i::Handle<i::Object> recv,
2033  int argc,
2034  i::Handle<i::Object> argv[],
2035  bool* has_pending_exception) {
2036  i::Isolate* isolate = i::Isolate::Current();
2037  i::Handle<i::String> fmt_str =
2038  isolate->factory()->InternalizeUtf8String(name);
2039  i::Object* object_fun =
2040  isolate->js_builtins_object()->GetPropertyNoExceptionThrown(*fmt_str);
2044  isolate, fun, recv, argc, argv, has_pending_exception);
2045  return value;
2046 }
2047 
2048 
2049 static i::Handle<i::Object> CallV8HeapFunction(const char* name,
2050  i::Handle<i::Object> data,
2051  bool* has_pending_exception) {
2052  i::Handle<i::Object> argv[] = { data };
2053  return CallV8HeapFunction(name,
2054  i::Isolate::Current()->js_builtins_object(),
2055  ARRAY_SIZE(argv),
2056  argv,
2057  has_pending_exception);
2058 }
2059 
2060 
2062  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2063  ON_BAILOUT(isolate, "v8::Message::GetLineNumber()", return kNoLineNumberInfo);
2064  ENTER_V8(isolate);
2065  i::HandleScope scope(isolate);
2066 
2067  EXCEPTION_PREAMBLE(isolate);
2068  i::Handle<i::Object> result = CallV8HeapFunction("GetLineNumber",
2069  Utils::OpenHandle(this),
2070  &has_pending_exception);
2071  EXCEPTION_BAILOUT_CHECK(isolate, 0);
2072  return static_cast<int>(result->Number());
2073 }
2074 
2075 
2077  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2078  ENTER_V8(isolate);
2079  i::HandleScope scope(isolate);
2082  return message->start_position();
2083 }
2084 
2085 
2087  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2088  ENTER_V8(isolate);
2089  i::HandleScope scope(isolate);
2092  return message->end_position();
2093 }
2094 
2095 
2097  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2098  ENTER_V8(isolate);
2099  i::HandleScope scope(isolate);
2100  i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this);
2101  EXCEPTION_PREAMBLE(isolate);
2102  i::Handle<i::Object> start_col_obj = CallV8HeapFunction(
2103  "GetPositionInLine",
2104  data_obj,
2105  &has_pending_exception);
2106  EXCEPTION_BAILOUT_CHECK(isolate, 0);
2107  return static_cast<int>(start_col_obj->Number());
2108 }
2109 
2110 
2112  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2113  ENTER_V8(isolate);
2114  i::HandleScope scope(isolate);
2115  i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this);
2116  EXCEPTION_PREAMBLE(isolate);
2117  i::Handle<i::Object> start_col_obj = CallV8HeapFunction(
2118  "GetPositionInLine",
2119  data_obj,
2120  &has_pending_exception);
2121  EXCEPTION_BAILOUT_CHECK(isolate, 0);
2124  int start = message->start_position();
2125  int end = message->end_position();
2126  return static_cast<int>(start_col_obj->Number()) + (end - start);
2127 }
2128 
2129 
2131  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2132  ENTER_V8(isolate);
2133  i::HandleScope scope(isolate);
2136  i::Handle<i::JSValue> script =
2138  isolate));
2139  return i::Script::cast(script->value())->is_shared_cross_origin();
2140 }
2141 
2142 
2144  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2145  ON_BAILOUT(isolate, "v8::Message::GetSourceLine()", return Local<String>());
2146  ENTER_V8(isolate);
2147  EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
2148  EXCEPTION_PREAMBLE(isolate);
2149  i::Handle<i::Object> result = CallV8HeapFunction("GetSourceLine",
2150  Utils::OpenHandle(this),
2151  &has_pending_exception);
2153  if (result->IsString()) {
2154  return scope.Escape(Utils::ToLocal(i::Handle<i::String>::cast(result)));
2155  } else {
2156  return Local<String>();
2157  }
2158 }
2159 
2160 
2161 void Message::PrintCurrentStackTrace(Isolate* isolate, FILE* out) {
2162  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
2163  ENTER_V8(i_isolate);
2164  i_isolate->PrintCurrentStackTrace(out);
2165 }
2166 
2167 
2168 // --- S t a c k T r a c e ---
2169 
2171  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2172  ENTER_V8(isolate);
2173  EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
2175  i::Handle<i::Object> obj =
2176  i::Object::GetElementNoExceptionThrown(isolate, self, index);
2178  return scope.Escape(Utils::StackFrameToLocal(jsobj));
2179 }
2180 
2181 
2183  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2184  ENTER_V8(isolate);
2185  return i::Smi::cast(Utils::OpenHandle(this)->length())->value();
2186 }
2187 
2188 
2190  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2191  ENTER_V8(isolate);
2192  return Utils::ToLocal(Utils::OpenHandle(this));
2193 }
2194 
2195 
2197  Isolate* isolate,
2198  int frame_limit,
2199  StackTraceOptions options) {
2200  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
2201  ENTER_V8(i_isolate);
2202  i::Handle<i::JSArray> stackTrace =
2203  i_isolate->CaptureCurrentStackTrace(frame_limit, options);
2204  return Utils::StackTraceToLocal(stackTrace);
2205 }
2206 
2207 
2208 // --- S t a c k F r a m e ---
2209 
2211  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2212  ENTER_V8(isolate);
2213  i::HandleScope scope(isolate);
2215  i::Handle<i::Object> line = GetProperty(self, "lineNumber");
2216  if (!line->IsSmi()) {
2218  }
2219  return i::Smi::cast(*line)->value();
2220 }
2221 
2222 
2224  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2225  ENTER_V8(isolate);
2226  i::HandleScope scope(isolate);
2228  i::Handle<i::Object> column = GetProperty(self, "column");
2229  if (!column->IsSmi()) {
2230  return Message::kNoColumnInfo;
2231  }
2232  return i::Smi::cast(*column)->value();
2233 }
2234 
2235 
2237  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2238  ENTER_V8(isolate);
2239  i::HandleScope scope(isolate);
2241  i::Handle<i::Object> scriptId = GetProperty(self, "scriptId");
2242  if (!scriptId->IsSmi()) {
2243  return Message::kNoScriptIdInfo;
2244  }
2245  return i::Smi::cast(*scriptId)->value();
2246 }
2247 
2248 
2250  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2251  ENTER_V8(isolate);
2252  EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
2254  i::Handle<i::Object> name = GetProperty(self, "scriptName");
2255  if (!name->IsString()) {
2256  return Local<String>();
2257  }
2258  return scope.Escape(Local<String>::Cast(Utils::ToLocal(name)));
2259 }
2260 
2261 
2263  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2264  ENTER_V8(isolate);
2265  EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
2267  i::Handle<i::Object> name = GetProperty(self, "scriptNameOrSourceURL");
2268  if (!name->IsString()) {
2269  return Local<String>();
2270  }
2271  return scope.Escape(Local<String>::Cast(Utils::ToLocal(name)));
2272 }
2273 
2274 
2276  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2277  ENTER_V8(isolate);
2278  EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
2280  i::Handle<i::Object> name = GetProperty(self, "functionName");
2281  if (!name->IsString()) {
2282  return Local<String>();
2283  }
2284  return scope.Escape(Local<String>::Cast(Utils::ToLocal(name)));
2285 }
2286 
2287 
2288 bool StackFrame::IsEval() const {
2289  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2290  ENTER_V8(isolate);
2291  i::HandleScope scope(isolate);
2293  i::Handle<i::Object> is_eval = GetProperty(self, "isEval");
2294  return is_eval->IsTrue();
2295 }
2296 
2297 
2299  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2300  ENTER_V8(isolate);
2301  i::HandleScope scope(isolate);
2303  i::Handle<i::Object> is_constructor = GetProperty(self, "isConstructor");
2304  return is_constructor->IsTrue();
2305 }
2306 
2307 
2308 // --- J S O N ---
2309 
2311  i::Isolate* isolate = i::Isolate::Current();
2312  EnsureInitializedForIsolate(isolate, "v8::JSON::Parse");
2313  ENTER_V8(isolate);
2314  i::HandleScope scope(isolate);
2316  FlattenGetString(Utils::OpenHandle(*json_string)));
2317  EXCEPTION_PREAMBLE(isolate);
2318  i::Handle<i::Object> result;
2319  if (source->IsSeqOneByteString()) {
2320  result = i::JsonParser<true>::Parse(source);
2321  } else {
2322  result = i::JsonParser<false>::Parse(source);
2323  }
2324  has_pending_exception = result.is_null();
2326  return Utils::ToLocal(
2328 }
2329 
2330 
2331 // --- D a t a ---
2332 
2333 bool Value::FullIsUndefined() const {
2334  bool result = Utils::OpenHandle(this)->IsUndefined();
2335  ASSERT_EQ(result, QuickIsUndefined());
2336  return result;
2337 }
2338 
2339 
2340 bool Value::FullIsNull() const {
2341  bool result = Utils::OpenHandle(this)->IsNull();
2342  ASSERT_EQ(result, QuickIsNull());
2343  return result;
2344 }
2345 
2346 
2347 bool Value::IsTrue() const {
2348  return Utils::OpenHandle(this)->IsTrue();
2349 }
2350 
2351 
2352 bool Value::IsFalse() const {
2353  return Utils::OpenHandle(this)->IsFalse();
2354 }
2355 
2356 
2357 bool Value::IsFunction() const {
2358  return Utils::OpenHandle(this)->IsJSFunction();
2359 }
2360 
2361 
2362 bool Value::FullIsString() const {
2363  bool result = Utils::OpenHandle(this)->IsString();
2364  ASSERT_EQ(result, QuickIsString());
2365  return result;
2366 }
2367 
2368 
2369 bool Value::IsSymbol() const {
2370  return Utils::OpenHandle(this)->IsSymbol();
2371 }
2372 
2373 
2374 bool Value::IsArray() const {
2375  return Utils::OpenHandle(this)->IsJSArray();
2376 }
2377 
2378 
2379 bool Value::IsArrayBuffer() const {
2380  return Utils::OpenHandle(this)->IsJSArrayBuffer();
2381 }
2382 
2383 
2385  return Utils::OpenHandle(this)->IsJSArrayBufferView();
2386 }
2387 
2388 
2389 bool Value::IsTypedArray() const {
2390  return Utils::OpenHandle(this)->IsJSTypedArray();
2391 }
2392 
2393 
2394 #define VALUE_IS_TYPED_ARRAY(Type, typeName, TYPE, ctype, size) \
2395  bool Value::Is##Type##Array() const { \
2396  i::Handle<i::Object> obj = Utils::OpenHandle(this); \
2397  return obj->IsJSTypedArray() && \
2398  i::JSTypedArray::cast(*obj)->type() == kExternal##Type##Array; \
2399  }
2400 
2402 
2403 #undef VALUE_IS_TYPED_ARRAY
2404 
2405 
2406 bool Value::IsDataView() const {
2407  return Utils::OpenHandle(this)->IsJSDataView();
2408 }
2409 
2410 
2411 bool Value::IsObject() const {
2412  return Utils::OpenHandle(this)->IsJSObject();
2413 }
2414 
2415 
2416 bool Value::IsNumber() const {
2417  return Utils::OpenHandle(this)->IsNumber();
2418 }
2419 
2420 
2421 bool Value::IsBoolean() const {
2422  return Utils::OpenHandle(this)->IsBoolean();
2423 }
2424 
2425 
2426 bool Value::IsExternal() const {
2427  return Utils::OpenHandle(this)->IsExternal();
2428 }
2429 
2430 
2431 bool Value::IsInt32() const {
2433  if (obj->IsSmi()) return true;
2434  if (obj->IsNumber()) {
2435  return i::IsInt32Double(obj->Number());
2436  }
2437  return false;
2438 }
2439 
2440 
2441 bool Value::IsUint32() const {
2443  if (obj->IsSmi()) return i::Smi::cast(*obj)->value() >= 0;
2444  if (obj->IsNumber()) {
2445  double value = obj->Number();
2446  return !i::IsMinusZero(value) &&
2447  value >= 0 &&
2448  value <= i::kMaxUInt32 &&
2449  value == i::FastUI2D(i::FastD2UI(value));
2450  }
2451  return false;
2452 }
2453 
2454 
2455 bool Value::IsDate() const {
2456  i::Isolate* isolate = i::Isolate::Current();
2458  return obj->HasSpecificClassOf(isolate->heap()->Date_string());
2459 }
2460 
2461 
2463  i::Isolate* isolate = i::Isolate::Current();
2465  return obj->HasSpecificClassOf(isolate->heap()->String_string());
2466 }
2467 
2468 
2470  // TODO(svenpanne): these and other test functions should be written such
2471  // that they do not use Isolate::Current().
2472  i::Isolate* isolate = i::Isolate::Current();
2474  return obj->HasSpecificClassOf(isolate->heap()->Symbol_string());
2475 }
2476 
2477 
2479  i::Isolate* isolate = i::Isolate::Current();
2481  return obj->HasSpecificClassOf(isolate->heap()->Number_string());
2482 }
2483 
2484 
2485 static i::Object* LookupBuiltin(i::Isolate* isolate,
2486  const char* builtin_name) {
2487  i::Handle<i::String> string =
2488  isolate->factory()->InternalizeUtf8String(builtin_name);
2489  i::Handle<i::JSBuiltinsObject> builtins = isolate->js_builtins_object();
2490  return builtins->GetPropertyNoExceptionThrown(*string);
2491 }
2492 
2493 
2494 static bool CheckConstructor(i::Isolate* isolate,
2496  const char* class_name) {
2497  i::Object* constr = obj->map()->constructor();
2498  if (!constr->IsJSFunction()) return false;
2499  i::JSFunction* func = i::JSFunction::cast(constr);
2500  return func->shared()->native() &&
2501  constr == LookupBuiltin(isolate, class_name);
2502 }
2503 
2504 
2505 bool Value::IsNativeError() const {
2506  i::Isolate* isolate = i::Isolate::Current();
2508  if (obj->IsJSObject()) {
2510  return CheckConstructor(isolate, js_obj, "$Error") ||
2511  CheckConstructor(isolate, js_obj, "$EvalError") ||
2512  CheckConstructor(isolate, js_obj, "$RangeError") ||
2513  CheckConstructor(isolate, js_obj, "$ReferenceError") ||
2514  CheckConstructor(isolate, js_obj, "$SyntaxError") ||
2515  CheckConstructor(isolate, js_obj, "$TypeError") ||
2516  CheckConstructor(isolate, js_obj, "$URIError");
2517  } else {
2518  return false;
2519  }
2520 }
2521 
2522 
2524  i::Isolate* isolate = i::Isolate::Current();
2526  return obj->HasSpecificClassOf(isolate->heap()->Boolean_string());
2527 }
2528 
2529 
2530 bool Value::IsRegExp() const {
2532  return obj->IsJSRegExp();
2533 }
2534 
2535 
2539  if (obj->IsString()) {
2540  str = obj;
2541  } else {
2542  i::Isolate* isolate = i::Isolate::Current();
2543  LOG_API(isolate, "ToString");
2544  ENTER_V8(isolate);
2545  EXCEPTION_PREAMBLE(isolate);
2546  str = i::Execution::ToString(isolate, obj, &has_pending_exception);
2548  }
2549  return ToApiHandle<String>(str);
2550 }
2551 
2552 
2556  if (obj->IsString()) {
2557  str = obj;
2558  } else {
2559  i::Isolate* isolate = i::Isolate::Current();
2560  LOG_API(isolate, "ToDetailString");
2561  ENTER_V8(isolate);
2562  EXCEPTION_PREAMBLE(isolate);
2563  str = i::Execution::ToDetailString(isolate, obj, &has_pending_exception);
2565  }
2566  return ToApiHandle<String>(str);
2567 }
2568 
2569 
2573  if (obj->IsJSObject()) {
2574  val = obj;
2575  } else {
2576  i::Isolate* isolate = i::Isolate::Current();
2577  LOG_API(isolate, "ToObject");
2578  ENTER_V8(isolate);
2579  EXCEPTION_PREAMBLE(isolate);
2580  val = i::Execution::ToObject(isolate, obj, &has_pending_exception);
2582  }
2583  return ToApiHandle<Object>(val);
2584 }
2585 
2586 
2589  if (obj->IsBoolean()) {
2590  return ToApiHandle<Boolean>(obj);
2591  } else {
2592  i::Isolate* isolate = i::Isolate::Current();
2593  LOG_API(isolate, "ToBoolean");
2594  ENTER_V8(isolate);
2595  i::Handle<i::Object> val =
2596  isolate->factory()->ToBoolean(obj->BooleanValue());
2597  return ToApiHandle<Boolean>(val);
2598  }
2599 }
2600 
2601 
2605  if (obj->IsNumber()) {
2606  num = obj;
2607  } else {
2608  i::Isolate* isolate = i::Isolate::Current();
2609  LOG_API(isolate, "ToNumber");
2610  ENTER_V8(isolate);
2611  EXCEPTION_PREAMBLE(isolate);
2612  num = i::Execution::ToNumber(isolate, obj, &has_pending_exception);
2614  }
2615  return ToApiHandle<Number>(num);
2616 }
2617 
2618 
2622  if (obj->IsSmi()) {
2623  num = obj;
2624  } else {
2625  i::Isolate* isolate = i::Isolate::Current();
2626  LOG_API(isolate, "ToInteger");
2627  ENTER_V8(isolate);
2628  EXCEPTION_PREAMBLE(isolate);
2629  num = i::Execution::ToInteger(isolate, obj, &has_pending_exception);
2631  }
2632  return ToApiHandle<Integer>(num);
2633 }
2634 
2635 
2636 void i::Internals::CheckInitializedImpl(v8::Isolate* external_isolate) {
2637  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate);
2638  Utils::ApiCheck(isolate != NULL &&
2639  isolate->IsInitialized() &&
2640  !isolate->IsDead(),
2641  "v8::internal::Internals::CheckInitialized()",
2642  "Isolate is not initialized or V8 has died");
2643 }
2644 
2645 
2646 void External::CheckCast(v8::Value* that) {
2648  "v8::External::Cast()",
2649  "Could not convert to external");
2650 }
2651 
2652 
2653 void v8::Object::CheckCast(Value* that) {
2655  Utils::ApiCheck(obj->IsJSObject(),
2656  "v8::Object::Cast()",
2657  "Could not convert to object");
2658 }
2659 
2660 
2661 void v8::Function::CheckCast(Value* that) {
2663  Utils::ApiCheck(obj->IsJSFunction(),
2664  "v8::Function::Cast()",
2665  "Could not convert to function");
2666 }
2667 
2668 
2669 void v8::String::CheckCast(v8::Value* that) {
2671  Utils::ApiCheck(obj->IsString(),
2672  "v8::String::Cast()",
2673  "Could not convert to string");
2674 }
2675 
2676 
2677 void v8::Symbol::CheckCast(v8::Value* that) {
2679  Utils::ApiCheck(obj->IsSymbol(),
2680  "v8::Symbol::Cast()",
2681  "Could not convert to symbol");
2682 }
2683 
2684 
2685 void v8::Number::CheckCast(v8::Value* that) {
2687  Utils::ApiCheck(obj->IsNumber(),
2688  "v8::Number::Cast()",
2689  "Could not convert to number");
2690 }
2691 
2692 
2693 void v8::Integer::CheckCast(v8::Value* that) {
2695  Utils::ApiCheck(obj->IsNumber(),
2696  "v8::Integer::Cast()",
2697  "Could not convert to number");
2698 }
2699 
2700 
2701 void v8::Array::CheckCast(Value* that) {
2703  Utils::ApiCheck(obj->IsJSArray(),
2704  "v8::Array::Cast()",
2705  "Could not convert to array");
2706 }
2707 
2708 
2709 void v8::Promise::CheckCast(Value* that) {
2710  Utils::ApiCheck(that->IsPromise(),
2711  "v8::Promise::Cast()",
2712  "Could not convert to promise");
2713 }
2714 
2715 
2716 void v8::Promise::Resolver::CheckCast(Value* that) {
2717  Utils::ApiCheck(that->IsPromise(),
2718  "v8::Promise::Resolver::Cast()",
2719  "Could not convert to promise resolver");
2720 }
2721 
2722 
2723 void v8::ArrayBuffer::CheckCast(Value* that) {
2725  Utils::ApiCheck(obj->IsJSArrayBuffer(),
2726  "v8::ArrayBuffer::Cast()",
2727  "Could not convert to ArrayBuffer");
2728 }
2729 
2730 
2731 void v8::ArrayBufferView::CheckCast(Value* that) {
2733  Utils::ApiCheck(obj->IsJSArrayBufferView(),
2734  "v8::ArrayBufferView::Cast()",
2735  "Could not convert to ArrayBufferView");
2736 }
2737 
2738 
2739 void v8::TypedArray::CheckCast(Value* that) {
2741  Utils::ApiCheck(obj->IsJSTypedArray(),
2742  "v8::TypedArray::Cast()",
2743  "Could not convert to TypedArray");
2744 }
2745 
2746 
2747 #define CHECK_TYPED_ARRAY_CAST(Type, typeName, TYPE, ctype, size) \
2748  void v8::Type##Array::CheckCast(Value* that) { \
2749  i::Handle<i::Object> obj = Utils::OpenHandle(that); \
2750  Utils::ApiCheck(obj->IsJSTypedArray() && \
2751  i::JSTypedArray::cast(*obj)->type() == \
2752  kExternal##Type##Array, \
2753  "v8::" #Type "Array::Cast()", \
2754  "Could not convert to " #Type "Array"); \
2755  }
2756 
2757 
2759 
2760 #undef CHECK_TYPED_ARRAY_CAST
2761 
2762 
2763 void v8::DataView::CheckCast(Value* that) {
2765  Utils::ApiCheck(obj->IsJSDataView(),
2766  "v8::DataView::Cast()",
2767  "Could not convert to DataView");
2768 }
2769 
2770 
2771 void v8::Date::CheckCast(v8::Value* that) {
2772  i::Isolate* isolate = i::Isolate::Current();
2774  Utils::ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Date_string()),
2775  "v8::Date::Cast()",
2776  "Could not convert to date");
2777 }
2778 
2779 
2780 void v8::StringObject::CheckCast(v8::Value* that) {
2781  i::Isolate* isolate = i::Isolate::Current();
2783  Utils::ApiCheck(obj->HasSpecificClassOf(isolate->heap()->String_string()),
2784  "v8::StringObject::Cast()",
2785  "Could not convert to StringObject");
2786 }
2787 
2788 
2789 void v8::SymbolObject::CheckCast(v8::Value* that) {
2790  i::Isolate* isolate = i::Isolate::Current();
2792  Utils::ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Symbol_string()),
2793  "v8::SymbolObject::Cast()",
2794  "Could not convert to SymbolObject");
2795 }
2796 
2797 
2798 void v8::NumberObject::CheckCast(v8::Value* that) {
2799  i::Isolate* isolate = i::Isolate::Current();
2801  Utils::ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Number_string()),
2802  "v8::NumberObject::Cast()",
2803  "Could not convert to NumberObject");
2804 }
2805 
2806 
2807 void v8::BooleanObject::CheckCast(v8::Value* that) {
2808  i::Isolate* isolate = i::Isolate::Current();
2810  Utils::ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Boolean_string()),
2811  "v8::BooleanObject::Cast()",
2812  "Could not convert to BooleanObject");
2813 }
2814 
2815 
2816 void v8::RegExp::CheckCast(v8::Value* that) {
2818  Utils::ApiCheck(obj->IsJSRegExp(),
2819  "v8::RegExp::Cast()",
2820  "Could not convert to regular expression");
2821 }
2822 
2823 
2824 bool Value::BooleanValue() const {
2825  return Utils::OpenHandle(this)->BooleanValue();
2826 }
2827 
2828 
2829 double Value::NumberValue() const {
2832  if (obj->IsNumber()) {
2833  num = obj;
2834  } else {
2835  i::Isolate* isolate = i::Isolate::Current();
2836  LOG_API(isolate, "NumberValue");
2837  ENTER_V8(isolate);
2838  EXCEPTION_PREAMBLE(isolate);
2839  num = i::Execution::ToNumber(isolate, obj, &has_pending_exception);
2841  }
2842  return num->Number();
2843 }
2844 
2845 
2846 int64_t Value::IntegerValue() const {
2849  if (obj->IsNumber()) {
2850  num = obj;
2851  } else {
2852  i::Isolate* isolate = i::Isolate::Current();
2853  LOG_API(isolate, "IntegerValue");
2854  ENTER_V8(isolate);
2855  EXCEPTION_PREAMBLE(isolate);
2856  num = i::Execution::ToInteger(isolate, obj, &has_pending_exception);
2857  EXCEPTION_BAILOUT_CHECK(isolate, 0);
2858  }
2859  if (num->IsSmi()) {
2860  return i::Smi::cast(*num)->value();
2861  } else {
2862  return static_cast<int64_t>(num->Number());
2863  }
2864 }
2865 
2866 
2870  if (obj->IsSmi()) {
2871  num = obj;
2872  } else {
2873  i::Isolate* isolate = i::Isolate::Current();
2874  LOG_API(isolate, "ToInt32");
2875  ENTER_V8(isolate);
2876  EXCEPTION_PREAMBLE(isolate);
2877  num = i::Execution::ToInt32(isolate, obj, &has_pending_exception);
2879  }
2880  return ToApiHandle<Int32>(num);
2881 }
2882 
2883 
2887  if (obj->IsSmi()) {
2888  num = obj;
2889  } else {
2890  i::Isolate* isolate = i::Isolate::Current();
2891  LOG_API(isolate, "ToUInt32");
2892  ENTER_V8(isolate);
2893  EXCEPTION_PREAMBLE(isolate);
2894  num = i::Execution::ToUint32(isolate, obj, &has_pending_exception);
2896  }
2897  return ToApiHandle<Uint32>(num);
2898 }
2899 
2900 
2903  if (obj->IsSmi()) {
2904  if (i::Smi::cast(*obj)->value() >= 0) return Utils::Uint32ToLocal(obj);
2905  return Local<Uint32>();
2906  }
2907  i::Isolate* isolate = i::Isolate::Current();
2908  LOG_API(isolate, "ToArrayIndex");
2909  ENTER_V8(isolate);
2910  EXCEPTION_PREAMBLE(isolate);
2911  i::Handle<i::Object> string_obj =
2912  i::Execution::ToString(isolate, obj, &has_pending_exception);
2915  uint32_t index;
2916  if (str->AsArrayIndex(&index)) {
2917  i::Handle<i::Object> value;
2918  if (index <= static_cast<uint32_t>(i::Smi::kMaxValue)) {
2919  value = i::Handle<i::Object>(i::Smi::FromInt(index), isolate);
2920  } else {
2921  value = isolate->factory()->NewNumber(index);
2922  }
2923  return Utils::Uint32ToLocal(value);
2924  }
2925  return Local<Uint32>();
2926 }
2927 
2928 
2931  if (obj->IsSmi()) {
2932  return i::Smi::cast(*obj)->value();
2933  } else {
2934  i::Isolate* isolate = i::Isolate::Current();
2935  LOG_API(isolate, "Int32Value (slow)");
2936  ENTER_V8(isolate);
2937  EXCEPTION_PREAMBLE(isolate);
2938  i::Handle<i::Object> num =
2939  i::Execution::ToInt32(isolate, obj, &has_pending_exception);
2940  EXCEPTION_BAILOUT_CHECK(isolate, 0);
2941  if (num->IsSmi()) {
2942  return i::Smi::cast(*num)->value();
2943  } else {
2944  return static_cast<int32_t>(num->Number());
2945  }
2946  }
2947 }
2948 
2949 
2950 bool Value::Equals(Handle<Value> that) const {
2951  i::Isolate* isolate = i::Isolate::Current();
2952  if (!Utils::ApiCheck(this != NULL && !that.IsEmpty(),
2953  "v8::Value::Equals()",
2954  "Reading from empty handle")) {
2955  return false;
2956  }
2957  LOG_API(isolate, "Equals");
2958  ENTER_V8(isolate);
2960  i::Handle<i::Object> other = Utils::OpenHandle(*that);
2961  // If both obj and other are JSObjects, we'd better compare by identity
2962  // immediately when going into JS builtin. The reason is Invoke
2963  // would overwrite global object receiver with global proxy.
2964  if (obj->IsJSObject() && other->IsJSObject()) {
2965  return *obj == *other;
2966  }
2967  i::Handle<i::Object> args[] = { other };
2968  EXCEPTION_PREAMBLE(isolate);
2969  i::Handle<i::Object> result =
2970  CallV8HeapFunction("EQUALS", obj, ARRAY_SIZE(args), args,
2971  &has_pending_exception);
2972  EXCEPTION_BAILOUT_CHECK(isolate, false);
2973  return *result == i::Smi::FromInt(i::EQUAL);
2974 }
2975 
2976 
2978  i::Isolate* isolate = i::Isolate::Current();
2979  if (!Utils::ApiCheck(this != NULL && !that.IsEmpty(),
2980  "v8::Value::StrictEquals()",
2981  "Reading from empty handle")) {
2982  return false;
2983  }
2984  LOG_API(isolate, "StrictEquals");
2986  i::Handle<i::Object> other = Utils::OpenHandle(*that);
2987  // Must check HeapNumber first, since NaN !== NaN.
2988  if (obj->IsHeapNumber()) {
2989  if (!other->IsNumber()) return false;
2990  double x = obj->Number();
2991  double y = other->Number();
2992  // Must check explicitly for NaN:s on Windows, but -0 works fine.
2993  return x == y && !std::isnan(x) && !std::isnan(y);
2994  } else if (*obj == *other) { // Also covers Booleans.
2995  return true;
2996  } else if (obj->IsSmi()) {
2997  return other->IsNumber() && obj->Number() == other->Number();
2998  } else if (obj->IsString()) {
2999  return other->IsString() &&
3000  i::String::cast(*obj)->Equals(i::String::cast(*other));
3001  } else if (obj->IsUndefined() || obj->IsUndetectableObject()) {
3002  return other->IsUndefined() || other->IsUndetectableObject();
3003  } else {
3004  return false;
3005  }
3006 }
3007 
3008 
3010  i::Isolate* isolate = i::Isolate::Current();
3011  if (!Utils::ApiCheck(this != NULL && !that.IsEmpty(),
3012  "v8::Value::SameValue()",
3013  "Reading from empty handle")) {
3014  return false;
3015  }
3016  LOG_API(isolate, "SameValue");
3018  i::Handle<i::Object> other = Utils::OpenHandle(*that);
3019  return obj->SameValue(*other);
3020 }
3021 
3022 
3023 uint32_t Value::Uint32Value() const {
3025  if (obj->IsSmi()) {
3026  return i::Smi::cast(*obj)->value();
3027  } else {
3028  i::Isolate* isolate = i::Isolate::Current();
3029  LOG_API(isolate, "Uint32Value");
3030  ENTER_V8(isolate);
3031  EXCEPTION_PREAMBLE(isolate);
3032  i::Handle<i::Object> num =
3033  i::Execution::ToUint32(isolate, obj, &has_pending_exception);
3034  EXCEPTION_BAILOUT_CHECK(isolate, 0);
3035  if (num->IsSmi()) {
3036  return i::Smi::cast(*num)->value();
3037  } else {
3038  return static_cast<uint32_t>(num->Number());
3039  }
3040  }
3041 }
3042 
3043 
3045  v8::PropertyAttribute attribs) {
3046  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3047  ON_BAILOUT(isolate, "v8::Object::Set()", return false);
3048  ENTER_V8(isolate);
3049  i::HandleScope scope(isolate);
3051  i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3052  i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
3053  EXCEPTION_PREAMBLE(isolate);
3055  isolate,
3056  self,
3057  key_obj,
3058  value_obj,
3059  static_cast<PropertyAttributes>(attribs),
3060  i::SLOPPY);
3061  has_pending_exception = obj.is_null();
3062  EXCEPTION_BAILOUT_CHECK(isolate, false);
3063  return true;
3064 }
3065 
3066 
3067 bool v8::Object::Set(uint32_t index, v8::Handle<Value> value) {
3068  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3069  ON_BAILOUT(isolate, "v8::Object::Set()", return false);
3070  ENTER_V8(isolate);
3071  i::HandleScope scope(isolate);
3073  i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
3074  EXCEPTION_PREAMBLE(isolate);
3076  self,
3077  index,
3078  value_obj,
3079  NONE,
3080  i::SLOPPY);
3081  has_pending_exception = obj.is_null();
3082  EXCEPTION_BAILOUT_CHECK(isolate, false);
3083  return true;
3084 }
3085 
3086 
3088  v8::Handle<Value> value,
3089  v8::PropertyAttribute attribs) {
3090  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3091  ON_BAILOUT(isolate, "v8::Object::ForceSet()", return false);
3092  ENTER_V8(isolate);
3093  i::HandleScope scope(isolate);
3095  i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3096  i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
3097  EXCEPTION_PREAMBLE(isolate);
3099  self,
3100  key_obj,
3101  value_obj,
3102  static_cast<PropertyAttributes>(attribs));
3103  has_pending_exception = obj.is_null();
3104  EXCEPTION_BAILOUT_CHECK(isolate, false);
3105  return true;
3106 }
3107 
3108 
3110  return Set(v8::Handle<Value>(reinterpret_cast<Value*>(*key)),
3111  value, DontEnum);
3112 }
3113 
3114 
3116  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3117  ON_BAILOUT(isolate, "v8::Object::ForceDelete()", return false);
3118  ENTER_V8(isolate);
3119  i::HandleScope scope(isolate);
3121  i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3122 
3123  // When deleting a property on the global object using ForceDelete
3124  // deoptimize all functions as optimized code does not check for the hole
3125  // value with DontDelete properties. We have to deoptimize all contexts
3126  // because of possible cross-context inlined functions.
3127  if (self->IsJSGlobalProxy() || self->IsGlobalObject()) {
3129  }
3130 
3131  EXCEPTION_PREAMBLE(isolate);
3132  i::Handle<i::Object> obj = i::ForceDeleteProperty(self, key_obj);
3133  has_pending_exception = obj.is_null();
3134  EXCEPTION_BAILOUT_CHECK(isolate, false);
3135  return obj->IsTrue();
3136 }
3137 
3138 
3140  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3141  ON_BAILOUT(isolate, "v8::Object::Get()", return Local<v8::Value>());
3142  ENTER_V8(isolate);
3144  i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3145  EXCEPTION_PREAMBLE(isolate);
3146  i::Handle<i::Object> result = i::GetProperty(isolate, self, key_obj);
3147  has_pending_exception = result.is_null();
3149  return Utils::ToLocal(result);
3150 }
3151 
3152 
3154  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3155  ON_BAILOUT(isolate, "v8::Object::Get()", return Local<v8::Value>());
3156  ENTER_V8(isolate);
3158  EXCEPTION_PREAMBLE(isolate);
3159  i::Handle<i::Object> result = i::Object::GetElement(isolate, self, index);
3160  has_pending_exception = result.is_null();
3162  return Utils::ToLocal(result);
3163 }
3164 
3165 
3167  return Get(v8::Handle<Value>(reinterpret_cast<Value*>(*key)));
3168 }
3169 
3170 
3172  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3173  ON_BAILOUT(isolate, "v8::Object::GetPropertyAttribute()",
3174  return static_cast<PropertyAttribute>(NONE));
3175  ENTER_V8(isolate);
3176  i::HandleScope scope(isolate);
3178  i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3179  if (!key_obj->IsName()) {
3180  EXCEPTION_PREAMBLE(isolate);
3181  key_obj = i::Execution::ToString(isolate, key_obj, &has_pending_exception);
3182  EXCEPTION_BAILOUT_CHECK(isolate, static_cast<PropertyAttribute>(NONE));
3183  }
3184  i::Handle<i::Name> key_name = i::Handle<i::Name>::cast(key_obj);
3185  PropertyAttributes result =
3186  i::JSReceiver::GetPropertyAttribute(self, key_name);
3187  if (result == ABSENT) return static_cast<PropertyAttribute>(NONE);
3188  return static_cast<PropertyAttribute>(result);
3189 }
3190 
3191 
3193  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3194  ON_BAILOUT(isolate, "v8::Object::GetPrototype()",
3195  return Local<v8::Value>());
3196  ENTER_V8(isolate);
3198  i::Handle<i::Object> result(self->GetPrototype(isolate), isolate);
3199  return Utils::ToLocal(result);
3200 }
3201 
3202 
3204  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3205  ON_BAILOUT(isolate, "v8::Object::SetPrototype()", return false);
3206  ENTER_V8(isolate);
3208  i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
3209  // We do not allow exceptions thrown while setting the prototype
3210  // to propagate outside.
3211  TryCatch try_catch;
3212  EXCEPTION_PREAMBLE(isolate);
3213  i::Handle<i::Object> result = i::JSObject::SetPrototype(self, value_obj);
3214  has_pending_exception = result.is_null();
3215  EXCEPTION_BAILOUT_CHECK(isolate, false);
3216  return true;
3217 }
3218 
3219 
3222  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3223  ON_BAILOUT(isolate,
3224  "v8::Object::FindInstanceInPrototypeChain()",
3225  return Local<v8::Object>());
3226  ENTER_V8(isolate);
3227  i::JSObject* object = *Utils::OpenHandle(this);
3228  i::FunctionTemplateInfo* tmpl_info = *Utils::OpenHandle(*tmpl);
3229  while (!tmpl_info->IsTemplateFor(object)) {
3230  i::Object* prototype = object->GetPrototype();
3231  if (!prototype->IsJSObject()) return Local<Object>();
3232  object = i::JSObject::cast(prototype);
3233  }
3234  return Utils::ToLocal(i::Handle<i::JSObject>(object));
3235 }
3236 
3237 
3239  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3240  ON_BAILOUT(isolate, "v8::Object::GetPropertyNames()",
3241  return Local<v8::Array>());
3242  ENTER_V8(isolate);
3243  i::HandleScope scope(isolate);
3245  bool threw = false;
3246  i::Handle<i::FixedArray> value =
3248  if (threw) return Local<v8::Array>();
3249  // Because we use caching to speed up enumeration it is important
3250  // to never change the result of the basic enumeration function so
3251  // we clone the result.
3252  i::Handle<i::FixedArray> elms = isolate->factory()->CopyFixedArray(value);
3253  i::Handle<i::JSArray> result =
3254  isolate->factory()->NewJSArrayWithElements(elms);
3255  return Utils::ToLocal(scope.CloseAndEscape(result));
3256 }
3257 
3258 
3260  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3261  ON_BAILOUT(isolate, "v8::Object::GetOwnPropertyNames()",
3262  return Local<v8::Array>());
3263  ENTER_V8(isolate);
3264  i::HandleScope scope(isolate);
3266  bool threw = false;
3267  i::Handle<i::FixedArray> value =
3269  if (threw) return Local<v8::Array>();
3270  // Because we use caching to speed up enumeration it is important
3271  // to never change the result of the basic enumeration function so
3272  // we clone the result.
3273  i::Handle<i::FixedArray> elms = isolate->factory()->CopyFixedArray(value);
3274  i::Handle<i::JSArray> result =
3275  isolate->factory()->NewJSArrayWithElements(elms);
3276  return Utils::ToLocal(scope.CloseAndEscape(result));
3277 }
3278 
3279 
3281  i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate();
3282  Isolate* isolate = reinterpret_cast<Isolate*>(i_isolate);
3283  ON_BAILOUT(i_isolate, "v8::Object::ObjectProtoToString()",
3284  return Local<v8::String>());
3285  ENTER_V8(i_isolate);
3287 
3288  i::Handle<i::Object> name(self->class_name(), i_isolate);
3289 
3290  // Native implementation of Object.prototype.toString (v8natives.js):
3291  // var c = %_ClassOf(this);
3292  // if (c === 'Arguments') c = 'Object';
3293  // return "[object " + c + "]";
3294 
3295  if (!name->IsString()) {
3296  return v8::String::NewFromUtf8(isolate, "[object ]");
3297  } else {
3299  if (class_name->IsOneByteEqualTo(STATIC_ASCII_VECTOR("Arguments"))) {
3300  return v8::String::NewFromUtf8(isolate, "[object Object]");
3301  } else {
3302  const char* prefix = "[object ";
3303  Local<String> str = Utils::ToLocal(class_name);
3304  const char* postfix = "]";
3305 
3306  int prefix_len = i::StrLength(prefix);
3307  int str_len = str->Utf8Length();
3308  int postfix_len = i::StrLength(postfix);
3309 
3310  int buf_len = prefix_len + str_len + postfix_len;
3311  i::ScopedVector<char> buf(buf_len);
3312 
3313  // Write prefix.
3314  char* ptr = buf.start();
3315  i::OS::MemCopy(ptr, prefix, prefix_len * v8::internal::kCharSize);
3316  ptr += prefix_len;
3317 
3318  // Write real content.
3319  str->WriteUtf8(ptr, str_len);
3320  ptr += str_len;
3321 
3322  // Write postfix.
3323  i::OS::MemCopy(ptr, postfix, postfix_len * v8::internal::kCharSize);
3324 
3325  // Copy the buffer into a heap-allocated string and return it.
3327  isolate, buf.start(), String::kNormalString, buf_len);
3328  return result;
3329  }
3330  }
3331 }
3332 
3333 
3335  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3336  ON_BAILOUT(isolate, "v8::Object::GetConstructor()",
3337  return Local<v8::Function>());
3338  ENTER_V8(isolate);
3340  i::Handle<i::Object> constructor(self->GetConstructor(), isolate);
3341  return Utils::ToLocal(constructor);
3342 }
3343 
3344 
3346  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3347  ON_BAILOUT(isolate, "v8::Object::GetConstructorName()",
3348  return Local<v8::String>());
3349  ENTER_V8(isolate);
3351  i::Handle<i::String> name(self->constructor_name());
3352  return Utils::ToLocal(name);
3353 }
3354 
3355 
3357  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3358  ON_BAILOUT(isolate, "v8::Object::Delete()", return false);
3359  ENTER_V8(isolate);
3360  i::HandleScope scope(isolate);
3362  i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3363  EXCEPTION_PREAMBLE(isolate);
3364  i::Handle<i::Object> obj = i::DeleteProperty(self, key_obj);
3365  has_pending_exception = obj.is_null();
3366  EXCEPTION_BAILOUT_CHECK(isolate, false);
3367  return obj->IsTrue();
3368 }
3369 
3370 
3372  return Delete(v8::Handle<Value>(reinterpret_cast<Value*>(*key)));
3373 }
3374 
3375 
3377  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3378  ON_BAILOUT(isolate, "v8::Object::Has()", return false);
3379  ENTER_V8(isolate);
3381  i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3382  EXCEPTION_PREAMBLE(isolate);
3383  i::Handle<i::Object> obj = i::HasProperty(self, key_obj);
3384  has_pending_exception = obj.is_null();
3385  EXCEPTION_BAILOUT_CHECK(isolate, false);
3386  return obj->IsTrue();
3387 }
3388 
3389 
3391  return Has(v8::Handle<Value>(reinterpret_cast<Value*>(*key)));
3392 }
3393 
3394 
3395 bool v8::Object::Delete(uint32_t index) {
3396  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3397  ON_BAILOUT(isolate, "v8::Object::DeleteProperty()",
3398  return false);
3399  ENTER_V8(isolate);
3400  HandleScope scope(reinterpret_cast<Isolate*>(isolate));
3402  return i::JSReceiver::DeleteElement(self, index)->IsTrue();
3403 }
3404 
3405 
3406 bool v8::Object::Has(uint32_t index) {
3407  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3408  ON_BAILOUT(isolate, "v8::Object::HasProperty()", return false);
3410  return i::JSReceiver::HasElement(self, index);
3411 }
3412 
3413 
3414 template<typename Setter, typename Getter, typename Data>
3415 static inline bool ObjectSetAccessor(Object* obj,
3416  Handle<String> name,
3417  Setter getter,
3418  Getter setter,
3419  Data data,
3420  AccessControl settings,
3421  PropertyAttribute attributes) {
3422  i::Isolate* isolate = Utils::OpenHandle(obj)->GetIsolate();
3423  ON_BAILOUT(isolate, "v8::Object::SetAccessor()", return false);
3424  ENTER_V8(isolate);
3425  i::HandleScope scope(isolate);
3427  i::Handle<i::AccessorInfo> info = MakeAccessorInfo(
3428  name, getter, setter, data, settings, attributes, signature);
3429  if (info.is_null()) return false;
3430  bool fast = Utils::OpenHandle(obj)->HasFastProperties();
3431  i::Handle<i::Object> result =
3433  if (result.is_null() || result->IsUndefined()) return false;
3435  return true;
3436 }
3437 
3438 
3440  AccessorGetterCallback getter,
3441  AccessorSetterCallback setter,
3442  v8::Handle<Value> data,
3443  AccessControl settings,
3444  PropertyAttribute attributes) {
3445  return ObjectSetAccessor(
3446  this, name, getter, setter, data, settings, attributes);
3447 }
3448 
3449 
3452  PropertyAttribute attributes,
3453  AccessControl settings) {
3454  void* null = NULL;
3455  return ObjectSetAccessor(
3456  this, name, descriptor, null, null, settings, attributes);
3457 }
3458 
3459 
3461  Local<Function> getter,
3462  Handle<Function> setter,
3463  PropertyAttribute attribute,
3464  AccessControl settings) {
3465  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3466  ON_BAILOUT(isolate, "v8::Object::SetAccessorProperty()", return);
3467  ENTER_V8(isolate);
3468  i::HandleScope scope(isolate);
3469  i::Handle<i::Object> getter_i = v8::Utils::OpenHandle(*getter);
3470  i::Handle<i::Object> setter_i = v8::Utils::OpenHandle(*setter, true);
3471  if (setter_i.is_null()) setter_i = isolate->factory()->null_value();
3473  v8::Utils::OpenHandle(*name),
3474  getter_i,
3475  setter_i,
3476  static_cast<PropertyAttributes>(attribute),
3477  settings);
3478 }
3479 
3480 
3482  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3483  ON_BAILOUT(isolate, "v8::Object::HasOwnProperty()",
3484  return false);
3486  Utils::OpenHandle(this), Utils::OpenHandle(*key));
3487 }
3488 
3489 
3491  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3492  ON_BAILOUT(isolate, "v8::Object::HasRealNamedProperty()",
3493  return false);
3495  Utils::OpenHandle(*key));
3496 }
3497 
3498 
3500  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3501  ON_BAILOUT(isolate, "v8::Object::HasRealIndexedProperty()",
3502  return false);
3504 }
3505 
3506 
3508  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3509  ON_BAILOUT(isolate,
3510  "v8::Object::HasRealNamedCallbackProperty()",
3511  return false);
3512  ENTER_V8(isolate);
3514  Utils::OpenHandle(*key));
3515 }
3516 
3517 
3519  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3520  ON_BAILOUT(isolate, "v8::Object::HasNamedLookupInterceptor()",
3521  return false);
3522  return Utils::OpenHandle(this)->HasNamedInterceptor();
3523 }
3524 
3525 
3527  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3528  ON_BAILOUT(isolate, "v8::Object::HasIndexedLookupInterceptor()",
3529  return false);
3530  return Utils::OpenHandle(this)->HasIndexedInterceptor();
3531 }
3532 
3533 
3534 static Local<Value> GetPropertyByLookup(i::Isolate* isolate,
3535  i::Handle<i::JSObject> receiver,
3536  i::Handle<i::String> name,
3537  i::LookupResult* lookup) {
3538  if (!lookup->IsProperty()) {
3539  // No real property was found.
3540  return Local<Value>();
3541  }
3542 
3543  // If the property being looked up is a callback, it can throw
3544  // an exception.
3545  EXCEPTION_PREAMBLE(isolate);
3546  PropertyAttributes ignored;
3547  i::Handle<i::Object> result =
3548  i::Object::GetProperty(receiver, receiver, lookup, name,
3549  &ignored);
3550  has_pending_exception = result.is_null();
3551  EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
3552 
3553  return Utils::ToLocal(result);
3554 }
3555 
3556 
3558  Handle<String> key) {
3559  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3560  ON_BAILOUT(isolate,
3561  "v8::Object::GetRealNamedPropertyInPrototypeChain()",
3562  return Local<Value>());
3563  ENTER_V8(isolate);
3564  i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this);
3565  i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
3566  i::LookupResult lookup(isolate);
3567  self_obj->LookupRealNamedPropertyInPrototypes(*key_obj, &lookup);
3568  return GetPropertyByLookup(isolate, self_obj, key_obj, &lookup);
3569 }
3570 
3571 
3573  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3574  ON_BAILOUT(isolate, "v8::Object::GetRealNamedProperty()",
3575  return Local<Value>());
3576  ENTER_V8(isolate);
3577  i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this);
3578  i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
3579  i::LookupResult lookup(isolate);
3580  self_obj->LookupRealNamedProperty(*key_obj, &lookup);
3581  return GetPropertyByLookup(isolate, self_obj, key_obj, &lookup);
3582 }
3583 
3584 
3585 // Turns on access checks by copying the map and setting the check flag.
3586 // Because the object gets a new map, existing inline cache caching
3587 // the old map of this object will fail.
3589  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3590  ON_BAILOUT(isolate, "v8::Object::TurnOnAccessCheck()", return);
3591  ENTER_V8(isolate);
3592  i::HandleScope scope(isolate);
3594 
3595  // When turning on access checks for a global object deoptimize all functions
3596  // as optimized code does not always handle access checks.
3598 
3599  i::Handle<i::Map> new_map =
3600  isolate->factory()->CopyMap(i::Handle<i::Map>(obj->map()));
3601  new_map->set_is_access_check_needed(true);
3602  obj->set_map(*new_map);
3603 }
3604 
3605 
3607  return Utils::OpenHandle(this)->IsDirty();
3608 }
3609 
3610 
3612  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3613  ON_BAILOUT(isolate, "v8::Object::Clone()", return Local<Object>());
3614  ENTER_V8(isolate);
3616  EXCEPTION_PREAMBLE(isolate);
3618  has_pending_exception = result.is_null();
3620  return Utils::ToLocal(result);
3621 }
3622 
3623 
3624 static i::Context* GetCreationContext(i::JSObject* object) {
3625  i::Object* constructor = object->map()->constructor();
3626  i::JSFunction* function;
3627  if (!constructor->IsJSFunction()) {
3628  // Functions have null as a constructor,
3629  // but any JSFunction knows its context immediately.
3630  ASSERT(object->IsJSFunction());
3631  function = i::JSFunction::cast(object);
3632  } else {
3633  function = i::JSFunction::cast(constructor);
3634  }
3635  return function->context()->native_context();
3636 }
3637 
3638 
3640  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3641  ON_BAILOUT(isolate,
3642  "v8::Object::CreationContext()", return Local<v8::Context>());
3643  ENTER_V8(isolate);
3645  i::Context* context = GetCreationContext(*self);
3646  return Utils::ToLocal(i::Handle<i::Context>(context));
3647 }
3648 
3649 
3651  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3652  ON_BAILOUT(isolate, "v8::Object::GetIdentityHash()", return 0);
3653  ENTER_V8(isolate);
3654  i::HandleScope scope(isolate);
3656  return i::Handle<i::Smi>::cast(
3658 }
3659 
3660 
3662  v8::Handle<v8::Value> value) {
3663  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3664  ON_BAILOUT(isolate, "v8::Object::SetHiddenValue()", return false);
3665  if (value.IsEmpty()) return DeleteHiddenValue(key);
3666  ENTER_V8(isolate);
3667  i::HandleScope scope(isolate);
3669  i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
3670  i::Handle<i::String> key_string =
3671  isolate->factory()->InternalizeString(key_obj);
3672  i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
3673  i::Handle<i::Object> result =
3674  i::JSObject::SetHiddenProperty(self, key_string, value_obj);
3675  return *result == *self;
3676 }
3677 
3678 
3680  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3681  ON_BAILOUT(isolate, "v8::Object::GetHiddenValue()",
3682  return Local<v8::Value>());
3683  ENTER_V8(isolate);
3685  i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
3686  i::Handle<i::String> key_string =
3687  isolate->factory()->InternalizeString(key_obj);
3688  i::Handle<i::Object> result(self->GetHiddenProperty(*key_string), isolate);
3689  if (result->IsTheHole()) return v8::Local<v8::Value>();
3690  return Utils::ToLocal(result);
3691 }
3692 
3693 
3695  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3696  ON_BAILOUT(isolate, "v8::DeleteHiddenValue()", return false);
3697  ENTER_V8(isolate);
3698  i::HandleScope scope(isolate);
3700  i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
3701  i::Handle<i::String> key_string =
3702  isolate->factory()->InternalizeString(key_obj);
3703  i::JSObject::DeleteHiddenProperty(self, key_string);
3704  return true;
3705 }
3706 
3707 
3708 namespace {
3709 
3710 static i::ElementsKind GetElementsKindFromExternalArrayType(
3711  ExternalArrayType array_type) {
3712  switch (array_type) {
3713 #define ARRAY_TYPE_TO_ELEMENTS_KIND(Type, type, TYPE, ctype, size) \
3714  case kExternal##Type##Array: \
3715  return i::EXTERNAL_##TYPE##_ELEMENTS;
3716 
3718 #undef ARRAY_TYPE_TO_ELEMENTS_KIND
3719  }
3720  UNREACHABLE();
3721  return i::DICTIONARY_ELEMENTS;
3722 }
3723 
3724 
3725 void PrepareExternalArrayElements(i::Handle<i::JSObject> object,
3726  void* data,
3727  ExternalArrayType array_type,
3728  int length) {
3729  i::Isolate* isolate = object->GetIsolate();
3731  isolate->factory()->NewExternalArray(length, array_type, data);
3732 
3733  i::Handle<i::Map> external_array_map =
3735  object,
3736  GetElementsKindFromExternalArrayType(array_type));
3737 
3738  object->set_map(*external_array_map);
3739  object->set_elements(*array);
3740 }
3741 
3742 } // namespace
3743 
3744 
3745 void v8::Object::SetIndexedPropertiesToPixelData(uint8_t* data, int length) {
3746  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3747  ON_BAILOUT(isolate, "v8::SetElementsToPixelData()", return);
3748  ENTER_V8(isolate);
3749  i::HandleScope scope(isolate);
3750  if (!Utils::ApiCheck(length >= 0 &&
3752  "v8::Object::SetIndexedPropertiesToPixelData()",
3753  "length exceeds max acceptable value")) {
3754  return;
3755  }
3757  if (!Utils::ApiCheck(!self->IsJSArray(),
3758  "v8::Object::SetIndexedPropertiesToPixelData()",
3759  "JSArray is not supported")) {
3760  return;
3761  }
3762  PrepareExternalArrayElements(self, data, kExternalUint8ClampedArray, length);
3763 }
3764 
3765 
3768  ON_BAILOUT(self->GetIsolate(), "v8::HasIndexedPropertiesInPixelData()",
3769  return false);
3770  return self->HasExternalUint8ClampedElements();
3771 }
3772 
3773 
3776  ON_BAILOUT(self->GetIsolate(), "v8::GetIndexedPropertiesPixelData()",
3777  return NULL);
3778  if (self->HasExternalUint8ClampedElements()) {
3779  return i::ExternalUint8ClampedArray::cast(self->elements())->
3780  external_uint8_clamped_pointer();
3781  } else {
3782  return NULL;
3783  }
3784 }
3785 
3786 
3789  ON_BAILOUT(self->GetIsolate(), "v8::GetIndexedPropertiesPixelDataLength()",
3790  return -1);
3791  if (self->HasExternalUint8ClampedElements()) {
3792  return i::ExternalUint8ClampedArray::cast(self->elements())->length();
3793  } else {
3794  return -1;
3795  }
3796 }
3797 
3798 
3800  void* data,
3801  ExternalArrayType array_type,
3802  int length) {
3803  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3804  ON_BAILOUT(isolate, "v8::SetIndexedPropertiesToExternalArrayData()", return);
3805  ENTER_V8(isolate);
3806  i::HandleScope scope(isolate);
3807  if (!Utils::ApiCheck(length >= 0 && length <= i::ExternalArray::kMaxLength,
3808  "v8::Object::SetIndexedPropertiesToExternalArrayData()",
3809  "length exceeds max acceptable value")) {
3810  return;
3811  }
3813  if (!Utils::ApiCheck(!self->IsJSArray(),
3814  "v8::Object::SetIndexedPropertiesToExternalArrayData()",
3815  "JSArray is not supported")) {
3816  return;
3817  }
3818  PrepareExternalArrayElements(self, data, array_type, length);
3819 }
3820 
3821 
3824  ON_BAILOUT(self->GetIsolate(),
3825  "v8::HasIndexedPropertiesInExternalArrayData()",
3826  return false);
3827  return self->HasExternalArrayElements();
3828 }
3829 
3830 
3833  ON_BAILOUT(self->GetIsolate(),
3834  "v8::GetIndexedPropertiesExternalArrayData()",
3835  return NULL);
3836  if (self->HasExternalArrayElements()) {
3837  return i::ExternalArray::cast(self->elements())->external_pointer();
3838  } else {
3839  return NULL;
3840  }
3841 }
3842 
3843 
3846  ON_BAILOUT(self->GetIsolate(),
3847  "v8::GetIndexedPropertiesExternalArrayDataType()",
3848  return static_cast<ExternalArrayType>(-1));
3849  switch (self->elements()->map()->instance_type()) {
3850 #define INSTANCE_TYPE_TO_ARRAY_TYPE(Type, type, TYPE, ctype, size) \
3851  case i::EXTERNAL_##TYPE##_ARRAY_TYPE: \
3852  return kExternal##Type##Array;
3854 #undef INSTANCE_TYPE_TO_ARRAY_TYPE
3855  default:
3856  return static_cast<ExternalArrayType>(-1);
3857  }
3858 }
3859 
3860 
3863  ON_BAILOUT(self->GetIsolate(),
3864  "v8::GetIndexedPropertiesExternalArrayDataLength()",
3865  return 0);
3866  if (self->HasExternalArrayElements()) {
3867  return i::ExternalArray::cast(self->elements())->length();
3868  } else {
3869  return -1;
3870  }
3871 }
3872 
3873 
3875  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3876  ON_BAILOUT(isolate, "v8::Object::IsCallable()", return false);
3877  ENTER_V8(isolate);
3878  i::HandleScope scope(isolate);
3880  return obj->IsCallable();
3881 }
3882 
3883 
3885  int argc,
3886  v8::Handle<v8::Value> argv[]) {
3887  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3888  ON_BAILOUT(isolate, "v8::Object::CallAsFunction()",
3889  return Local<v8::Value>());
3890  LOG_API(isolate, "Object::CallAsFunction");
3891  ENTER_V8(isolate);
3892  i::Logger::TimerEventScope timer_scope(
3893  isolate, i::Logger::TimerEventScope::v8_execute);
3894  i::HandleScope scope(isolate);
3896  i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv);
3897  STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**));
3898  i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
3900  if (obj->IsJSFunction()) {
3901  fun = i::Handle<i::JSFunction>::cast(obj);
3902  } else {
3903  EXCEPTION_PREAMBLE(isolate);
3905  isolate, obj, &has_pending_exception);
3907  fun = i::Handle<i::JSFunction>::cast(delegate);
3908  recv_obj = obj;
3909  }
3910  EXCEPTION_PREAMBLE(isolate);
3912  isolate, fun, recv_obj, argc, args, &has_pending_exception, true);
3914  return Utils::ToLocal(scope.CloseAndEscape(returned));
3915 }
3916 
3917 
3919  v8::Handle<v8::Value> argv[]) {
3920  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3921  ON_BAILOUT(isolate, "v8::Object::CallAsConstructor()",
3922  return Local<v8::Object>());
3923  LOG_API(isolate, "Object::CallAsConstructor");
3924  ENTER_V8(isolate);
3925  i::Logger::TimerEventScope timer_scope(
3926  isolate, i::Logger::TimerEventScope::v8_execute);
3927  i::HandleScope scope(isolate);
3929  STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**));
3930  i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
3931  if (obj->IsJSFunction()) {
3933  EXCEPTION_PREAMBLE(isolate);
3934  i::Handle<i::Object> returned =
3935  i::Execution::New(fun, argc, args, &has_pending_exception);
3937  return Utils::ToLocal(scope.CloseAndEscape(
3938  i::Handle<i::JSObject>::cast(returned)));
3939  }
3940  EXCEPTION_PREAMBLE(isolate);
3942  isolate, obj, &has_pending_exception);
3944  if (!delegate->IsUndefined()) {
3946  EXCEPTION_PREAMBLE(isolate);
3948  isolate, fun, obj, argc, args, &has_pending_exception);
3950  ASSERT(!delegate->IsUndefined());
3951  return Utils::ToLocal(scope.CloseAndEscape(returned));
3952  }
3953  return Local<v8::Object>();
3954 }
3955 
3956 
3958  FunctionCallback callback,
3959  Local<Value> data,
3960  int length) {
3961  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
3962  LOG_API(isolate, "Function::New");
3963  ENTER_V8(isolate);
3964  return FunctionTemplateNew(
3965  isolate, callback, data, Local<Signature>(), length, true)->
3966  GetFunction();
3967 }
3968 
3969 
3971  return NewInstance(0, NULL);
3972 }
3973 
3974 
3976  v8::Handle<v8::Value> argv[]) const {
3977  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3978  ON_BAILOUT(isolate, "v8::Function::NewInstance()",
3979  return Local<v8::Object>());
3980  LOG_API(isolate, "Function::NewInstance");
3981  ENTER_V8(isolate);
3982  i::Logger::TimerEventScope timer_scope(
3983  isolate, i::Logger::TimerEventScope::v8_execute);
3984  EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
3986  STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**));
3987  i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
3988  EXCEPTION_PREAMBLE(isolate);
3989  i::Handle<i::Object> returned =
3990  i::Execution::New(function, argc, args, &has_pending_exception);
3992  return scope.Escape(Utils::ToLocal(i::Handle<i::JSObject>::cast(returned)));
3993 }
3994 
3995 
3997  v8::Handle<v8::Value> argv[]) {
3998  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3999  ON_BAILOUT(isolate, "v8::Function::Call()", return Local<v8::Value>());
4000  LOG_API(isolate, "Function::Call");
4001  ENTER_V8(isolate);
4002  i::Logger::TimerEventScope timer_scope(
4003  isolate, i::Logger::TimerEventScope::v8_execute);
4004  i::Object* raw_result = NULL;
4005  {
4006  i::HandleScope scope(isolate);
4008  i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv);
4009  STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**));
4010  i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
4011  EXCEPTION_PREAMBLE(isolate);
4013  isolate, fun, recv_obj, argc, args, &has_pending_exception, true);
4015  raw_result = *returned;
4016  }
4017  i::Handle<i::Object> result(raw_result, isolate);
4018  return Utils::ToLocal(result);
4019 }
4020 
4021 
4023  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4024  ENTER_V8(isolate);
4025  USE(isolate);
4027  func->shared()->set_name(*Utils::OpenHandle(*name));
4028 }
4029 
4030 
4033  return Utils::ToLocal(i::Handle<i::Object>(func->shared()->name(),
4034  func->GetIsolate()));
4035 }
4036 
4037 
4040  return Utils::ToLocal(i::Handle<i::Object>(func->shared()->inferred_name(),
4041  func->GetIsolate()));
4042 }
4043 
4044 
4046  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4047  ON_BAILOUT(isolate, "v8::Function::GetDisplayName()",
4048  return ToApiHandle<Primitive>(
4049  isolate->factory()->undefined_value()));
4050  ENTER_V8(isolate);
4052  i::Handle<i::String> property_name =
4053  isolate->factory()->InternalizeOneByteString(
4054  STATIC_ASCII_VECTOR("displayName"));
4055  i::LookupResult lookup(isolate);
4056  func->LookupRealNamedProperty(*property_name, &lookup);
4057  if (lookup.IsFound()) {
4058  i::Object* value = lookup.GetLazyValue();
4059  if (value && value->IsString()) {
4060  i::String* name = i::String::cast(value);
4061  if (name->length() > 0) return Utils::ToLocal(i::Handle<i::String>(name));
4062  }
4063  }
4064  return ToApiHandle<Primitive>(isolate->factory()->undefined_value());
4065 }
4066 
4067 
4070  if (func->shared()->script()->IsScript()) {
4071  i::Handle<i::Script> script(i::Script::cast(func->shared()->script()));
4072  i::Handle<i::Object> scriptName = GetScriptNameOrSourceURL(script);
4073  v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(func->GetIsolate());
4074  v8::ScriptOrigin origin(
4075  Utils::ToLocal(scriptName),
4076  v8::Integer::New(isolate, script->line_offset()->value()),
4077  v8::Integer::New(isolate, script->column_offset()->value()));
4078  return origin;
4079  }
4080  return v8::ScriptOrigin(Handle<Value>());
4081 }
4082 
4083 
4084 const int Function::kLineOffsetNotFound = -1;
4085 
4086 
4089  if (func->shared()->script()->IsScript()) {
4090  i::Handle<i::Script> script(i::Script::cast(func->shared()->script()));
4091  return i::GetScriptLineNumber(script, func->shared()->start_position());
4092  }
4093  return kLineOffsetNotFound;
4094 }
4095 
4096 
4099  if (func->shared()->script()->IsScript()) {
4100  i::Handle<i::Script> script(i::Script::cast(func->shared()->script()));
4101  return i::GetScriptColumnNumber(script, func->shared()->start_position());
4102  }
4103  return kLineOffsetNotFound;
4104 }
4105 
4106 
4107 bool Function::IsBuiltin() const {
4109  return func->IsBuiltin();
4110 }
4111 
4112 
4113 int Function::ScriptId() const {
4115  if (!func->shared()->script()->IsScript()) {
4117  }
4118  i::Handle<i::Script> script(i::Script::cast(func->shared()->script()));
4119  return script->id()->value();
4120 }
4121 
4122 
4125  if (!func->shared()->bound()) {
4126  return v8::Undefined(reinterpret_cast<v8::Isolate*>(func->GetIsolate()));
4127  }
4129  i::FixedArray::cast(func->function_bindings()));
4130  i::Handle<i::Object> original(
4131  bound_args->get(i::JSFunction::kBoundFunctionIndex),
4132  func->GetIsolate());
4134 }
4135 
4136 
4137 int String::Length() const {
4139  return str->length();
4140 }
4141 
4142 
4143 bool String::IsOneByte() const {
4145  return str->HasOnlyOneByteChars();
4146 }
4147 
4148 
4149 // Helpers for ContainsOnlyOneByteHelper
4150 template<size_t size> struct OneByteMask;
4151 template<> struct OneByteMask<4> {
4152  static const uint32_t value = 0xFF00FF00;
4153 };
4154 template<> struct OneByteMask<8> {
4155  static const uint64_t value = V8_2PART_UINT64_C(0xFF00FF00, FF00FF00);
4156 };
4157 static const uintptr_t kOneByteMask = OneByteMask<sizeof(uintptr_t)>::value;
4158 static const uintptr_t kAlignmentMask = sizeof(uintptr_t) - 1;
4159 static inline bool Unaligned(const uint16_t* chars) {
4160  return reinterpret_cast<const uintptr_t>(chars) & kAlignmentMask;
4161 }
4162 
4163 
4164 static inline const uint16_t* Align(const uint16_t* chars) {
4165  return reinterpret_cast<uint16_t*>(
4166  reinterpret_cast<uintptr_t>(chars) & ~kAlignmentMask);
4167 }
4168 
4170  public:
4171  ContainsOnlyOneByteHelper() : is_one_byte_(true) {}
4172  bool Check(i::String* string) {
4173  i::ConsString* cons_string = i::String::VisitFlat(this, string, 0);
4174  if (cons_string == NULL) return is_one_byte_;
4175  return CheckCons(cons_string);
4176  }
4177  void VisitOneByteString(const uint8_t* chars, int length) {
4178  // Nothing to do.
4179  }
4180  void VisitTwoByteString(const uint16_t* chars, int length) {
4181  // Accumulated bits.
4182  uintptr_t acc = 0;
4183  // Align to uintptr_t.
4184  const uint16_t* end = chars + length;
4185  while (Unaligned(chars) && chars != end) {
4186  acc |= *chars++;
4187  }
4188  // Read word aligned in blocks,
4189  // checking the return value at the end of each block.
4190  const uint16_t* aligned_end = Align(end);
4191  const int increment = sizeof(uintptr_t)/sizeof(uint16_t);
4192  const int inner_loops = 16;
4193  while (chars + inner_loops*increment < aligned_end) {
4194  for (int i = 0; i < inner_loops; i++) {
4195  acc |= *reinterpret_cast<const uintptr_t*>(chars);
4196  chars += increment;
4197  }
4198  // Check for early return.
4199  if ((acc & kOneByteMask) != 0) {
4200  is_one_byte_ = false;
4201  return;
4202  }
4203  }
4204  // Read the rest.
4205  while (chars != end) {
4206  acc |= *chars++;
4207  }
4208  // Check result.
4209  if ((acc & kOneByteMask) != 0) is_one_byte_ = false;
4210  }
4211 
4212  private:
4213  bool CheckCons(i::ConsString* cons_string) {
4214  while (true) {
4215  // Check left side if flat.
4216  i::String* left = cons_string->first();
4217  i::ConsString* left_as_cons =
4218  i::String::VisitFlat(this, left, 0);
4219  if (!is_one_byte_) return false;
4220  // Check right side if flat.
4221  i::String* right = cons_string->second();
4222  i::ConsString* right_as_cons =
4223  i::String::VisitFlat(this, right, 0);
4224  if (!is_one_byte_) return false;
4225  // Standard recurse/iterate trick.
4226  if (left_as_cons != NULL && right_as_cons != NULL) {
4227  if (left->length() < right->length()) {
4228  CheckCons(left_as_cons);
4229  cons_string = right_as_cons;
4230  } else {
4231  CheckCons(right_as_cons);
4232  cons_string = left_as_cons;
4233  }
4234  // Check fast return.
4235  if (!is_one_byte_) return false;
4236  continue;
4237  }
4238  // Descend left in place.
4239  if (left_as_cons != NULL) {
4240  cons_string = left_as_cons;
4241  continue;
4242  }
4243  // Descend right in place.
4244  if (right_as_cons != NULL) {
4245  cons_string = right_as_cons;
4246  continue;
4247  }
4248  // Terminate.
4249  break;
4250  }
4251  return is_one_byte_;
4252  }
4253  bool is_one_byte_;
4254  DISALLOW_COPY_AND_ASSIGN(ContainsOnlyOneByteHelper);
4255 };
4256 
4257 
4260  if (str->HasOnlyOneByteChars()) return true;
4262  return helper.Check(*str);
4263 }
4264 
4265 
4267  public:
4268  enum State {
4275  };
4276 
4277  static const uint8_t kInitialState = 0;
4278 
4279  static inline bool EndsWithSurrogate(uint8_t state) {
4280  return state & kEndsWithLeadingSurrogate;
4281  }
4282 
4283  static inline bool StartsWithSurrogate(uint8_t state) {
4284  return state & kStartsWithTrailingSurrogate;
4285  }
4286 
4287  class Visitor {
4288  public:
4289  inline explicit Visitor()
4290  : utf8_length_(0),
4291  state_(kInitialState) {}
4292 
4293  void VisitOneByteString(const uint8_t* chars, int length) {
4294  int utf8_length = 0;
4295  // Add in length 1 for each non-ASCII character.
4296  for (int i = 0; i < length; i++) {
4297  utf8_length += *chars++ >> 7;
4298  }
4299  // Add in length 1 for each character.
4300  utf8_length_ = utf8_length + length;
4301  state_ = kInitialState;
4302  }
4303 
4304  void VisitTwoByteString(const uint16_t* chars, int length) {
4305  int utf8_length = 0;
4306  int last_character = unibrow::Utf16::kNoPreviousCharacter;
4307  for (int i = 0; i < length; i++) {
4308  uint16_t c = chars[i];
4309  utf8_length += unibrow::Utf8::Length(c, last_character);
4310  last_character = c;
4311  }
4312  utf8_length_ = utf8_length;
4313  uint8_t state = 0;
4314  if (unibrow::Utf16::IsTrailSurrogate(chars[0])) {
4316  }
4317  if (unibrow::Utf16::IsLeadSurrogate(chars[length-1])) {
4318  state |= kEndsWithLeadingSurrogate;
4319  }
4320  state_ = state;
4321  }
4322 
4324  int* length,
4325  uint8_t* state) {
4326  Visitor visitor;
4327  i::ConsString* cons_string = i::String::VisitFlat(&visitor, string);
4328  *length = visitor.utf8_length_;
4329  *state = visitor.state_;
4330  return cons_string;
4331  }
4332 
4333  private:
4334  int utf8_length_;
4335  uint8_t state_;
4336  DISALLOW_COPY_AND_ASSIGN(Visitor);
4337  };
4338 
4339  static inline void MergeLeafLeft(int* length,
4340  uint8_t* state,
4341  uint8_t leaf_state) {
4342  bool edge_surrogate = StartsWithSurrogate(leaf_state);
4343  if (!(*state & kLeftmostEdgeIsCalculated)) {
4344  ASSERT(!(*state & kLeftmostEdgeIsSurrogate));
4345  *state |= kLeftmostEdgeIsCalculated
4346  | (edge_surrogate ? kLeftmostEdgeIsSurrogate : 0);
4347  } else if (EndsWithSurrogate(*state) && edge_surrogate) {
4349  }
4350  if (EndsWithSurrogate(leaf_state)) {
4351  *state |= kEndsWithLeadingSurrogate;
4352  } else {
4353  *state &= ~kEndsWithLeadingSurrogate;
4354  }
4355  }
4356 
4357  static inline void MergeLeafRight(int* length,
4358  uint8_t* state,
4359  uint8_t leaf_state) {
4360  bool edge_surrogate = EndsWithSurrogate(leaf_state);
4361  if (!(*state & kRightmostEdgeIsCalculated)) {
4362  ASSERT(!(*state & kRightmostEdgeIsSurrogate));
4363  *state |= (kRightmostEdgeIsCalculated
4364  | (edge_surrogate ? kRightmostEdgeIsSurrogate : 0));
4365  } else if (edge_surrogate && StartsWithSurrogate(*state)) {
4367  }
4368  if (StartsWithSurrogate(leaf_state)) {
4369  *state |= kStartsWithTrailingSurrogate;
4370  } else {
4371  *state &= ~kStartsWithTrailingSurrogate;
4372  }
4373  }
4374 
4375  static inline void MergeTerminal(int* length,
4376  uint8_t state,
4377  uint8_t* state_out) {
4378  ASSERT((state & kLeftmostEdgeIsCalculated) &&
4379  (state & kRightmostEdgeIsCalculated));
4380  if (EndsWithSurrogate(state) && StartsWithSurrogate(state)) {
4382  }
4383  *state_out = kInitialState |
4386  }
4387 
4388  static int Calculate(i::ConsString* current, uint8_t* state_out) {
4389  using namespace internal;
4390  int total_length = 0;
4391  uint8_t state = kInitialState;
4392  while (true) {
4393  i::String* left = current->first();
4394  i::String* right = current->second();
4395  uint8_t right_leaf_state;
4396  uint8_t left_leaf_state;
4397  int leaf_length;
4398  ConsString* left_as_cons =
4399  Visitor::VisitFlat(left, &leaf_length, &left_leaf_state);
4400  if (left_as_cons == NULL) {
4401  total_length += leaf_length;
4402  MergeLeafLeft(&total_length, &state, left_leaf_state);
4403  }
4404  ConsString* right_as_cons =
4405  Visitor::VisitFlat(right, &leaf_length, &right_leaf_state);
4406  if (right_as_cons == NULL) {
4407  total_length += leaf_length;
4408  MergeLeafRight(&total_length, &state, right_leaf_state);
4409  if (left_as_cons != NULL) {
4410  // 1 Leaf node. Descend in place.
4411  current = left_as_cons;
4412  continue;
4413  } else {
4414  // Terminal node.
4415  MergeTerminal(&total_length, state, state_out);
4416  return total_length;
4417  }
4418  } else if (left_as_cons == NULL) {
4419  // 1 Leaf node. Descend in place.
4420  current = right_as_cons;
4421  continue;
4422  }
4423  // Both strings are ConsStrings.
4424  // Recurse on smallest.
4425  if (left->length() < right->length()) {
4426  total_length += Calculate(left_as_cons, &left_leaf_state);
4427  MergeLeafLeft(&total_length, &state, left_leaf_state);
4428  current = right_as_cons;
4429  } else {
4430  total_length += Calculate(right_as_cons, &right_leaf_state);
4431  MergeLeafRight(&total_length, &state, right_leaf_state);
4432  current = left_as_cons;
4433  }
4434  }
4435  UNREACHABLE();
4436  return 0;
4437  }
4438 
4439  static inline int Calculate(i::ConsString* current) {
4440  uint8_t state = kInitialState;
4441  return Calculate(current, &state);
4442  }
4443 
4444  private:
4445  DISALLOW_IMPLICIT_CONSTRUCTORS(Utf8LengthHelper);
4446 };
4447 
4448 
4449 static int Utf8Length(i::String* str, i::Isolate* isolate) {
4450  int length = str->length();
4451  if (length == 0) return 0;
4452  uint8_t state;
4453  i::ConsString* cons_string =
4454  Utf8LengthHelper::Visitor::VisitFlat(str, &length, &state);
4455  if (cons_string == NULL) return length;
4456  return Utf8LengthHelper::Calculate(cons_string);
4457 }
4458 
4459 
4460 int String::Utf8Length() const {
4462  i::Isolate* isolate = str->GetIsolate();
4463  return v8::Utf8Length(*str, isolate);
4464 }
4465 
4466 
4468  public:
4470  char* buffer,
4471  int capacity,
4472  bool skip_capacity_check,
4473  bool replace_invalid_utf8)
4474  : early_termination_(false),
4475  last_character_(unibrow::Utf16::kNoPreviousCharacter),
4476  buffer_(buffer),
4477  start_(buffer),
4478  capacity_(capacity),
4479  skip_capacity_check_(capacity == -1 || skip_capacity_check),
4480  replace_invalid_utf8_(replace_invalid_utf8),
4481  utf16_chars_read_(0) {
4482  }
4483 
4484  static int WriteEndCharacter(uint16_t character,
4485  int last_character,
4486  int remaining,
4487  char* const buffer,
4488  bool replace_invalid_utf8) {
4489  using namespace unibrow;
4490  ASSERT(remaining > 0);
4491  // We can't use a local buffer here because Encode needs to modify
4492  // previous characters in the stream. We know, however, that
4493  // exactly one character will be advanced.
4494  if (Utf16::IsSurrogatePair(last_character, character)) {
4495  int written = Utf8::Encode(buffer,
4496  character,
4497  last_character,
4498  replace_invalid_utf8);
4499  ASSERT(written == 1);
4500  return written;
4501  }
4502  // Use a scratch buffer to check the required characters.
4503  char temp_buffer[Utf8::kMaxEncodedSize];
4504  // Can't encode using last_character as gcc has array bounds issues.
4505  int written = Utf8::Encode(temp_buffer,
4506  character,
4507  Utf16::kNoPreviousCharacter,
4508  replace_invalid_utf8);
4509  // Won't fit.
4510  if (written > remaining) return 0;
4511  // Copy over the character from temp_buffer.
4512  for (int j = 0; j < written; j++) {
4513  buffer[j] = temp_buffer[j];
4514  }
4515  return written;
4516  }
4517 
4518  // Visit writes out a group of code units (chars) of a v8::String to the
4519  // internal buffer_. This is done in two phases. The first phase calculates a
4520  // pesimistic estimate (writable_length) on how many code units can be safely
4521  // written without exceeding the buffer capacity and without writing the last
4522  // code unit (it could be a lead surrogate). The estimated number of code
4523  // units is then written out in one go, and the reported byte usage is used
4524  // to correct the estimate. This is repeated until the estimate becomes <= 0
4525  // or all code units have been written out. The second phase writes out code
4526  // units until the buffer capacity is reached, would be exceeded by the next
4527  // unit, or all units have been written out.
4528  template<typename Char>
4529  void Visit(const Char* chars, const int length) {
4530  using namespace unibrow;
4531  ASSERT(!early_termination_);
4532  if (length == 0) return;
4533  // Copy state to stack.
4534  char* buffer = buffer_;
4535  int last_character =
4536  sizeof(Char) == 1 ? Utf16::kNoPreviousCharacter : last_character_;
4537  int i = 0;
4538  // Do a fast loop where there is no exit capacity check.
4539  while (true) {
4540  int fast_length;
4541  if (skip_capacity_check_) {
4542  fast_length = length;
4543  } else {
4544  int remaining_capacity = capacity_ - static_cast<int>(buffer - start_);
4545  // Need enough space to write everything but one character.
4546  STATIC_ASSERT(Utf16::kMaxExtraUtf8BytesForOneUtf16CodeUnit == 3);
4547  int max_size_per_char = sizeof(Char) == 1 ? 2 : 3;
4548  int writable_length =
4549  (remaining_capacity - max_size_per_char)/max_size_per_char;
4550  // Need to drop into slow loop.
4551  if (writable_length <= 0) break;
4552  fast_length = i + writable_length;
4553  if (fast_length > length) fast_length = length;
4554  }
4555  // Write the characters to the stream.
4556  if (sizeof(Char) == 1) {
4557  for (; i < fast_length; i++) {
4558  buffer +=
4559  Utf8::EncodeOneByte(buffer, static_cast<uint8_t>(*chars++));
4560  ASSERT(capacity_ == -1 || (buffer - start_) <= capacity_);
4561  }
4562  } else {
4563  for (; i < fast_length; i++) {
4564  uint16_t character = *chars++;
4565  buffer += Utf8::Encode(buffer,
4566  character,
4567  last_character,
4568  replace_invalid_utf8_);
4569  last_character = character;
4570  ASSERT(capacity_ == -1 || (buffer - start_) <= capacity_);
4571  }
4572  }
4573  // Array is fully written. Exit.
4574  if (fast_length == length) {
4575  // Write state back out to object.
4576  last_character_ = last_character;
4577  buffer_ = buffer;
4578  utf16_chars_read_ += length;
4579  return;
4580  }
4581  }
4582  ASSERT(!skip_capacity_check_);
4583  // Slow loop. Must check capacity on each iteration.
4584  int remaining_capacity = capacity_ - static_cast<int>(buffer - start_);
4585  ASSERT(remaining_capacity >= 0);
4586  for (; i < length && remaining_capacity > 0; i++) {
4587  uint16_t character = *chars++;
4588  // remaining_capacity is <= 3 bytes at this point, so we do not write out
4589  // an umatched lead surrogate.
4590  if (replace_invalid_utf8_ && Utf16::IsLeadSurrogate(character)) {
4591  early_termination_ = true;
4592  break;
4593  }
4594  int written = WriteEndCharacter(character,
4595  last_character,
4596  remaining_capacity,
4597  buffer,
4598  replace_invalid_utf8_);
4599  if (written == 0) {
4600  early_termination_ = true;
4601  break;
4602  }
4603  buffer += written;
4604  remaining_capacity -= written;
4605  last_character = character;
4606  }
4607  // Write state back out to object.
4608  last_character_ = last_character;
4609  buffer_ = buffer;
4610  utf16_chars_read_ += i;
4611  }
4612 
4613  inline bool IsDone() {
4614  return early_termination_;
4615  }
4616 
4617  inline void VisitOneByteString(const uint8_t* chars, int length) {
4618  Visit(chars, length);
4619  }
4620 
4621  inline void VisitTwoByteString(const uint16_t* chars, int length) {
4622  Visit(chars, length);
4623  }
4624 
4625  int CompleteWrite(bool write_null, int* utf16_chars_read_out) {
4626  // Write out number of utf16 characters written to the stream.
4627  if (utf16_chars_read_out != NULL) {
4628  *utf16_chars_read_out = utf16_chars_read_;
4629  }
4630  // Only null terminate if all of the string was written and there's space.
4631  if (write_null &&
4632  !early_termination_ &&
4633  (capacity_ == -1 || (buffer_ - start_) < capacity_)) {
4634  *buffer_++ = '\0';
4635  }
4636  return static_cast<int>(buffer_ - start_);
4637  }
4638 
4639  private:
4640  bool early_termination_;
4641  int last_character_;
4642  char* buffer_;
4643  char* const start_;
4644  int capacity_;
4645  bool const skip_capacity_check_;
4646  bool const replace_invalid_utf8_;
4647  int utf16_chars_read_;
4649 };
4650 
4651 
4652 static bool RecursivelySerializeToUtf8(i::String* current,
4653  Utf8WriterVisitor* writer,
4654  int recursion_budget) {
4655  while (!writer->IsDone()) {
4656  i::ConsString* cons_string = i::String::VisitFlat(writer, current);
4657  if (cons_string == NULL) return true; // Leaf node.
4658  if (recursion_budget <= 0) return false;
4659  // Must write the left branch first.
4660  i::String* first = cons_string->first();
4661  bool success = RecursivelySerializeToUtf8(first,
4662  writer,
4663  recursion_budget - 1);
4664  if (!success) return false;
4665  // Inline tail recurse for right branch.
4666  current = cons_string->second();
4667  }
4668  return true;
4669 }
4670 
4671 
4672 int String::WriteUtf8(char* buffer,
4673  int capacity,
4674  int* nchars_ref,
4675  int options) const {
4676  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4677  LOG_API(isolate, "String::WriteUtf8");
4678  ENTER_V8(isolate);
4680  if (options & HINT_MANY_WRITES_EXPECTED) {
4681  FlattenString(str); // Flatten the string for efficiency.
4682  }
4683  const int string_length = str->length();
4684  bool write_null = !(options & NO_NULL_TERMINATION);
4685  bool replace_invalid_utf8 = (options & REPLACE_INVALID_UTF8);
4686  int max16BitCodeUnitSize = unibrow::Utf8::kMax16BitCodeUnitSize;
4687  // First check if we can just write the string without checking capacity.
4688  if (capacity == -1 || capacity / max16BitCodeUnitSize >= string_length) {
4689  Utf8WriterVisitor writer(buffer, capacity, true, replace_invalid_utf8);
4690  const int kMaxRecursion = 100;
4691  bool success = RecursivelySerializeToUtf8(*str, &writer, kMaxRecursion);
4692  if (success) return writer.CompleteWrite(write_null, nchars_ref);
4693  } else if (capacity >= string_length) {
4694  // First check that the buffer is large enough.
4695  int utf8_bytes = v8::Utf8Length(*str, str->GetIsolate());
4696  if (utf8_bytes <= capacity) {
4697  // ASCII fast path.
4698  if (utf8_bytes == string_length) {
4699  WriteOneByte(reinterpret_cast<uint8_t*>(buffer), 0, capacity, options);
4700  if (nchars_ref != NULL) *nchars_ref = string_length;
4701  if (write_null && (utf8_bytes+1 <= capacity)) {
4702  return string_length + 1;
4703  }
4704  return string_length;
4705  }
4706  if (write_null && (utf8_bytes+1 > capacity)) {
4707  options |= NO_NULL_TERMINATION;
4708  }
4709  // Recurse once without a capacity limit.
4710  // This will get into the first branch above.
4711  // TODO(dcarney) Check max left rec. in Utf8Length and fall through.
4712  return WriteUtf8(buffer, -1, nchars_ref, options);
4713  }
4714  }
4715  // Recursive slow path can potentially be unreasonable slow. Flatten.
4716  str = FlattenGetString(str);
4717  Utf8WriterVisitor writer(buffer, capacity, false, replace_invalid_utf8);
4718  i::String::VisitFlat(&writer, *str);
4719  return writer.CompleteWrite(write_null, nchars_ref);
4720 }
4721 
4722 
4723 template<typename CharType>
4724 static inline int WriteHelper(const String* string,
4725  CharType* buffer,
4726  int start,
4727  int length,
4728  int options) {
4729  i::Isolate* isolate = Utils::OpenHandle(string)->GetIsolate();
4730  LOG_API(isolate, "String::Write");
4731  ENTER_V8(isolate);
4732  ASSERT(start >= 0 && length >= -1);
4734  isolate->string_tracker()->RecordWrite(str);
4735  if (options & String::HINT_MANY_WRITES_EXPECTED) {
4736  // Flatten the string for efficiency. This applies whether we are
4737  // using StringCharacterStream or Get(i) to access the characters.
4738  FlattenString(str);
4739  }
4740  int end = start + length;
4741  if ((length == -1) || (length > str->length() - start) )
4742  end = str->length();
4743  if (end < 0) return 0;
4744  i::String::WriteToFlat(*str, buffer, start, end);
4745  if (!(options & String::NO_NULL_TERMINATION) &&
4746  (length == -1 || end - start < length)) {
4747  buffer[end - start] = '\0';
4748  }
4749  return end - start;
4750 }
4751 
4752 
4753 int String::WriteOneByte(uint8_t* buffer,
4754  int start,
4755  int length,
4756  int options) const {
4757  return WriteHelper(this, buffer, start, length, options);
4758 }
4759 
4760 
4762  int start,
4763  int length,
4764  int options) const {
4765  return WriteHelper(this, buffer, start, length, options);
4766 }
4767 
4768 
4771  EnsureInitializedForIsolate(str->GetIsolate(), "v8::String::IsExternal()");
4772  return i::StringShape(*str).IsExternalTwoByte();
4773 }
4774 
4775 
4778  return i::StringShape(*str).IsExternalAscii();
4779 }
4780 
4781 
4782 void v8::String::VerifyExternalStringResource(
4783  v8::String::ExternalStringResource* value) const {
4785  const v8::String::ExternalStringResource* expected;
4786  if (i::StringShape(*str).IsExternalTwoByte()) {
4787  const void* resource =
4789  expected = reinterpret_cast<const ExternalStringResource*>(resource);
4790  } else {
4791  expected = NULL;
4792  }
4793  CHECK_EQ(expected, value);
4794 }
4795 
4796 void v8::String::VerifyExternalStringResourceBase(
4797  v8::String::ExternalStringResourceBase* value, Encoding encoding) const {
4800  Encoding expectedEncoding;
4801  if (i::StringShape(*str).IsExternalAscii()) {
4802  const void* resource =
4803  i::Handle<i::ExternalAsciiString>::cast(str)->resource();
4804  expected = reinterpret_cast<const ExternalStringResourceBase*>(resource);
4805  expectedEncoding = ASCII_ENCODING;
4806  } else if (i::StringShape(*str).IsExternalTwoByte()) {
4807  const void* resource =
4809  expected = reinterpret_cast<const ExternalStringResourceBase*>(resource);
4810  expectedEncoding = TWO_BYTE_ENCODING;
4811  } else {
4812  expected = NULL;
4813  expectedEncoding = str->IsOneByteRepresentation() ? ASCII_ENCODING
4814  : TWO_BYTE_ENCODING;
4815  }
4816  CHECK_EQ(expected, value);
4817  CHECK_EQ(expectedEncoding, encoding);
4818 }
4819 
4823  if (i::StringShape(*str).IsExternalAscii()) {
4824  const void* resource =
4825  i::Handle<i::ExternalAsciiString>::cast(str)->resource();
4826  return reinterpret_cast<const ExternalAsciiStringResource*>(resource);
4827  } else {
4828  return NULL;
4829  }
4830 }
4831 
4832 
4835  i::Handle<i::Object> name(sym->name(), sym->GetIsolate());
4836  return Utils::ToLocal(name);
4837 }
4838 
4839 
4841  return reinterpret_cast<const Symbol*>(this)->Name();
4842 }
4843 
4844 
4845 double Number::Value() const {
4847  return obj->Number();
4848 }
4849 
4850 
4851 bool Boolean::Value() const {
4853  return obj->IsTrue();
4854 }
4855 
4856 
4857 int64_t Integer::Value() const {
4859  if (obj->IsSmi()) {
4860  return i::Smi::cast(*obj)->value();
4861  } else {
4862  return static_cast<int64_t>(obj->Number());
4863  }
4864 }
4865 
4866 
4869  if (obj->IsSmi()) {
4870  return i::Smi::cast(*obj)->value();
4871  } else {
4872  return static_cast<int32_t>(obj->Number());
4873  }
4874 }
4875 
4876 
4877 uint32_t Uint32::Value() const {
4879  if (obj->IsSmi()) {
4880  return i::Smi::cast(*obj)->value();
4881  } else {
4882  return static_cast<uint32_t>(obj->Number());
4883  }
4884 }
4885 
4886 
4889  return obj->GetInternalFieldCount();
4890 }
4891 
4892 
4893 static bool InternalFieldOK(i::Handle<i::JSObject> obj,
4894  int index,
4895  const char* location) {
4896  return Utils::ApiCheck(index < obj->GetInternalFieldCount(),
4897  location,
4898  "Internal field out of bounds");
4899 }
4900 
4901 
4902 Local<Value> v8::Object::SlowGetInternalField(int index) {
4904  const char* location = "v8::Object::GetInternalField()";
4905  if (!InternalFieldOK(obj, index, location)) return Local<Value>();
4906  i::Handle<i::Object> value(obj->GetInternalField(index), obj->GetIsolate());
4907  return Utils::ToLocal(value);
4908 }
4909 
4910 
4913  const char* location = "v8::Object::SetInternalField()";
4914  if (!InternalFieldOK(obj, index, location)) return;
4916  obj->SetInternalField(index, *val);
4917  ASSERT_EQ(value, GetInternalField(index));
4918 }
4919 
4920 
4921 void* v8::Object::SlowGetAlignedPointerFromInternalField(int index) {
4923  const char* location = "v8::Object::GetAlignedPointerFromInternalField()";
4924  if (!InternalFieldOK(obj, index, location)) return NULL;
4925  return DecodeSmiToAligned(obj->GetInternalField(index), location);
4926 }
4927 
4928 
4929 void v8::Object::SetAlignedPointerInInternalField(int index, void* value) {
4931  const char* location = "v8::Object::SetAlignedPointerInInternalField()";
4932  if (!InternalFieldOK(obj, index, location)) return;
4933  obj->SetInternalField(index, EncodeAlignedAsSmi(value, location));
4934  ASSERT_EQ(value, GetAlignedPointerFromInternalField(index));
4935 }
4936 
4937 
4938 static void* ExternalValue(i::Object* obj) {
4939  // Obscure semantics for undefined, but somehow checked in our unit tests...
4940  if (obj->IsUndefined()) return NULL;
4941  i::Object* foreign = i::JSObject::cast(obj)->GetInternalField(0);
4942  return i::Foreign::cast(foreign)->foreign_address();
4943 }
4944 
4945 
4946 // --- E n v i r o n m e n t ---
4947 
4948 
4950 #ifdef V8_USE_DEFAULT_PLATFORM
4951  FATAL("Can't override v8::Platform when using default implementation");
4952 #else
4953  i::V8::InitializePlatform(platform);
4954 #endif
4955 }
4956 
4957 
4959 #ifdef V8_USE_DEFAULT_PLATFORM
4960  FATAL("Can't override v8::Platform when using default implementation");
4961 #else
4963 #endif
4964 }
4965 
4966 
4968  i::Isolate* isolate = i::Isolate::UncheckedCurrent();
4969  if (isolate != NULL && isolate->IsInitialized()) {
4970  return true;
4971  }
4972  return InitializeHelper(isolate);
4973 }
4974 
4975 
4977  i::RandomNumberGenerator::SetEntropySource(entropy_source);
4978 }
4979 
4980 
4982  ReturnAddressLocationResolver return_address_resolver) {
4983  i::V8::SetReturnAddressLocationResolver(return_address_resolver);
4984 }
4985 
4986 
4988  FunctionEntryHook entry_hook) {
4989  ASSERT(ext_isolate != NULL);
4990  ASSERT(entry_hook != NULL);
4991 
4992  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(ext_isolate);
4993 
4994  // The entry hook can only be set before the Isolate is initialized, as
4995  // otherwise the Isolate's code stubs generated at initialization won't
4996  // contain entry hooks.
4997  if (isolate->IsInitialized())
4998  return false;
4999 
5000  // Setting an entry hook is a one-way operation, once set, it cannot be
5001  // changed or unset.
5002  if (isolate->function_entry_hook() != NULL)
5003  return false;
5004 
5005  isolate->set_function_entry_hook(entry_hook);
5006  return true;
5007 }
5008 
5009 
5011  JitCodeEventOptions options, JitCodeEventHandler event_handler) {
5012  i::Isolate* isolate = i::Isolate::Current();
5013  // Ensure that logging is initialized for our isolate.
5014  isolate->InitializeLoggingAndCounters();
5015  isolate->logger()->SetCodeEventHandler(options, event_handler);
5016 }
5017 
5019  ArrayBuffer::Allocator* allocator) {
5021  "v8::V8::SetArrayBufferAllocator",
5022  "ArrayBufferAllocator might only be set once"))
5023  return;
5024  i::V8::SetArrayBufferAllocator(allocator);
5025 }
5026 
5027 
5029  i::Isolate* isolate = i::Isolate::Current();
5030  if (!Utils::ApiCheck(isolate != NULL && isolate->IsDefaultIsolate(),
5031  "v8::V8::Dispose()",
5032  "Use v8::Isolate::Dispose() for non-default isolate.")) {
5033  return false;
5034  }
5035  i::V8::TearDown();
5036  return true;
5037 }
5038 
5039 
5040 HeapStatistics::HeapStatistics(): total_heap_size_(0),
5041  total_heap_size_executable_(0),
5042  total_physical_size_(0),
5043  used_heap_size_(0),
5044  heap_size_limit_(0) { }
5045 
5046 
5048  i::Isolate* isolate = i::Isolate::Current();
5049  isolate->heap()->VisitExternalResources(visitor);
5050 }
5051 
5052 
5053 class VisitorAdapter : public i::ObjectVisitor {
5054  public:
5056  : visitor_(visitor) {}
5057  virtual void VisitPointers(i::Object** start, i::Object** end) {
5058  UNREACHABLE();
5059  }
5060  virtual void VisitEmbedderReference(i::Object** p, uint16_t class_id) {
5061  Value* value = ToApi<Value>(i::Handle<i::Object>(p));
5062  visitor_->VisitPersistentHandle(
5063  reinterpret_cast<Persistent<Value>*>(&value), class_id);
5064  }
5065  private:
5066  PersistentHandleVisitor* visitor_;
5067 };
5068 
5069 
5071  i::Isolate* isolate = i::Isolate::Current();
5072  i::DisallowHeapAllocation no_allocation;
5073 
5074  VisitorAdapter visitor_adapter(visitor);
5075  isolate->global_handles()->IterateAllRootsWithClassIds(&visitor_adapter);
5076 }
5077 
5078 
5080  Isolate* exported_isolate, PersistentHandleVisitor* visitor) {
5081  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(exported_isolate);
5082  ASSERT(isolate == i::Isolate::Current());
5083  i::DisallowHeapAllocation no_allocation;
5084 
5085  VisitorAdapter visitor_adapter(visitor);
5087  &visitor_adapter);
5088 }
5089 
5090 
5092  // Returning true tells the caller that it need not
5093  // continue to call IdleNotification.
5094  i::Isolate* isolate = i::Isolate::Current();
5095  if (isolate == NULL || !isolate->IsInitialized()) return true;
5096  if (!i::FLAG_use_idle_notification) return true;
5097  return isolate->heap()->IdleNotification(hint);
5098 }
5099 
5100 
5102  i::Isolate* isolate = i::Isolate::Current();
5103  if (isolate == NULL || !isolate->IsInitialized()) return;
5104  isolate->heap()->CollectAllAvailableGarbage("low memory notification");
5105 }
5106 
5107 
5109  i::Isolate* isolate = i::Isolate::Current();
5110  if (!isolate->IsInitialized()) return 0;
5111  return isolate->heap()->NotifyContextDisposed();
5112 }
5113 
5114 
5115 bool v8::V8::InitializeICU(const char* icu_data_file) {
5116  return i::InitializeICU(icu_data_file);
5117 }
5118 
5119 
5120 const char* v8::V8::GetVersion() {
5121  return i::Version::GetVersion();
5122 }
5123 
5124 
5125 static i::Handle<i::Context> CreateEnvironment(
5126  i::Isolate* isolate,
5127  v8::ExtensionConfiguration* extensions,
5128  v8::Handle<ObjectTemplate> global_template,
5129  v8::Handle<Value> global_object) {
5131 
5132  // Enter V8 via an ENTER_V8 scope.
5133  {
5134  ENTER_V8(isolate);
5135  v8::Handle<ObjectTemplate> proxy_template = global_template;
5136  i::Handle<i::FunctionTemplateInfo> proxy_constructor;
5137  i::Handle<i::FunctionTemplateInfo> global_constructor;
5138 
5139  if (!global_template.IsEmpty()) {
5140  // Make sure that the global_template has a constructor.
5141  global_constructor = EnsureConstructor(isolate, *global_template);
5142 
5143  // Create a fresh template for the global proxy object.
5144  proxy_template = ObjectTemplate::New(
5145  reinterpret_cast<v8::Isolate*>(isolate));
5146  proxy_constructor = EnsureConstructor(isolate, *proxy_template);
5147 
5148  // Set the global template to be the prototype template of
5149  // global proxy template.
5150  proxy_constructor->set_prototype_template(
5151  *Utils::OpenHandle(*global_template));
5152 
5153  // Migrate security handlers from global_template to
5154  // proxy_template. Temporarily removing access check
5155  // information from the global template.
5156  if (!global_constructor->access_check_info()->IsUndefined()) {
5157  proxy_constructor->set_access_check_info(
5158  global_constructor->access_check_info());
5159  proxy_constructor->set_needs_access_check(
5160  global_constructor->needs_access_check());
5161  global_constructor->set_needs_access_check(false);
5162  global_constructor->set_access_check_info(
5163  isolate->heap()->undefined_value());
5164  }
5165  }
5166 
5167  // Create the environment.
5168  env = isolate->bootstrapper()->CreateEnvironment(
5169  Utils::OpenHandle(*global_object, true),
5170  proxy_template,
5171  extensions);
5172 
5173  // Restore the access check info on the global template.
5174  if (!global_template.IsEmpty()) {
5175  ASSERT(!global_constructor.is_null());
5176  ASSERT(!proxy_constructor.is_null());
5177  global_constructor->set_access_check_info(
5178  proxy_constructor->access_check_info());
5179  global_constructor->set_needs_access_check(
5180  proxy_constructor->needs_access_check());
5181  }
5182  }
5183  // Leave V8.
5184 
5185  return env;
5186 }
5187 
5189  v8::Isolate* external_isolate,
5190  v8::ExtensionConfiguration* extensions,
5191  v8::Handle<ObjectTemplate> global_template,
5192  v8::Handle<Value> global_object) {
5193  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate);
5194  EnsureInitializedForIsolate(isolate, "v8::Context::New()");
5195  LOG_API(isolate, "Context::New");
5196  ON_BAILOUT(isolate, "v8::Context::New()", return Local<Context>());
5197  i::HandleScope scope(isolate);
5198  ExtensionConfiguration no_extensions;
5199  if (extensions == NULL) extensions = &no_extensions;
5200  i::Handle<i::Context> env =
5201  CreateEnvironment(isolate, extensions, global_template, global_object);
5202  if (env.is_null()) return Local<Context>();
5203  return Utils::ToLocal(scope.CloseAndEscape(env));
5204 }
5205 
5206 
5208  i::Isolate* isolate = i::Isolate::Current();
5209  ENTER_V8(isolate);
5211  i::Handle<i::Object> token_handle = Utils::OpenHandle(*token);
5212  env->set_security_token(*token_handle);
5213 }
5214 
5215 
5217  i::Isolate* isolate = i::Isolate::Current();
5218  ENTER_V8(isolate);
5220  env->set_security_token(env->global_object());
5221 }
5222 
5223 
5225  i::Isolate* isolate = i::Isolate::Current();
5227  i::Object* security_token = env->security_token();
5228  i::Handle<i::Object> token_handle(security_token, isolate);
5229  return Utils::ToLocal(token_handle);
5230 }
5231 
5232 
5235  return reinterpret_cast<Isolate*>(env->GetIsolate());
5236 }
5237 
5238 
5240  i::Handle<i::Context> context = Utils::OpenHandle(this);
5241  i::Isolate* isolate = context->GetIsolate();
5242  i::Handle<i::Object> global(context->global_proxy(), isolate);
5243  // TODO(dcarney): This should always return the global proxy
5244  // but can't presently as calls to GetProtoype will return the wrong result.
5246  global)->IsDetachedFrom(context->global_object())) {
5247  global = i::Handle<i::Object>(context->global_object(), isolate);
5248  }
5250 }
5251 
5252 
5254  i::Handle<i::Context> context = Utils::OpenHandle(this);
5255  i::Isolate* isolate = context->GetIsolate();
5256  ENTER_V8(isolate);
5257  isolate->bootstrapper()->DetachGlobal(context);
5258 }
5259 
5260 
5262  i::Handle<i::Context> context = Utils::OpenHandle(this);
5263  i::Isolate* isolate = context->GetIsolate();
5264  ENTER_V8(isolate);
5265  context->set_allow_code_gen_from_strings(
5266  allow ? isolate->heap()->true_value() : isolate->heap()->false_value());
5267 }
5268 
5269 
5271  i::Handle<i::Context> context = Utils::OpenHandle(this);
5272  return !context->allow_code_gen_from_strings()->IsFalse();
5273 }
5274 
5275 
5277  Handle<String> error) {
5278  i::Handle<i::Context> context = Utils::OpenHandle(this);
5279  i::Handle<i::String> error_handle = Utils::OpenHandle(*error);
5280  context->set_error_message_for_code_gen_from_strings(*error_handle);
5281 }
5282 
5283 
5285  i::Isolate* isolate = i::Isolate::Current();
5286  ON_BAILOUT(isolate, "v8::ObjectTemplate::NewInstance()",
5287  return Local<v8::Object>());
5288  LOG_API(isolate, "ObjectTemplate::NewInstance");
5289  ENTER_V8(isolate);
5290  EXCEPTION_PREAMBLE(isolate);
5291  i::Handle<i::Object> obj =
5293  &has_pending_exception);
5296 }
5297 
5298 
5300  i::Isolate* isolate = i::Isolate::Current();
5301  ON_BAILOUT(isolate, "v8::FunctionTemplate::GetFunction()",
5302  return Local<v8::Function>());
5303  LOG_API(isolate, "FunctionTemplate::GetFunction");
5304  ENTER_V8(isolate);
5305  EXCEPTION_PREAMBLE(isolate);
5306  i::Handle<i::Object> obj =
5308  &has_pending_exception);
5311 }
5312 
5313 
5315  ON_BAILOUT(i::Isolate::Current(), "v8::FunctionTemplate::HasInstanceOf()",
5316  return false);
5317  i::Object* obj = *Utils::OpenHandle(*value);
5318  return Utils::OpenHandle(this)->IsTemplateFor(obj);
5319 }
5320 
5321 
5323  STATIC_ASSERT(sizeof(value) == sizeof(i::Address));
5324  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5325  EnsureInitializedForIsolate(i_isolate, "v8::External::New()");
5326  LOG_API(i_isolate, "External::New");
5327  ENTER_V8(i_isolate);
5328  i::Handle<i::JSObject> external = i_isolate->factory()->NewExternal(value);
5329  return Utils::ExternalToLocal(external);
5330 }
5331 
5332 
5333 void* External::Value() const {
5334  return ExternalValue(*Utils::OpenHandle(this));
5335 }
5336 
5337 
5338 // anonymous namespace for string creation helper functions
5339 namespace {
5340 
5341 inline int StringLength(const char* string) {
5342  return i::StrLength(string);
5343 }
5344 
5345 
5346 inline int StringLength(const uint8_t* string) {
5347  return i::StrLength(reinterpret_cast<const char*>(string));
5348 }
5349 
5350 
5351 inline int StringLength(const uint16_t* string) {
5352  int length = 0;
5353  while (string[length] != '\0')
5354  length++;
5355  return length;
5356 }
5357 
5358 
5359 inline i::Handle<i::String> NewString(i::Factory* factory,
5360  String::NewStringType type,
5361  i::Vector<const char> string) {
5362  if (type ==String::kInternalizedString) {
5363  return factory->InternalizeUtf8String(string);
5364  }
5365  return factory->NewStringFromUtf8(string);
5366 }
5367 
5368 
5369 inline i::Handle<i::String> NewString(i::Factory* factory,
5370  String::NewStringType type,
5371  i::Vector<const uint8_t> string) {
5372  if (type == String::kInternalizedString) {
5373  return factory->InternalizeOneByteString(string);
5374  }
5375  return factory->NewStringFromOneByte(string);
5376 }
5377 
5378 
5379 inline i::Handle<i::String> NewString(i::Factory* factory,
5380  String::NewStringType type,
5381  i::Vector<const uint16_t> string) {
5382  if (type == String::kInternalizedString) {
5383  return factory->InternalizeTwoByteString(string);
5384  }
5385  return factory->NewStringFromTwoByte(string);
5386 }
5387 
5388 
5389 template<typename Char>
5390 inline Local<String> NewString(Isolate* v8_isolate,
5391  const char* location,
5392  const char* env,
5393  const Char* data,
5394  String::NewStringType type,
5395  int length) {
5396  i::Isolate* isolate = reinterpret_cast<internal::Isolate*>(v8_isolate);
5397  EnsureInitializedForIsolate(isolate, location);
5398  LOG_API(isolate, env);
5399  if (length == 0 && type != String::kUndetectableString) {
5400  return String::Empty(v8_isolate);
5401  }
5402  ENTER_V8(isolate);
5403  if (length == -1) length = StringLength(data);
5404  i::Handle<i::String> result = NewString(
5405  isolate->factory(), type, i::Vector<const Char>(data, length));
5406  // We do not expect this to fail. Change this if it does.
5407  CHECK(!result.is_null());
5408  if (type == String::kUndetectableString) {
5409  result->MarkAsUndetectable();
5410  }
5411  return Utils::ToLocal(result);
5412 }
5413 
5414 } // anonymous namespace
5415 
5416 
5418  const char* data,
5419  NewStringType type,
5420  int length) {
5421  return NewString(isolate,
5422  "v8::String::NewFromUtf8()",
5423  "String::NewFromUtf8",
5424  data,
5425  type,
5426  length);
5427 }
5428 
5429 
5431  const uint8_t* data,
5432  NewStringType type,
5433  int length) {
5434  return NewString(isolate,
5435  "v8::String::NewFromOneByte()",
5436  "String::NewFromOneByte",
5437  data,
5438  type,
5439  length);
5440 }
5441 
5442 
5444  const uint16_t* data,
5445  NewStringType type,
5446  int length) {
5447  return NewString(isolate,
5448  "v8::String::NewFromTwoByte()",
5449  "String::NewFromTwoByte",
5450  data,
5451  type,
5452  length);
5453 }
5454 
5455 
5457  i::Handle<i::String> left_string = Utils::OpenHandle(*left);
5458  i::Isolate* isolate = left_string->GetIsolate();
5459  EnsureInitializedForIsolate(isolate, "v8::String::New()");
5460  LOG_API(isolate, "String::New(char)");
5461  ENTER_V8(isolate);
5462  i::Handle<i::String> right_string = Utils::OpenHandle(*right);
5463  i::Handle<i::String> result = isolate->factory()->NewConsString(left_string,
5464  right_string);
5465  // We do not expect this to fail. Change this if it does.
5466  CHECK(!result.is_null());
5467  return Utils::ToLocal(result);
5468 }
5469 
5470 
5471 static i::Handle<i::String> NewExternalStringHandle(
5472  i::Isolate* isolate,
5474  i::Handle<i::String> result =
5475  isolate->factory()->NewExternalStringFromTwoByte(resource);
5476  // We do not expect this to fail. Change this if it does.
5477  CHECK(!result.is_null());
5478  return result;
5479 }
5480 
5481 
5482 static i::Handle<i::String> NewExternalAsciiStringHandle(
5483  i::Isolate* isolate,
5485  i::Handle<i::String> result =
5486  isolate->factory()->NewExternalStringFromAscii(resource);
5487  // We do not expect this to fail. Change this if it does.
5488  CHECK(!result.is_null());
5489  return result;
5490 }
5491 
5492 
5494  Isolate* isolate,
5496  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5497  EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()");
5498  LOG_API(i_isolate, "String::NewExternal");
5499  ENTER_V8(i_isolate);
5500  CHECK(resource && resource->data());
5501  i::Handle<i::String> result = NewExternalStringHandle(i_isolate, resource);
5502  i_isolate->heap()->external_string_table()->AddString(*result);
5503  return Utils::ToLocal(result);
5504 }
5505 
5506 
5509  i::Isolate* isolate = obj->GetIsolate();
5510  if (i::StringShape(*obj).IsExternalTwoByte()) {
5511  return false; // Already an external string.
5512  }
5513  ENTER_V8(isolate);
5514  if (isolate->string_tracker()->IsFreshUnusedString(obj)) {
5515  return false;
5516  }
5517  if (isolate->heap()->IsInGCPostProcessing()) {
5518  return false;
5519  }
5520  CHECK(resource && resource->data());
5521 
5522  bool result = obj->MakeExternal(resource);
5523  if (result) {
5524  ASSERT(obj->IsExternalString());
5525  isolate->heap()->external_string_table()->AddString(*obj);
5526  }
5527  return result;
5528 }
5529 
5530 
5532  Isolate* isolate,
5534  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5535  EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()");
5536  LOG_API(i_isolate, "String::NewExternal");
5537  ENTER_V8(i_isolate);
5538  CHECK(resource && resource->data());
5539  i::Handle<i::String> result =
5540  NewExternalAsciiStringHandle(i_isolate, resource);
5541  i_isolate->heap()->external_string_table()->AddString(*result);
5542  return Utils::ToLocal(result);
5543 }
5544 
5545 
5549  i::Isolate* isolate = obj->GetIsolate();
5550  if (i::StringShape(*obj).IsExternalTwoByte()) {
5551  return false; // Already an external string.
5552  }
5553  ENTER_V8(isolate);
5554  if (isolate->string_tracker()->IsFreshUnusedString(obj)) {
5555  return false;
5556  }
5557  if (isolate->heap()->IsInGCPostProcessing()) {
5558  return false;
5559  }
5560  CHECK(resource && resource->data());
5561 
5562  bool result = obj->MakeExternal(resource);
5563  if (result) {
5564  ASSERT(obj->IsExternalString());
5565  isolate->heap()->external_string_table()->AddString(*obj);
5566  }
5567  return result;
5568 }
5569 
5570 
5572  if (!internal::FLAG_clever_optimizations) return false;
5574  i::Isolate* isolate = obj->GetIsolate();
5575 
5576  // TODO(yangguo): Externalizing sliced/cons strings allocates.
5577  // This rule can be removed when all code that can
5578  // trigger an access check is handlified and therefore GC safe.
5579  if (isolate->heap()->old_pointer_space()->Contains(*obj)) return false;
5580 
5581  if (isolate->string_tracker()->IsFreshUnusedString(obj)) return false;
5582  int size = obj->Size(); // Byte size of the original string.
5583  if (size < i::ExternalString::kShortSize) return false;
5584  i::StringShape shape(*obj);
5585  return !shape.IsExternal();
5586 }
5587 
5588 
5590  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5591  EnsureInitializedForIsolate(i_isolate, "v8::Object::New()");
5592  LOG_API(i_isolate, "Object::New");
5593  ENTER_V8(i_isolate);
5595  i_isolate->factory()->NewJSObject(i_isolate->object_function());
5596  return Utils::ToLocal(obj);
5597 }
5598 
5599 
5601  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5602  EnsureInitializedForIsolate(i_isolate, "v8::NumberObject::New()");
5603  LOG_API(i_isolate, "NumberObject::New");
5604  ENTER_V8(i_isolate);
5605  i::Handle<i::Object> number = i_isolate->factory()->NewNumber(value);
5606  i::Handle<i::Object> obj = i_isolate->factory()->ToObject(number);
5607  return Utils::ToLocal(obj);
5608 }
5609 
5610 
5612  i::Isolate* isolate = i::Isolate::Current();
5613  LOG_API(isolate, "NumberObject::NumberValue");
5616  return jsvalue->value()->Number();
5617 }
5618 
5619 
5621  i::Isolate* isolate = i::Isolate::Current();
5622  EnsureInitializedForIsolate(isolate, "v8::BooleanObject::New()");
5623  LOG_API(isolate, "BooleanObject::New");
5624  ENTER_V8(isolate);
5625  i::Handle<i::Object> boolean(value
5626  ? isolate->heap()->true_value()
5627  : isolate->heap()->false_value(),
5628  isolate);
5629  i::Handle<i::Object> obj = isolate->factory()->ToObject(boolean);
5630  return Utils::ToLocal(obj);
5631 }
5632 
5633 
5635  i::Isolate* isolate = i::Isolate::Current();
5636  LOG_API(isolate, "BooleanObject::BooleanValue");
5639  return jsvalue->value()->IsTrue();
5640 }
5641 
5642 
5644  i::Isolate* isolate = i::Isolate::Current();
5645  EnsureInitializedForIsolate(isolate, "v8::StringObject::New()");
5646  LOG_API(isolate, "StringObject::New");
5647  ENTER_V8(isolate);
5648  i::Handle<i::Object> obj =
5649  isolate->factory()->ToObject(Utils::OpenHandle(*value));
5650  return Utils::ToLocal(obj);
5651 }
5652 
5653 
5655  i::Isolate* isolate = i::Isolate::Current();
5656  LOG_API(isolate, "StringObject::StringValue");
5659  return Utils::ToLocal(
5660  i::Handle<i::String>(i::String::cast(jsvalue->value())));
5661 }
5662 
5663 
5665  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5666  EnsureInitializedForIsolate(i_isolate, "v8::SymbolObject::New()");
5667  LOG_API(i_isolate, "SymbolObject::New");
5668  ENTER_V8(i_isolate);
5669  i::Handle<i::Object> obj =
5670  i_isolate->factory()->ToObject(Utils::OpenHandle(*value));
5671  return Utils::ToLocal(obj);
5672 }
5673 
5674 
5676  i::Isolate* isolate = i::Isolate::Current();
5677  LOG_API(isolate, "SymbolObject::SymbolValue");
5680  return Utils::ToLocal(
5681  i::Handle<i::Symbol>(i::Symbol::cast(jsvalue->value())));
5682 }
5683 
5684 
5685 Local<v8::Value> v8::Date::New(Isolate* isolate, double time) {
5686  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5687  EnsureInitializedForIsolate(i_isolate, "v8::Date::New()");
5688  LOG_API(i_isolate, "Date::New");
5689  if (std::isnan(time)) {
5690  // Introduce only canonical NaN value into the VM, to avoid signaling NaNs.
5691  time = i::OS::nan_value();
5692  }
5693  ENTER_V8(i_isolate);
5694  EXCEPTION_PREAMBLE(i_isolate);
5695  i::Handle<i::Object> obj =
5696  i::Execution::NewDate(i_isolate, time, &has_pending_exception);
5698  return Utils::ToLocal(obj);
5699 }
5700 
5701 
5702 double v8::Date::ValueOf() const {
5703  i::Isolate* isolate = i::Isolate::Current();
5704  LOG_API(isolate, "Date::NumberValue");
5707  return jsdate->value()->Number();
5708 }
5709 
5710 
5712  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5713  ON_BAILOUT(i_isolate, "v8::Date::DateTimeConfigurationChangeNotification()",
5714  return);
5715  LOG_API(i_isolate, "Date::DateTimeConfigurationChangeNotification");
5716  ENTER_V8(i_isolate);
5717 
5718  i_isolate->date_cache()->ResetDateCache();
5719 
5720  if (!i_isolate->eternal_handles()->Exists(
5722  return;
5723  }
5724  i::Handle<i::FixedArray> date_cache_version =
5727  ASSERT_EQ(1, date_cache_version->length());
5728  CHECK(date_cache_version->get(0)->IsSmi());
5729  date_cache_version->set(
5730  0,
5731  i::Smi::FromInt(i::Smi::cast(date_cache_version->get(0))->value() + 1));
5732 }
5733 
5734 
5735 static i::Handle<i::String> RegExpFlagsToString(RegExp::Flags flags) {
5736  i::Isolate* isolate = i::Isolate::Current();
5737  uint8_t flags_buf[3];
5738  int num_flags = 0;
5739  if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g';
5740  if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm';
5741  if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i';
5742  ASSERT(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf)));
5743  return isolate->factory()->InternalizeOneByteString(
5744  i::Vector<const uint8_t>(flags_buf, num_flags));
5745 }
5746 
5747 
5749  Flags flags) {
5750  i::Isolate* isolate = Utils::OpenHandle(*pattern)->GetIsolate();
5751  EnsureInitializedForIsolate(isolate, "v8::RegExp::New()");
5752  LOG_API(isolate, "RegExp::New");
5753  ENTER_V8(isolate);
5754  EXCEPTION_PREAMBLE(isolate);
5756  Utils::OpenHandle(*pattern),
5757  RegExpFlagsToString(flags),
5758  &has_pending_exception);
5761 }
5762 
5763 
5766  return Utils::ToLocal(i::Handle<i::String>(obj->Pattern()));
5767 }
5768 
5769 
5770 // Assert that the static flags cast in GetFlags is valid.
5771 #define REGEXP_FLAG_ASSERT_EQ(api_flag, internal_flag) \
5772  STATIC_ASSERT(static_cast<int>(v8::RegExp::api_flag) == \
5773  static_cast<int>(i::JSRegExp::internal_flag))
5774 REGEXP_FLAG_ASSERT_EQ(kNone, NONE);
5775 REGEXP_FLAG_ASSERT_EQ(kGlobal, GLOBAL);
5776 REGEXP_FLAG_ASSERT_EQ(kIgnoreCase, IGNORE_CASE);
5777 REGEXP_FLAG_ASSERT_EQ(kMultiline, MULTILINE);
5778 #undef REGEXP_FLAG_ASSERT_EQ
5779 
5782  return static_cast<RegExp::Flags>(obj->GetFlags().value());
5783 }
5784 
5785 
5786 Local<v8::Array> v8::Array::New(Isolate* isolate, int length) {
5787  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5788  EnsureInitializedForIsolate(i_isolate, "v8::Array::New()");
5789  LOG_API(i_isolate, "Array::New");
5790  ENTER_V8(i_isolate);
5791  int real_length = length > 0 ? length : 0;
5792  i::Handle<i::JSArray> obj = i_isolate->factory()->NewJSArray(real_length);
5793  i::Handle<i::Object> length_obj =
5794  i_isolate->factory()->NewNumberFromInt(real_length);
5795  obj->set_length(*length_obj);
5796  return Utils::ToLocal(obj);
5797 }
5798 
5799 
5800 uint32_t v8::Array::Length() const {
5802  i::Object* length = obj->length();
5803  if (length->IsSmi()) {
5804  return i::Smi::cast(length)->value();
5805  } else {
5806  return static_cast<uint32_t>(length->Number());
5807  }
5808 }
5809 
5810 
5812  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
5813  ON_BAILOUT(isolate, "v8::Array::CloneElementAt()", return Local<Object>());
5815  if (!self->HasFastObjectElements()) {
5816  return Local<Object>();
5817  }
5818  i::FixedArray* elms = i::FixedArray::cast(self->elements());
5819  i::Object* paragon = elms->get(index);
5820  if (!paragon->IsJSObject()) {
5821  return Local<Object>();
5822  }
5823  i::Handle<i::JSObject> paragon_handle(i::JSObject::cast(paragon));
5824  EXCEPTION_PREAMBLE(isolate);
5825  ENTER_V8(isolate);
5826  i::Handle<i::JSObject> result = i::JSObject::Copy(paragon_handle);
5827  has_pending_exception = result.is_null();
5829  return Utils::ToLocal(result);
5830 }
5831 
5832 
5833 bool Value::IsPromise() const {
5835  if (!val->IsJSObject()) return false;
5837  i::Isolate* isolate = obj->GetIsolate();
5838  LOG_API(isolate, "IsPromise");
5839  ENTER_V8(isolate);
5840  EXCEPTION_PREAMBLE(isolate);
5841  i::Handle<i::Object> argv[] = { obj };
5843  isolate,
5844  handle(
5845  isolate->context()->global_object()->native_context()->is_promise()),
5846  isolate->factory()->undefined_value(),
5847  ARRAY_SIZE(argv), argv,
5848  &has_pending_exception,
5849  false);
5850  EXCEPTION_BAILOUT_CHECK(isolate, false);
5851  return b->BooleanValue();
5852 }
5853 
5854 
5856  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
5857  LOG_API(isolate, "Promise::Resolver::New");
5858  ENTER_V8(isolate);
5859  EXCEPTION_PREAMBLE(isolate);
5861  isolate,
5862  handle(isolate->context()->global_object()->native_context()->
5863  promise_create()),
5864  isolate->factory()->undefined_value(),
5865  0, NULL,
5866  &has_pending_exception,
5867  false);
5870 }
5871 
5872 
5874  i::Handle<i::JSObject> promise = Utils::OpenHandle(this);
5875  return Local<Promise>::Cast(Utils::ToLocal(promise));
5876 }
5877 
5878 
5880  i::Handle<i::JSObject> promise = Utils::OpenHandle(this);
5881  i::Isolate* isolate = promise->GetIsolate();
5882  LOG_API(isolate, "Promise::Resolver::Resolve");
5883  ENTER_V8(isolate);
5884  EXCEPTION_PREAMBLE(isolate);
5885  i::Handle<i::Object> argv[] = { promise, Utils::OpenHandle(*value) };
5887  isolate,
5888  handle(isolate->context()->global_object()->native_context()->
5889  promise_resolve()),
5890  isolate->factory()->undefined_value(),
5891  ARRAY_SIZE(argv), argv,
5892  &has_pending_exception,
5893  false);
5894  EXCEPTION_BAILOUT_CHECK(isolate, /* void */ ;);
5895 }
5896 
5897 
5899  i::Handle<i::JSObject> promise = Utils::OpenHandle(this);
5900  i::Isolate* isolate = promise->GetIsolate();
5901  LOG_API(isolate, "Promise::Resolver::Reject");
5902  ENTER_V8(isolate);
5903  EXCEPTION_PREAMBLE(isolate);
5904  i::Handle<i::Object> argv[] = { promise, Utils::OpenHandle(*value) };
5906  isolate,
5907  handle(isolate->context()->global_object()->native_context()->
5908  promise_reject()),
5909  isolate->factory()->undefined_value(),
5910  ARRAY_SIZE(argv), argv,
5911  &has_pending_exception,
5912  false);
5913  EXCEPTION_BAILOUT_CHECK(isolate, /* void */ ;);
5914 }
5915 
5916 
5918  i::Handle<i::JSObject> promise = Utils::OpenHandle(this);
5919  i::Isolate* isolate = promise->GetIsolate();
5920  LOG_API(isolate, "Promise::Chain");
5921  ENTER_V8(isolate);
5922  EXCEPTION_PREAMBLE(isolate);
5923  i::Handle<i::Object> argv[] = { Utils::OpenHandle(*handler) };
5925  isolate,
5926  handle(isolate->context()->global_object()->native_context()->
5927  promise_chain()),
5928  promise,
5929  ARRAY_SIZE(argv), argv,
5930  &has_pending_exception,
5931  false);
5933  return Local<Promise>::Cast(Utils::ToLocal(result));
5934 }
5935 
5936 
5938  i::Handle<i::JSObject> promise = Utils::OpenHandle(this);
5939  i::Isolate* isolate = promise->GetIsolate();
5940  LOG_API(isolate, "Promise::Catch");
5941  ENTER_V8(isolate);
5942  EXCEPTION_PREAMBLE(isolate);
5943  i::Handle<i::Object> argv[] = { Utils::OpenHandle(*handler) };
5945  isolate,
5946  handle(isolate->context()->global_object()->native_context()->
5947  promise_catch()),
5948  promise,
5949  ARRAY_SIZE(argv), argv,
5950  &has_pending_exception,
5951  false);
5953  return Local<Promise>::Cast(Utils::ToLocal(result));
5954 }
5955 
5956 
5958  return Utils::OpenHandle(this)->is_external();
5959 }
5960 
5961 
5964  Utils::ApiCheck(!obj->is_external(),
5965  "v8::ArrayBuffer::Externalize",
5966  "ArrayBuffer already externalized");
5967  obj->set_is_external(true);
5968  size_t byte_length = static_cast<size_t>(obj->byte_length()->Number());
5969  Contents contents;
5970  contents.data_ = obj->backing_store();
5971  contents.byte_length_ = byte_length;
5972  return contents;
5973 }
5974 
5975 
5978  i::Isolate* isolate = obj->GetIsolate();
5979  Utils::ApiCheck(obj->is_external(),
5980  "v8::ArrayBuffer::Neuter",
5981  "Only externalized ArrayBuffers can be neutered");
5982  LOG_API(obj->GetIsolate(), "v8::ArrayBuffer::Neuter()");
5983  ENTER_V8(isolate);
5985 }
5986 
5987 
5990  return static_cast<size_t>(obj->byte_length()->Number());
5991 }
5992 
5993 
5994 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, size_t byte_length) {
5995  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5996  EnsureInitializedForIsolate(i_isolate, "v8::ArrayBuffer::New(size_t)");
5997  LOG_API(i_isolate, "v8::ArrayBuffer::New(size_t)");
5998  ENTER_V8(i_isolate);
6000  i_isolate->factory()->NewJSArrayBuffer();
6001  i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length);
6002  return Utils::ToLocal(obj);
6003 }
6004 
6005 
6007  size_t byte_length) {
6008  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6009  EnsureInitializedForIsolate(i_isolate, "v8::ArrayBuffer::New(void*, size_t)");
6010  LOG_API(i_isolate, "v8::ArrayBuffer::New(void*, size_t)");
6011  ENTER_V8(i_isolate);
6013  i_isolate->factory()->NewJSArrayBuffer();
6014  i::Runtime::SetupArrayBuffer(i_isolate, obj, true, data, byte_length);
6015  return Utils::ToLocal(obj);
6016 }
6017 
6018 
6022  if (obj->IsJSDataView()) {
6024  ASSERT(data_view->buffer()->IsJSArrayBuffer());
6025  buffer = i::handle(i::JSArrayBuffer::cast(data_view->buffer()));
6026  } else {
6027  ASSERT(obj->IsJSTypedArray());
6028  buffer = i::JSTypedArray::cast(*obj)->GetBuffer();
6029  }
6030  return Utils::ToLocal(buffer);
6031 }
6032 
6033 
6036  return static_cast<size_t>(obj->byte_offset()->Number());
6037 }
6038 
6039 
6042  return static_cast<size_t>(obj->byte_length()->Number());
6043 }
6044 
6045 
6048  return static_cast<size_t>(obj->length()->Number());
6049 }
6050 
6051 
6052 static inline void SetupArrayBufferView(
6053  i::Isolate* isolate,
6056  size_t byte_offset,
6057  size_t byte_length) {
6058  ASSERT(byte_offset + byte_length <=
6059  static_cast<size_t>(buffer->byte_length()->Number()));
6060 
6061  obj->set_buffer(*buffer);
6062 
6063  obj->set_weak_next(buffer->weak_first_view());
6064  buffer->set_weak_first_view(*obj);
6065 
6066  i::Handle<i::Object> byte_offset_object =
6067  isolate->factory()->NewNumberFromSize(byte_offset);
6068  obj->set_byte_offset(*byte_offset_object);
6069 
6070  i::Handle<i::Object> byte_length_object =
6071  isolate->factory()->NewNumberFromSize(byte_length);
6072  obj->set_byte_length(*byte_length_object);
6073 }
6074 
6075 template<typename ElementType,
6076  ExternalArrayType array_type,
6077  i::ElementsKind elements_kind>
6079  i::Isolate* isolate,
6080  Handle<ArrayBuffer> array_buffer, size_t byte_offset, size_t length) {
6082  isolate->factory()->NewJSTypedArray(array_type);
6083  i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer);
6084 
6085  ASSERT(byte_offset % sizeof(ElementType) == 0);
6086 
6087  CHECK(length <= (std::numeric_limits<size_t>::max() / sizeof(ElementType)));
6088  size_t byte_length = length * sizeof(ElementType);
6089  SetupArrayBufferView(
6090  isolate, obj, buffer, byte_offset, byte_length);
6091 
6092  i::Handle<i::Object> length_object =
6093  isolate->factory()->NewNumberFromSize(length);
6094  obj->set_length(*length_object);
6095 
6096  i::Handle<i::ExternalArray> elements =
6097  isolate->factory()->NewExternalArray(
6098  static_cast<int>(length), array_type,
6099  static_cast<uint8_t*>(buffer->backing_store()) + byte_offset);
6101  i::JSObject::GetElementsTransitionMap(obj, elements_kind);
6102  obj->set_map_and_elements(*map, *elements);
6103  return obj;
6104 }
6105 
6106 
6107 #define TYPED_ARRAY_NEW(Type, type, TYPE, ctype, size) \
6108  Local<Type##Array> Type##Array::New(Handle<ArrayBuffer> array_buffer, \
6109  size_t byte_offset, size_t length) { \
6110  i::Isolate* isolate = i::Isolate::Current(); \
6111  EnsureInitializedForIsolate(isolate, \
6112  "v8::" #Type "Array::New(Handle<ArrayBuffer>, size_t, size_t)"); \
6113  LOG_API(isolate, \
6114  "v8::" #Type "Array::New(Handle<ArrayBuffer>, size_t, size_t)"); \
6115  ENTER_V8(isolate); \
6116  i::Handle<i::JSTypedArray> obj = \
6117  NewTypedArray<ctype, v8::kExternal##Type##Array, \
6118  i::EXTERNAL_##TYPE##_ELEMENTS>( \
6119  isolate, array_buffer, byte_offset, length); \
6120  return Utils::ToLocal##Type##Array(obj); \
6121  }
6122 
6123 
6125 #undef TYPED_ARRAY_NEW
6126 
6128  size_t byte_offset, size_t byte_length) {
6129  i::Isolate* isolate = i::Isolate::Current();
6130  EnsureInitializedForIsolate(
6131  isolate, "v8::DataView::New(void*, size_t, size_t)");
6132  LOG_API(isolate, "v8::DataView::New(void*, size_t, size_t)");
6133  ENTER_V8(isolate);
6134  i::Handle<i::JSDataView> obj = isolate->factory()->NewJSDataView();
6135  i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer);
6136  SetupArrayBufferView(
6137  isolate, obj, buffer, byte_offset, byte_length);
6138  return Utils::ToLocal(obj);
6139 }
6140 
6141 
6143  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6144  EnsureInitializedForIsolate(i_isolate, "v8::Symbol::New()");
6145  LOG_API(i_isolate, "Symbol::New()");
6146  ENTER_V8(i_isolate);
6147  i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol();
6148  if (!name.IsEmpty()) result->set_name(*Utils::OpenHandle(*name));
6149  return Utils::ToLocal(result);
6150 }
6151 
6152 
6154  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6155  i::Handle<i::String> i_name = Utils::OpenHandle(*name);
6156  i::Handle<i::JSObject> registry = i_isolate->GetSymbolRegistry();
6157  i::Handle<i::String> part = i_isolate->factory()->for_string();
6160  i::Handle<i::Object> symbol = i::JSObject::GetProperty(symbols, i_name);
6161  if (!symbol->IsSymbol()) {
6162  ASSERT(symbol->IsUndefined());
6163  symbol = i_isolate->factory()->NewSymbol();
6164  i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name);
6165  i::JSObject::SetProperty(symbols, i_name, symbol, NONE, i::STRICT);
6166  }
6168 }
6169 
6170 
6172  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6173  i::Handle<i::String> i_name = Utils::OpenHandle(*name);
6174  i::Handle<i::JSObject> registry = i_isolate->GetSymbolRegistry();
6175  i::Handle<i::String> part = i_isolate->factory()->for_api_string();
6178  i::Handle<i::Object> symbol = i::JSObject::GetProperty(symbols, i_name);
6179  if (!symbol->IsSymbol()) {
6180  ASSERT(symbol->IsUndefined());
6181  symbol = i_isolate->factory()->NewSymbol();
6182  i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name);
6183  i::JSObject::SetProperty(symbols, i_name, symbol, NONE, i::STRICT);
6184  }
6186 }
6187 
6188 
6190  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6191  EnsureInitializedForIsolate(i_isolate, "v8::Private::New()");
6192  LOG_API(i_isolate, "Private::New()");
6193  ENTER_V8(i_isolate);
6194  i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol();
6195  if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name));
6196  Local<Symbol> result = Utils::ToLocal(symbol);
6197  return v8::Handle<Private>(reinterpret_cast<Private*>(*result));
6198 }
6199 
6200 
6202  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6203  i::Handle<i::String> i_name = Utils::OpenHandle(*name);
6204  i::Handle<i::JSObject> registry = i_isolate->GetSymbolRegistry();
6205  i::Handle<i::String> part = i_isolate->factory()->private_api_string();
6206  i::Handle<i::JSObject> privates =
6208  i::Handle<i::Object> symbol = i::JSObject::GetProperty(privates, i_name);
6209  if (!symbol->IsSymbol()) {
6210  ASSERT(symbol->IsUndefined());
6211  symbol = i_isolate->factory()->NewPrivateSymbol();
6212  i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name);
6213  i::JSObject::SetProperty(privates, i_name, symbol, NONE, i::STRICT);
6214  }
6216  return v8::Handle<Private>(reinterpret_cast<Private*>(*result));
6217 }
6218 
6219 
6220 Local<Number> v8::Number::New(Isolate* isolate, double value) {
6221  i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
6222  ASSERT(internal_isolate->IsInitialized());
6223  if (std::isnan(value)) {
6224  // Introduce only canonical NaN value into the VM, to avoid signaling NaNs.
6225  value = i::OS::nan_value();
6226  }
6227  ENTER_V8(internal_isolate);
6228  i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value);
6229  return Utils::NumberToLocal(result);
6230 }
6231 
6232 
6234  i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
6235  ASSERT(internal_isolate->IsInitialized());
6236  if (i::Smi::IsValid(value)) {
6238  internal_isolate));
6239  }
6240  ENTER_V8(internal_isolate);
6241  i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value);
6242  return Utils::IntegerToLocal(result);
6243 }
6244 
6245 
6247  i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
6248  ASSERT(internal_isolate->IsInitialized());
6249  bool fits_into_int32_t = (value & (1 << 31)) == 0;
6250  if (fits_into_int32_t) {
6251  return Integer::New(isolate, static_cast<int32_t>(value));
6252  }
6253  ENTER_V8(internal_isolate);
6254  i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value);
6255  return Utils::IntegerToLocal(result);
6256 }
6257 
6258 
6260  i::Isolate* isolate = i::Isolate::Current();
6261  EnsureInitializedForIsolate(isolate, "v8::V8::AddMessageListener()");
6262  ON_BAILOUT(isolate, "v8::V8::AddMessageListener()", return false);
6263  ENTER_V8(isolate);
6264  i::HandleScope scope(isolate);
6265  NeanderArray listeners(isolate->factory()->message_listeners());
6266  NeanderObject obj(isolate, 2);
6267  obj.set(0, *isolate->factory()->NewForeign(FUNCTION_ADDR(that)));
6268  obj.set(1, data.IsEmpty() ? isolate->heap()->undefined_value()
6269  : *Utils::OpenHandle(*data));
6270  listeners.add(obj.value());
6271  return true;
6272 }
6273 
6274 
6276  i::Isolate* isolate = i::Isolate::Current();
6277  EnsureInitializedForIsolate(isolate, "v8::V8::RemoveMessageListener()");
6278  ON_BAILOUT(isolate, "v8::V8::RemoveMessageListeners()", return);
6279  ENTER_V8(isolate);
6280  i::HandleScope scope(isolate);
6281  NeanderArray listeners(isolate->factory()->message_listeners());
6282  for (int i = 0; i < listeners.length(); i++) {
6283  if (listeners.get(i)->IsUndefined()) continue; // skip deleted ones
6284 
6285  NeanderObject listener(i::JSObject::cast(listeners.get(i)));
6286  i::Handle<i::Foreign> callback_obj(i::Foreign::cast(listener.get(0)));
6287  if (callback_obj->foreign_address() == FUNCTION_ADDR(that)) {
6288  listeners.set(i, isolate->heap()->undefined_value());
6289  }
6290  }
6291 }
6292 
6293 
6295  bool capture,
6296  int frame_limit,
6298  i::Isolate::Current()->SetCaptureStackTraceForUncaughtExceptions(
6299  capture,
6300  frame_limit,
6301  options);
6302 }
6303 
6304 
6306  i::Isolate* isolate = EnterIsolateIfNeeded();
6307  isolate->stats_table()->SetCounterFunction(callback);
6308 }
6309 
6310 
6312  i::Isolate* isolate = EnterIsolateIfNeeded();
6313  isolate->stats_table()->SetCreateHistogramFunction(callback);
6314  isolate->InitializeLoggingAndCounters();
6315  isolate->counters()->ResetHistograms();
6316 }
6317 
6318 
6320  i::Isolate* isolate = EnterIsolateIfNeeded();
6321  isolate->stats_table()->
6322  SetAddHistogramSampleFunction(callback);
6323 }
6324 
6326  FailedAccessCheckCallback callback) {
6327  i::Isolate* isolate = i::Isolate::Current();
6328  isolate->SetFailedAccessCheckCallback(callback);
6329 }
6330 
6331 
6333  int64_t change_in_bytes) {
6334  i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap();
6335  return heap->AdjustAmountOfExternalAllocatedMemory(change_in_bytes);
6336 }
6337 
6338 
6340  i::HeapProfiler* heap_profiler =
6341  reinterpret_cast<i::Isolate*>(this)->heap_profiler();
6342  return reinterpret_cast<HeapProfiler*>(heap_profiler);
6343 }
6344 
6345 
6347  i::CpuProfiler* cpu_profiler =
6348  reinterpret_cast<i::Isolate*>(this)->cpu_profiler();
6349  return reinterpret_cast<CpuProfiler*>(cpu_profiler);
6350 }
6351 
6352 
6354  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6355  return isolate->context() != NULL;
6356 }
6357 
6358 
6360  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6361  i::Context* context = isolate->context();
6362  if (context == NULL) return Local<Context>();
6363  i::Context* native_context = context->global_object()->native_context();
6364  if (native_context == NULL) return Local<Context>();
6365  return Utils::ToLocal(i::Handle<i::Context>(native_context));
6366 }
6367 
6368 
6370  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6371  i::Handle<i::Object> calling = isolate->GetCallingNativeContext();
6372  if (calling.is_null()) return Local<Context>();
6374 }
6375 
6376 
6378  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6379  i::Handle<i::Object> last =
6381  if (last.is_null()) return Local<Context>();
6383 }
6384 
6385 
6387  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6388  ENTER_V8(isolate);
6389  // If we're passed an empty handle, we throw an undefined exception
6390  // to deal more gracefully with out of memory situations.
6391  if (value.IsEmpty()) {
6392  isolate->ScheduleThrow(isolate->heap()->undefined_value());
6393  } else {
6394  isolate->ScheduleThrow(*Utils::OpenHandle(*value));
6395  }
6396  return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
6397 }
6398 
6399 
6401  i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(this);
6402  internal_isolate->global_handles()->SetObjectGroupId(
6403  v8::internal::Handle<v8::internal::Object>(object).location(),
6404  id);
6405 }
6406 
6407 
6408 void Isolate::SetReferenceFromGroup(UniqueId id, internal::Object** object) {
6409  i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(this);
6410  internal_isolate->global_handles()->SetReferenceFromGroup(
6411  id,
6412  v8::internal::Handle<v8::internal::Object>(object).location());
6413 }
6414 
6415 
6417  internal::Object** child) {
6418  i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(this);
6419  i::Object** parent_location =
6420  v8::internal::Handle<v8::internal::Object>(parent).location();
6421  internal_isolate->global_handles()->SetReference(
6422  reinterpret_cast<i::HeapObject**>(parent_location),
6423  v8::internal::Handle<v8::internal::Object>(child).location());
6424 }
6425 
6426 
6428  GCType gc_type) {
6429  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6430  isolate->heap()->AddGCPrologueCallback(callback, gc_type);
6431 }
6432 
6433 
6435  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6436  isolate->heap()->RemoveGCPrologueCallback(callback);
6437 }
6438 
6439 
6441  GCType gc_type) {
6442  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6443  isolate->heap()->AddGCEpilogueCallback(callback, gc_type);
6444 }
6445 
6446 
6448  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6449  isolate->heap()->RemoveGCEpilogueCallback(callback);
6450 }
6451 
6452 
6454  i::Isolate* isolate = i::Isolate::Current();
6455  isolate->heap()->AddGCPrologueCallback(
6456  reinterpret_cast<v8::Isolate::GCPrologueCallback>(callback),
6457  gc_type,
6458  false);
6459 }
6460 
6461 
6463  i::Isolate* isolate = i::Isolate::Current();
6464  isolate->heap()->RemoveGCPrologueCallback(
6465  reinterpret_cast<v8::Isolate::GCPrologueCallback>(callback));
6466 }
6467 
6468 
6470  i::Isolate* isolate = i::Isolate::Current();
6471  isolate->heap()->AddGCEpilogueCallback(
6472  reinterpret_cast<v8::Isolate::GCEpilogueCallback>(callback),
6473  gc_type,
6474  false);
6475 }
6476 
6477 
6479  i::Isolate* isolate = i::Isolate::Current();
6480  isolate->heap()->RemoveGCEpilogueCallback(
6481  reinterpret_cast<v8::Isolate::GCEpilogueCallback>(callback));
6482 }
6483 
6484 
6486  ObjectSpace space,
6487  AllocationAction action) {
6488  i::Isolate* isolate = i::Isolate::Current();
6490  callback, space, action);
6491 }
6492 
6493 
6495  i::Isolate* isolate = i::Isolate::Current();
6497  callback);
6498 }
6499 
6500 
6502  if (callback == NULL) return;
6504 }
6505 
6506 
6507 void V8::RunMicrotasks(Isolate* isolate) {
6508  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6509  i::HandleScope scope(i_isolate);
6510  i::V8::RunMicrotasks(i_isolate);
6511 }
6512 
6513 
6514 void V8::EnqueueMicrotask(Isolate* isolate, Handle<Function> microtask) {
6515  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6516  ENTER_V8(i_isolate);
6517  i::Execution::EnqueueMicrotask(i_isolate, Utils::OpenHandle(*microtask));
6518 }
6519 
6520 
6521 void V8::SetAutorunMicrotasks(Isolate* isolate, bool autorun) {
6522  reinterpret_cast<i::Isolate*>(isolate)->set_autorun_microtasks(autorun);
6523 }
6524 
6525 
6528 }
6529 
6530 
6532  // If no isolate is supplied, use the default isolate.
6533  if (isolate != NULL) {
6534  reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->TerminateExecution();
6535  } else {
6537  }
6538 }
6539 
6540 
6542  i::Isolate* i_isolate = isolate != NULL ?
6543  reinterpret_cast<i::Isolate*>(isolate) : i::Isolate::Current();
6544  return IsExecutionTerminatingCheck(i_isolate);
6545 }
6546 
6547 
6549  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6550  i_isolate->stack_guard()->CancelTerminateExecution();
6551 }
6552 
6553 
6554 void Isolate::RequestInterrupt(InterruptCallback callback, void* data) {
6555  reinterpret_cast<i::Isolate*>(this)->stack_guard()->RequestInterrupt(
6556  callback, data);
6557 }
6558 
6559 
6561  reinterpret_cast<i::Isolate*>(this)->stack_guard()->ClearInterrupt();
6562 }
6563 
6564 
6566  CHECK(i::FLAG_expose_gc);
6567  if (type == kMinorGarbageCollection) {
6568  reinterpret_cast<i::Isolate*>(this)->heap()->CollectGarbage(
6569  i::NEW_SPACE, "Isolate::RequestGarbageCollection",
6571  } else {
6572  ASSERT_EQ(kFullGarbageCollection, type);
6573  reinterpret_cast<i::Isolate*>(this)->heap()->CollectAllGarbage(
6575  "Isolate::RequestGarbageCollection", kGCCallbackFlagForced);
6576  }
6577 }
6578 
6579 
6581  i::Isolate* isolate = i::Isolate::UncheckedCurrent();
6582  return reinterpret_cast<Isolate*>(isolate);
6583 }
6584 
6585 
6587  i::Isolate* isolate = new i::Isolate();
6588  return reinterpret_cast<Isolate*>(isolate);
6589 }
6590 
6591 
6593  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6594  if (!Utils::ApiCheck(!isolate->IsInUse(),
6595  "v8::Isolate::Dispose()",
6596  "Disposing the isolate that is entered by a thread.")) {
6597  return;
6598  }
6599  isolate->TearDown();
6600 }
6601 
6602 
6604  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6605  isolate->Enter();
6606 }
6607 
6608 
6610  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6611  isolate->Exit();
6612 }
6613 
6614 
6616  Isolate* isolate,
6618  : on_failure_(on_failure) {
6619  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6620  if (on_failure_ == CRASH_ON_FAILURE) {
6621  internal_ = reinterpret_cast<void*>(
6622  new i::DisallowJavascriptExecution(i_isolate));
6623  } else {
6624  ASSERT_EQ(THROW_ON_FAILURE, on_failure);
6625  internal_ = reinterpret_cast<void*>(
6626  new i::ThrowOnJavascriptExecution(i_isolate));
6627  }
6628 }
6629 
6630 
6632  if (on_failure_ == CRASH_ON_FAILURE) {
6633  delete reinterpret_cast<i::DisallowJavascriptExecution*>(internal_);
6634  } else {
6635  delete reinterpret_cast<i::ThrowOnJavascriptExecution*>(internal_);
6636  }
6637 }
6638 
6639 
6641  Isolate* isolate) {
6642  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6643  internal_assert_ = reinterpret_cast<void*>(
6644  new i::AllowJavascriptExecution(i_isolate));
6645  internal_throws_ = reinterpret_cast<void*>(
6646  new i::NoThrowOnJavascriptExecution(i_isolate));
6647 }
6648 
6649 
6651  delete reinterpret_cast<i::AllowJavascriptExecution*>(internal_assert_);
6652  delete reinterpret_cast<i::NoThrowOnJavascriptExecution*>(internal_throws_);
6653 }
6654 
6655 
6657  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6658  if (!isolate->IsInitialized()) {
6659  heap_statistics->total_heap_size_ = 0;
6660  heap_statistics->total_heap_size_executable_ = 0;
6661  heap_statistics->total_physical_size_ = 0;
6662  heap_statistics->used_heap_size_ = 0;
6663  heap_statistics->heap_size_limit_ = 0;
6664  return;
6665  }
6666  i::Heap* heap = isolate->heap();
6667  heap_statistics->total_heap_size_ = heap->CommittedMemory();
6668  heap_statistics->total_heap_size_executable_ =
6669  heap->CommittedMemoryExecutable();
6670  heap_statistics->total_physical_size_ = heap->CommittedPhysicalMemory();
6671  heap_statistics->used_heap_size_ = heap->SizeOfObjects();
6672  heap_statistics->heap_size_limit_ = heap->MaxReserved();
6673 }
6674 
6675 
6677  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6678  isolate->set_event_logger(that);
6679 }
6680 
6682  : str_(NULL), length_(0) {
6683  i::Isolate* isolate = i::Isolate::Current();
6684  if (obj.IsEmpty()) return;
6685  ENTER_V8(isolate);
6686  i::HandleScope scope(isolate);
6687  TryCatch try_catch;
6688  Handle<String> str = obj->ToString();
6689  if (str.IsEmpty()) return;
6691  length_ = v8::Utf8Length(*i_str, isolate);
6692  str_ = i::NewArray<char>(length_ + 1);
6693  str->WriteUtf8(str_);
6694 }
6695 
6696 
6698  i::DeleteArray(str_);
6699 }
6700 
6701 
6703  : str_(NULL), length_(0) {
6704  i::Isolate* isolate = i::Isolate::Current();
6705  if (obj.IsEmpty()) return;
6706  ENTER_V8(isolate);
6707  i::HandleScope scope(isolate);
6708  TryCatch try_catch;
6709  Handle<String> str = obj->ToString();
6710  if (str.IsEmpty()) return;
6711  length_ = str->Length();
6712  str_ = i::NewArray<uint16_t>(length_ + 1);
6713  str->Write(str_);
6714 }
6715 
6716 
6718  i::DeleteArray(str_);
6719 }
6720 
6721 
6723  i::Isolate* isolate = i::Isolate::Current();
6724  LOG_API(isolate, "RangeError");
6725  ON_BAILOUT(isolate, "v8::Exception::RangeError()", return Local<Value>());
6726  ENTER_V8(isolate);
6727  i::Object* error;
6728  {
6729  i::HandleScope scope(isolate);
6730  i::Handle<i::String> message = Utils::OpenHandle(*raw_message);
6731  i::Handle<i::Object> result = isolate->factory()->NewRangeError(message);
6732  error = *result;
6733  }
6734  i::Handle<i::Object> result(error, isolate);
6735  return Utils::ToLocal(result);
6736 }
6737 
6738 
6740  i::Isolate* isolate = i::Isolate::Current();
6741  LOG_API(isolate, "ReferenceError");
6742  ON_BAILOUT(isolate, "v8::Exception::ReferenceError()", return Local<Value>());
6743  ENTER_V8(isolate);
6744  i::Object* error;
6745  {
6746  i::HandleScope scope(isolate);
6747  i::Handle<i::String> message = Utils::OpenHandle(*raw_message);
6748  i::Handle<i::Object> result =
6749  isolate->factory()->NewReferenceError(message);
6750  error = *result;
6751  }
6752  i::Handle<i::Object> result(error, isolate);
6753  return Utils::ToLocal(result);
6754 }
6755 
6756 
6758  i::Isolate* isolate = i::Isolate::Current();
6759  LOG_API(isolate, "SyntaxError");
6760  ON_BAILOUT(isolate, "v8::Exception::SyntaxError()", return Local<Value>());
6761  ENTER_V8(isolate);
6762  i::Object* error;
6763  {
6764  i::HandleScope scope(isolate);
6765  i::Handle<i::String> message = Utils::OpenHandle(*raw_message);
6766  i::Handle<i::Object> result = isolate->factory()->NewSyntaxError(message);
6767  error = *result;
6768  }
6769  i::Handle<i::Object> result(error, isolate);
6770  return Utils::ToLocal(result);
6771 }
6772 
6773 
6775  i::Isolate* isolate = i::Isolate::Current();
6776  LOG_API(isolate, "TypeError");
6777  ON_BAILOUT(isolate, "v8::Exception::TypeError()", return Local<Value>());
6778  ENTER_V8(isolate);
6779  i::Object* error;
6780  {
6781  i::HandleScope scope(isolate);
6782  i::Handle<i::String> message = Utils::OpenHandle(*raw_message);
6783  i::Handle<i::Object> result = isolate->factory()->NewTypeError(message);
6784  error = *result;
6785  }
6786  i::Handle<i::Object> result(error, isolate);
6787  return Utils::ToLocal(result);
6788 }
6789 
6790 
6792  i::Isolate* isolate = i::Isolate::Current();
6793  LOG_API(isolate, "Error");
6794  ON_BAILOUT(isolate, "v8::Exception::Error()", return Local<Value>());
6795  ENTER_V8(isolate);
6796  i::Object* error;
6797  {
6798  i::HandleScope scope(isolate);
6799  i::Handle<i::String> message = Utils::OpenHandle(*raw_message);
6800  i::Handle<i::Object> result = isolate->factory()->NewError(message);
6801  error = *result;
6802  }
6803  i::Handle<i::Object> result(error, isolate);
6804  return Utils::ToLocal(result);
6805 }
6806 
6807 
6808 // --- D e b u g S u p p o r t ---
6809 
6810 #ifdef ENABLE_DEBUGGER_SUPPORT
6811 
6812 bool Debug::SetDebugEventListener2(EventCallback2 that, Handle<Value> data) {
6813  i::Isolate* isolate = i::Isolate::Current();
6814  EnsureInitializedForIsolate(isolate, "v8::Debug::SetDebugEventListener2()");
6815  ON_BAILOUT(isolate, "v8::Debug::SetDebugEventListener2()", return false);
6816  ENTER_V8(isolate);
6817  i::HandleScope scope(isolate);
6818  i::Handle<i::Object> foreign = isolate->factory()->undefined_value();
6819  if (that != NULL) {
6820  foreign = isolate->factory()->NewForeign(FUNCTION_ADDR(that));
6821  }
6822  isolate->debugger()->SetEventListener(foreign,
6823  Utils::OpenHandle(*data, true));
6824  return true;
6825 }
6826 
6827 
6829  Handle<Value> data) {
6830  i::Isolate* isolate = i::Isolate::Current();
6831  ON_BAILOUT(isolate, "v8::Debug::SetDebugEventListener()", return false);
6832  ENTER_V8(isolate);
6833  isolate->debugger()->SetEventListener(Utils::OpenHandle(*that),
6834  Utils::OpenHandle(*data, true));
6835  return true;
6836 }
6837 
6838 
6839 void Debug::DebugBreak(Isolate* isolate) {
6840  // If no isolate is supplied, use the default isolate.
6841  if (isolate != NULL) {
6842  reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->DebugBreak();
6843  } else {
6845  }
6846 }
6847 
6848 
6849 void Debug::CancelDebugBreak(Isolate* isolate) {
6850  // If no isolate is supplied, use the default isolate.
6851  if (isolate != NULL) {
6852  i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
6853  internal_isolate->stack_guard()->Continue(i::DEBUGBREAK);
6854  } else {
6856  }
6857 }
6858 
6859 
6860 void Debug::DebugBreakForCommand(ClientData* data, Isolate* isolate) {
6861  // If no isolate is supplied, use the default isolate.
6862  if (isolate != NULL) {
6863  i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
6864  internal_isolate->debugger()->EnqueueDebugCommand(data);
6865  } else {
6866  i::Isolate::GetDefaultIsolateDebugger()->EnqueueDebugCommand(data);
6867  }
6868 }
6869 
6870 
6872  i::Isolate* isolate = i::Isolate::Current();
6873  EnsureInitializedForIsolate(isolate, "v8::Debug::SetMessageHandler");
6874  ENTER_V8(isolate);
6875  isolate->debugger()->SetMessageHandler(handler);
6876 }
6877 
6878 
6879 void Debug::SendCommand(Isolate* isolate,
6880  const uint16_t* command,
6881  int length,
6882  ClientData* client_data) {
6883  i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
6884  internal_isolate->debugger()->ProcessCommand(
6885  i::Vector<const uint16_t>(command, length), client_data);
6886 }
6887 
6888 
6889 void Debug::SendCommand(const uint16_t* command, int length,
6890  ClientData* client_data,
6891  Isolate* isolate) {
6892  // If no isolate is supplied, use the default isolate.
6893  if (isolate != NULL) {
6894  i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
6895  internal_isolate->debugger()->ProcessCommand(
6896  i::Vector<const uint16_t>(command, length), client_data);
6897  } else {
6898  i::Isolate::GetDefaultIsolateDebugger()->ProcessCommand(
6899  i::Vector<const uint16_t>(command, length), client_data);
6900  }
6901 }
6902 
6903 
6904 void Debug::SetHostDispatchHandler(HostDispatchHandler handler,
6905  int period) {
6906  i::Isolate* isolate = i::Isolate::Current();
6907  EnsureInitializedForIsolate(isolate, "v8::Debug::SetHostDispatchHandler");
6908  ENTER_V8(isolate);
6909  isolate->debugger()->SetHostDispatchHandler(
6910  handler, i::TimeDelta::FromMilliseconds(period));
6911 }
6912 
6913 
6915  DebugMessageDispatchHandler handler, bool provide_locker) {
6916  i::Isolate* isolate = i::Isolate::Current();
6917  EnsureInitializedForIsolate(isolate,
6918  "v8::Debug::SetDebugMessageDispatchHandler");
6919  ENTER_V8(isolate);
6920  isolate->debugger()->SetDebugMessageDispatchHandler(
6921  handler, provide_locker);
6922 }
6923 
6924 
6925 Local<Value> Debug::Call(v8::Handle<v8::Function> fun,
6926  v8::Handle<v8::Value> data) {
6927  i::Isolate* isolate = i::Isolate::Current();
6928  if (!isolate->IsInitialized()) return Local<Value>();
6929  ON_BAILOUT(isolate, "v8::Debug::Call()", return Local<Value>());
6930  ENTER_V8(isolate);
6931  i::Handle<i::Object> result;
6932  EXCEPTION_PREAMBLE(isolate);
6933  if (data.IsEmpty()) {
6934  result = isolate->debugger()->Call(Utils::OpenHandle(*fun),
6935  isolate->factory()->undefined_value(),
6936  &has_pending_exception);
6937  } else {
6938  result = isolate->debugger()->Call(Utils::OpenHandle(*fun),
6939  Utils::OpenHandle(*data),
6940  &has_pending_exception);
6941  }
6942  EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
6943  return Utils::ToLocal(result);
6944 }
6945 
6946 
6947 Local<Value> Debug::GetMirror(v8::Handle<v8::Value> obj) {
6948  i::Isolate* isolate = i::Isolate::Current();
6949  if (!isolate->IsInitialized()) return Local<Value>();
6950  ON_BAILOUT(isolate, "v8::Debug::GetMirror()", return Local<Value>());
6951  ENTER_V8(isolate);
6952  v8::EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
6953  i::Debug* isolate_debug = isolate->debug();
6954  isolate_debug->Load();
6955  i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global_object());
6957  STATIC_ASCII_VECTOR("MakeMirror"));
6958  i::Handle<i::Object> fun_obj = i::GetProperty(isolate, debug, name);
6961  const int kArgc = 1;
6962  v8::Handle<v8::Value> argv[kArgc] = { obj };
6963  EXCEPTION_PREAMBLE(isolate);
6964  v8::Local<v8::Value> result =
6965  v8_fun->Call(Utils::ToLocal(debug), kArgc, argv);
6966  EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
6967  return scope.Escape(result);
6968 }
6969 
6970 
6971 bool Debug::EnableAgent(const char* name, int port, bool wait_for_connection) {
6972  return i::Isolate::Current()->debugger()->StartAgent(name, port,
6973  wait_for_connection);
6974 }
6975 
6976 
6977 void Debug::DisableAgent() {
6978  return i::Isolate::Current()->debugger()->StopAgent();
6979 }
6980 
6981 
6983  i::Execution::ProcessDebugMessages(i::Isolate::Current(), true);
6984 }
6985 
6986 
6987 Local<Context> Debug::GetDebugContext() {
6988  i::Isolate* isolate = i::Isolate::Current();
6989  EnsureInitializedForIsolate(isolate, "v8::Debug::GetDebugContext()");
6990  ENTER_V8(isolate);
6991  return Utils::ToLocal(i::Isolate::Current()->debugger()->GetDebugContext());
6992 }
6993 
6994 
6995 void Debug::SetLiveEditEnabled(bool enable, Isolate* isolate) {
6996  // If no isolate is supplied, use the default isolate.
6997  i::Debugger* debugger;
6998  if (isolate != NULL) {
6999  i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
7000  debugger = internal_isolate->debugger();
7001  } else {
7002  debugger = i::Isolate::GetDefaultIsolateDebugger();
7003  }
7004  debugger->set_live_edit_enabled(enable);
7005 }
7006 
7007 
7008 #endif // ENABLE_DEBUGGER_SUPPORT
7009 
7010 
7012  i::Isolate* isolate = i::Isolate::Current();
7013  const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
7014  const i::CodeEntry* entry = node->entry();
7015  if (!entry->has_name_prefix()) {
7016  return ToApiHandle<String>(
7017  isolate->factory()->InternalizeUtf8String(entry->name()));
7018  } else {
7019  i::Handle<i::String> cons = isolate->factory()->NewConsString(
7020  isolate->factory()->InternalizeUtf8String(entry->name_prefix()),
7021  isolate->factory()->InternalizeUtf8String(entry->name()));
7022  // We do not expect this to fail. Change this if it does.
7023  CHECK(!cons.is_null());
7024  return ToApiHandle<String>(cons);
7025  }
7026 }
7027 
7028 
7030  const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
7031  const i::CodeEntry* entry = node->entry();
7032  return entry->script_id();
7033 }
7034 
7035 
7037  i::Isolate* isolate = i::Isolate::Current();
7038  const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
7039  return ToApiHandle<String>(isolate->factory()->InternalizeUtf8String(
7040  node->entry()->resource_name()));
7041 }
7042 
7043 
7045  return reinterpret_cast<const i::ProfileNode*>(this)->entry()->line_number();
7046 }
7047 
7048 
7050  return reinterpret_cast<const i::ProfileNode*>(this)->
7051  entry()->column_number();
7052 }
7053 
7054 
7056  const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
7057  return node->entry()->bailout_reason();
7058 }
7059 
7060 
7062  return reinterpret_cast<const i::ProfileNode*>(this)->self_ticks();
7063 }
7064 
7065 
7066 unsigned CpuProfileNode::GetCallUid() const {
7067  return reinterpret_cast<const i::ProfileNode*>(this)->entry()->GetCallUid();
7068 }
7069 
7070 
7071 unsigned CpuProfileNode::GetNodeId() const {
7072  return reinterpret_cast<const i::ProfileNode*>(this)->id();
7073 }
7074 
7075 
7077  return reinterpret_cast<const i::ProfileNode*>(this)->children()->length();
7078 }
7079 
7080 
7081 const CpuProfileNode* CpuProfileNode::GetChild(int index) const {
7082  const i::ProfileNode* child =
7083  reinterpret_cast<const i::ProfileNode*>(this)->children()->at(index);
7084  return reinterpret_cast<const CpuProfileNode*>(child);
7085 }
7086 
7087 
7089  i::Isolate* isolate = i::Isolate::Current();
7090  i::CpuProfiler* profiler = isolate->cpu_profiler();
7091  ASSERT(profiler != NULL);
7092  profiler->DeleteProfile(reinterpret_cast<i::CpuProfile*>(this));
7093 }
7094 
7095 
7097  i::Isolate* isolate = i::Isolate::Current();
7098  const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
7099  return ToApiHandle<String>(isolate->factory()->InternalizeUtf8String(
7100  profile->title()));
7101 }
7102 
7103 
7105  const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
7106  return reinterpret_cast<const CpuProfileNode*>(profile->top_down()->root());
7107 }
7108 
7109 
7110 const CpuProfileNode* CpuProfile::GetSample(int index) const {
7111  const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
7112  return reinterpret_cast<const CpuProfileNode*>(profile->sample(index));
7113 }
7114 
7115 
7116 int64_t CpuProfile::GetStartTime() const {
7117  const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
7118  return (profile->start_time() - i::Time::UnixEpoch()).InMicroseconds();
7119 }
7120 
7121 
7122 int64_t CpuProfile::GetEndTime() const {
7123  const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
7124  return (profile->end_time() - i::Time::UnixEpoch()).InMicroseconds();
7125 }
7126 
7127 
7129  return reinterpret_cast<const i::CpuProfile*>(this)->samples_count();
7130 }
7131 
7132 
7134  ASSERT(us >= 0);
7135  return reinterpret_cast<i::CpuProfiler*>(this)->set_sampling_interval(
7136  i::TimeDelta::FromMicroseconds(us));
7137 }
7138 
7139 
7140 void CpuProfiler::StartProfiling(Handle<String> title, bool record_samples) {
7141  reinterpret_cast<i::CpuProfiler*>(this)->StartProfiling(
7142  *Utils::OpenHandle(*title), record_samples);
7143 }
7144 
7145 
7146 void CpuProfiler::StartCpuProfiling(Handle<String> title, bool record_samples) {
7147  StartProfiling(title, record_samples);
7148 }
7149 
7150 
7152  return reinterpret_cast<CpuProfile*>(
7153  reinterpret_cast<i::CpuProfiler*>(this)->StopProfiling(
7154  *Utils::OpenHandle(*title)));
7155 }
7156 
7157 
7159  return StopProfiling(title);
7160 }
7161 
7162 
7163 void CpuProfiler::SetIdle(bool is_idle) {
7164  i::Isolate* isolate = reinterpret_cast<i::CpuProfiler*>(this)->isolate();
7165  i::StateTag state = isolate->current_vm_state();
7166  ASSERT(state == i::EXTERNAL || state == i::IDLE);
7167  if (isolate->js_entry_sp() != NULL) return;
7168  if (is_idle) {
7169  isolate->set_current_vm_state(i::IDLE);
7170  } else if (state == i::IDLE) {
7171  isolate->set_current_vm_state(i::EXTERNAL);
7172  }
7173 }
7174 
7175 
7176 static i::HeapGraphEdge* ToInternal(const HeapGraphEdge* edge) {
7177  return const_cast<i::HeapGraphEdge*>(
7178  reinterpret_cast<const i::HeapGraphEdge*>(edge));
7179 }
7180 
7181 
7183  return static_cast<HeapGraphEdge::Type>(ToInternal(this)->type());
7184 }
7185 
7186 
7188  i::Isolate* isolate = i::Isolate::Current();
7189  i::HeapGraphEdge* edge = ToInternal(this);
7190  switch (edge->type()) {
7191  case i::HeapGraphEdge::kContextVariable:
7192  case i::HeapGraphEdge::kInternal:
7193  case i::HeapGraphEdge::kProperty:
7194  case i::HeapGraphEdge::kShortcut:
7195  case i::HeapGraphEdge::kWeak:
7196  return ToApiHandle<String>(
7197  isolate->factory()->InternalizeUtf8String(edge->name()));
7198  case i::HeapGraphEdge::kElement:
7199  case i::HeapGraphEdge::kHidden:
7200  return ToApiHandle<Number>(
7201  isolate->factory()->NewNumberFromInt(edge->index()));
7202  default: UNREACHABLE();
7203  }
7204  return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
7205 }
7206 
7207 
7209  const i::HeapEntry* from = ToInternal(this)->from();
7210  return reinterpret_cast<const HeapGraphNode*>(from);
7211 }
7212 
7213 
7215  const i::HeapEntry* to = ToInternal(this)->to();
7216  return reinterpret_cast<const HeapGraphNode*>(to);
7217 }
7218 
7219 
7220 static i::HeapEntry* ToInternal(const HeapGraphNode* entry) {
7221  return const_cast<i::HeapEntry*>(
7222  reinterpret_cast<const i::HeapEntry*>(entry));
7223 }
7224 
7225 
7227  return static_cast<HeapGraphNode::Type>(ToInternal(this)->type());
7228 }
7229 
7230 
7232  i::Isolate* isolate = i::Isolate::Current();
7233  return ToApiHandle<String>(
7234  isolate->factory()->InternalizeUtf8String(ToInternal(this)->name()));
7235 }
7236 
7237 
7239  return ToInternal(this)->id();
7240 }
7241 
7242 
7243 int HeapGraphNode::GetSelfSize() const {
7244  size_t size = ToInternal(this)->self_size();
7245  CHECK(size <= static_cast<size_t>(internal::kMaxInt));
7246  return static_cast<int>(size);
7247 }
7248 
7249 
7251  return ToInternal(this)->self_size();
7252 }
7253 
7254 
7256  return ToInternal(this)->children().length();
7257 }
7258 
7259 
7260 const HeapGraphEdge* HeapGraphNode::GetChild(int index) const {
7261  return reinterpret_cast<const HeapGraphEdge*>(
7262  ToInternal(this)->children()[index]);
7263 }
7264 
7265 
7266 static i::HeapSnapshot* ToInternal(const HeapSnapshot* snapshot) {
7267  return const_cast<i::HeapSnapshot*>(
7268  reinterpret_cast<const i::HeapSnapshot*>(snapshot));
7269 }
7270 
7271 
7273  i::Isolate* isolate = i::Isolate::Current();
7274  if (isolate->heap_profiler()->GetSnapshotsCount() > 1) {
7275  ToInternal(this)->Delete();
7276  } else {
7277  // If this is the last snapshot, clean up all accessory data as well.
7278  isolate->heap_profiler()->DeleteAllSnapshots();
7279  }
7280 }
7281 
7282 
7283 unsigned HeapSnapshot::GetUid() const {
7284  return ToInternal(this)->uid();
7285 }
7286 
7287 
7289  i::Isolate* isolate = i::Isolate::Current();
7290  return ToApiHandle<String>(
7291  isolate->factory()->InternalizeUtf8String(ToInternal(this)->title()));
7292 }
7293 
7294 
7296  return reinterpret_cast<const HeapGraphNode*>(ToInternal(this)->root());
7297 }
7298 
7299 
7301  return reinterpret_cast<const HeapGraphNode*>(
7302  ToInternal(this)->GetEntryById(id));
7303 }
7304 
7305 
7307  return ToInternal(this)->entries().length();
7308 }
7309 
7310 
7311 const HeapGraphNode* HeapSnapshot::GetNode(int index) const {
7312  return reinterpret_cast<const HeapGraphNode*>(
7313  &ToInternal(this)->entries().at(index));
7314 }
7315 
7316 
7318  return ToInternal(this)->max_snapshot_js_object_id();
7319 }
7320 
7321 
7323  HeapSnapshot::SerializationFormat format) const {
7324  Utils::ApiCheck(format == kJSON,
7325  "v8::HeapSnapshot::Serialize",
7326  "Unknown serialization format");
7327  Utils::ApiCheck(stream->GetChunkSize() > 0,
7328  "v8::HeapSnapshot::Serialize",
7329  "Invalid stream chunk size");
7330  i::HeapSnapshotJSONSerializer serializer(ToInternal(this));
7331  serializer.Serialize(stream);
7332 }
7333 
7334 
7336  return reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshotsCount();
7337 }
7338 
7339 
7341  return reinterpret_cast<const HeapSnapshot*>(
7342  reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshot(index));
7343 }
7344 
7345 
7348  return reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshotObjectId(obj);
7349 }
7350 
7351 
7353  i::Handle<i::Object> obj =
7354  reinterpret_cast<i::HeapProfiler*>(this)->FindHeapObjectById(id);
7355  if (obj.is_null()) return Local<Value>();
7356  return Utils::ToLocal(obj);
7357 }
7358 
7359 
7361  reinterpret_cast<i::HeapProfiler*>(this)->ClearHeapObjectMap();
7362 }
7363 
7364 
7366  Handle<String> title,
7367  ActivityControl* control,
7368  ObjectNameResolver* resolver) {
7369  return reinterpret_cast<const HeapSnapshot*>(
7370  reinterpret_cast<i::HeapProfiler*>(this)->TakeSnapshot(
7371  *Utils::OpenHandle(*title), control, resolver));
7372 }
7373 
7374 
7375 void HeapProfiler::StartTrackingHeapObjects(bool track_allocations) {
7376  reinterpret_cast<i::HeapProfiler*>(this)->StartHeapObjectsTracking(
7377  track_allocations);
7378 }
7379 
7380 
7382  reinterpret_cast<i::HeapProfiler*>(this)->StopHeapObjectsTracking();
7383 }
7384 
7385 
7387  return reinterpret_cast<i::HeapProfiler*>(this)->PushHeapObjectsStats(stream);
7388 }
7389 
7390 
7392  reinterpret_cast<i::HeapProfiler*>(this)->DeleteAllSnapshots();
7393 }
7394 
7395 
7397  WrapperInfoCallback callback) {
7398  reinterpret_cast<i::HeapProfiler*>(this)->DefineWrapperClass(class_id,
7399  callback);
7400 }
7401 
7402 
7404  return reinterpret_cast<i::HeapProfiler*>(this)->
7405  GetMemorySizeUsedByProfiler();
7406 }
7407 
7408 
7410  RetainedObjectInfo* info) {
7411  reinterpret_cast<i::HeapProfiler*>(this)->SetRetainedObjectInfo(id, info);
7412 }
7413 
7414 
7415 v8::Testing::StressType internal::Testing::stress_type_ =
7417 
7418 
7421 }
7422 
7423 
7425  if (internal::FLAG_stress_runs != 0) return internal::FLAG_stress_runs;
7426 #ifdef DEBUG
7427  // In debug mode the code runs much slower so stressing will only make two
7428  // runs.
7429  return 2;
7430 #else
7431  return 5;
7432 #endif
7433 }
7434 
7435 
7436 static void SetFlagsFromString(const char* flags) {
7437  V8::SetFlagsFromString(flags, i::StrLength(flags));
7438 }
7439 
7440 
7442  static const char* kLazyOptimizations =
7443  "--prepare-always-opt "
7444  "--max-inlined-source-size=999999 "
7445  "--max-inlined-nodes=999999 "
7446  "--max-inlined-nodes-cumulative=999999 "
7447  "--noalways-opt";
7448  static const char* kForcedOptimizations = "--always-opt";
7449 
7450  // If deoptimization stressed turn on frequent deoptimization. If no value
7451  // is spefified through --deopt-every-n-times use a default default value.
7452  static const char* kDeoptEvery13Times = "--deopt-every-n-times=13";
7454  internal::FLAG_deopt_every_n_times == 0) {
7455  SetFlagsFromString(kDeoptEvery13Times);
7456  }
7457 
7458 #ifdef DEBUG
7459  // As stressing in debug mode only make two runs skip the deopt stressing
7460  // here.
7461  if (run == GetStressRuns() - 1) {
7462  SetFlagsFromString(kForcedOptimizations);
7463  } else {
7464  SetFlagsFromString(kLazyOptimizations);
7465  }
7466 #else
7467  if (run == GetStressRuns() - 1) {
7468  SetFlagsFromString(kForcedOptimizations);
7469  } else if (run != GetStressRuns() - 2) {
7470  SetFlagsFromString(kLazyOptimizations);
7471  }
7472 #endif
7473 }
7474 
7475 
7476 // TODO(svenpanne) Deprecate this.
7478  i::Isolate* isolate = i::Isolate::Current();
7479  i::HandleScope scope(isolate);
7481 }
7482 
7483 
7484 namespace internal {
7485 
7486 
7487 void HandleScopeImplementer::FreeThreadResources() {
7488  Free();
7489 }
7490 
7491 
7492 char* HandleScopeImplementer::ArchiveThread(char* storage) {
7493  HandleScopeData* current = isolate_->handle_scope_data();
7494  handle_scope_data_ = *current;
7495  OS::MemCopy(storage, this, sizeof(*this));
7496 
7497  ResetAfterArchive();
7498  current->Initialize();
7499 
7500  return storage + ArchiveSpacePerThread();
7501 }
7502 
7503 
7504 int HandleScopeImplementer::ArchiveSpacePerThread() {
7505  return sizeof(HandleScopeImplementer);
7506 }
7507 
7508 
7509 char* HandleScopeImplementer::RestoreThread(char* storage) {
7510  OS::MemCopy(this, storage, sizeof(*this));
7511  *isolate_->handle_scope_data() = handle_scope_data_;
7512  return storage + ArchiveSpacePerThread();
7513 }
7514 
7515 
7516 void HandleScopeImplementer::IterateThis(ObjectVisitor* v) {
7517 #ifdef DEBUG
7518  bool found_block_before_deferred = false;
7519 #endif
7520  // Iterate over all handles in the blocks except for the last.
7521  for (int i = blocks()->length() - 2; i >= 0; --i) {
7522  Object** block = blocks()->at(i);
7523  if (last_handle_before_deferred_block_ != NULL &&
7524  (last_handle_before_deferred_block_ <= &block[kHandleBlockSize]) &&
7525  (last_handle_before_deferred_block_ >= block)) {
7526  v->VisitPointers(block, last_handle_before_deferred_block_);
7527  ASSERT(!found_block_before_deferred);
7528 #ifdef DEBUG
7529  found_block_before_deferred = true;
7530 #endif
7531  } else {
7532  v->VisitPointers(block, &block[kHandleBlockSize]);
7533  }
7534  }
7535 
7536  ASSERT(last_handle_before_deferred_block_ == NULL ||
7537  found_block_before_deferred);
7538 
7539  // Iterate over live handles in the last block (if any).
7540  if (!blocks()->is_empty()) {
7541  v->VisitPointers(blocks()->last(), handle_scope_data_.next);
7542  }
7543 
7544  List<Context*>* context_lists[2] = { &saved_contexts_, &entered_contexts_};
7545  for (unsigned i = 0; i < ARRAY_SIZE(context_lists); i++) {
7546  if (context_lists[i]->is_empty()) continue;
7547  Object** start = reinterpret_cast<Object**>(&context_lists[i]->first());
7548  v->VisitPointers(start, start + context_lists[i]->length());
7549  }
7550 }
7551 
7552 
7553 void HandleScopeImplementer::Iterate(ObjectVisitor* v) {
7554  HandleScopeData* current = isolate_->handle_scope_data();
7555  handle_scope_data_ = *current;
7556  IterateThis(v);
7557 }
7558 
7559 
7560 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
7561  HandleScopeImplementer* scope_implementer =
7562  reinterpret_cast<HandleScopeImplementer*>(storage);
7563  scope_implementer->IterateThis(v);
7564  return storage + ArchiveSpacePerThread();
7565 }
7566 
7567 
7568 DeferredHandles* HandleScopeImplementer::Detach(Object** prev_limit) {
7569  DeferredHandles* deferred =
7570  new DeferredHandles(isolate()->handle_scope_data()->next, isolate());
7571 
7572  while (!blocks_.is_empty()) {
7573  Object** block_start = blocks_.last();
7574  Object** block_limit = &block_start[kHandleBlockSize];
7575  // We should not need to check for SealHandleScope here. Assert this.
7576  ASSERT(prev_limit == block_limit ||
7577  !(block_start <= prev_limit && prev_limit <= block_limit));
7578  if (prev_limit == block_limit) break;
7579  deferred->blocks_.Add(blocks_.last());
7580  blocks_.RemoveLast();
7581  }
7582 
7583  // deferred->blocks_ now contains the blocks installed on the
7584  // HandleScope stack since BeginDeferredScope was called, but in
7585  // reverse order.
7586 
7587  ASSERT(prev_limit == NULL || !blocks_.is_empty());
7588 
7589  ASSERT(!blocks_.is_empty() && prev_limit != NULL);
7590  ASSERT(last_handle_before_deferred_block_ != NULL);
7591  last_handle_before_deferred_block_ = NULL;
7592  return deferred;
7593 }
7594 
7595 
7596 void HandleScopeImplementer::BeginDeferredScope() {
7597  ASSERT(last_handle_before_deferred_block_ == NULL);
7598  last_handle_before_deferred_block_ = isolate()->handle_scope_data()->next;
7599 }
7600 
7601 
7602 DeferredHandles::~DeferredHandles() {
7603  isolate_->UnlinkDeferredHandles(this);
7604 
7605  for (int i = 0; i < blocks_.length(); i++) {
7606 #ifdef ENABLE_HANDLE_ZAPPING
7607  HandleScope::ZapRange(blocks_[i], &blocks_[i][kHandleBlockSize]);
7608 #endif
7609  isolate_->handle_scope_implementer()->ReturnBlock(blocks_[i]);
7610  }
7611 }
7612 
7613 
7614 void DeferredHandles::Iterate(ObjectVisitor* v) {
7615  ASSERT(!blocks_.is_empty());
7616 
7617  ASSERT((first_block_limit_ >= blocks_.first()) &&
7618  (first_block_limit_ <= &(blocks_.first())[kHandleBlockSize]));
7619 
7620  v->VisitPointers(blocks_.first(), first_block_limit_);
7621 
7622  for (int i = 1; i < blocks_.length(); i++) {
7623  v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]);
7624  }
7625 }
7626 
7627 
7629  v8::Local<v8::String> property,
7631  v8::AccessorGetterCallback getter) {
7632  // Leaving JavaScript.
7633  Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7634  Address getter_address = reinterpret_cast<Address>(reinterpret_cast<intptr_t>(
7635  getter));
7636  VMState<EXTERNAL> state(isolate);
7637  ExternalCallbackScope call_scope(isolate, getter_address);
7638  getter(property, info);
7639 }
7640 
7641 
7643  v8::FunctionCallback callback) {
7644  Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7645  Address callback_address =
7646  reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7647  VMState<EXTERNAL> state(isolate);
7648  ExternalCallbackScope call_scope(isolate, callback_address);
7649  callback(info);
7650 }
7651 
7652 
7653 } } // namespace v8::internal
void Enter()
Definition: api.cc:650
byte * Address
Definition: globals.h:186
static void MergeLeafRight(int *length, uint8_t *state, uint8_t leaf_state)
Definition: api.cc:4357
void SaveContext(Context *context)
Definition: api.h:619
void DeleteAllHeapSnapshots()
Definition: api.cc:7391
void SetAccessor(Handle< String > name, AccessorGetterCallback getter, AccessorSetterCallback setter=0, Handle< Value > data=Handle< Value >(), AccessControl settings=DEFAULT, PropertyAttribute attribute=None, Handle< AccessorSignature > signature=Handle< AccessorSignature >())
Definition: api.cc:1404
void VisitOneByteString(const uint8_t *chars, int length)
Definition: api.cc:4617
void RequestInterrupt(InterruptCallback callback, void *data)
Definition: api.cc:6554
static Local< Signature > New(Isolate *isolate, Handle< FunctionTemplate > receiver=Handle< FunctionTemplate >(), int argc=0, Handle< FunctionTemplate > argv[]=0)
Definition: api.cc:957
static Isolate * GetCurrent()
Definition: api.cc:6580
static Handle< Object > SetElement(Handle< JSObject > object, uint32_t index, Handle< Object > value, PropertyAttributes attributes, StrictMode strict_mode, bool check_prototype=true, SetPropertyMode set_mode=SET_PROPERTY)
Definition: objects.cc:12410
void SetLength(int length)
Definition: api.cc:1243
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
V8_INLINE Local< Value > GetEmbedderData(int index)
Definition: v8.h:6622
static V8_INLINE Local< T > New(Isolate *isolate, Handle< T > that)
Definition: v8.h:5713
static void set_stress_type(v8::Testing::StressType stress_type)
Definition: api.h:708
static Handle< Object > New(Handle< JSFunction > func, int argc, Handle< Object > argv[], bool *pending_exception)
Definition: execution.cc:190
void DeleteProfile(CpuProfile *profile)
Handle< Context > LastEnteredContext()
Definition: api.h:649
RegisteredExtension * next()
Definition: api.h:151
int Length() const
Definition: api.cc:4137
static Local< Symbol > ForApi(Isolate *isolate, Local< String > name)
Definition: api.cc:6171
static void SetLiveEditEnabled(bool enable, Isolate *isolate=NULL)
double NumberValue() const
Definition: api.cc:2829
static bool Initialize(Deserializer *des)
Definition: v8.cc:61
static T ** CreateHandle(Isolate *isolate, T *value)
Definition: handles-inl.h:165
const HeapGraphEdge * GetChild(int index) const
Definition: api.cc:7260
GarbageCollectionType
Definition: v8.h:4190
static const byte * data()
Definition: snapshot.h:55
static void Destroy(Object **location)
int GetLineNumber() const
Definition: api.cc:2210
void FlattenString(Handle< String > string)
Definition: handles.cc:151
bool IsEval() const
Definition: api.cc:2288
static void AddGCEpilogueCallback(GCEpilogueCallback callback, GCType gc_type_filter=kGCTypeAll)
Definition: api.cc:6469
int WriteUtf8(char *buffer, int length=-1, int *nchars_ref=NULL, int options=NO_OPTIONS) const
Definition: api.cc:4672
static void SetAllowCodeGenerationFromStringsCallback(AllowCodeGenerationFromStringsCallback that)
Definition: api.cc:399
bool HasRealIndexedProperty(uint32_t index)
Definition: api.cc:3499
void(* MemoryAllocationCallback)(ObjectSpace space, AllocationAction action, int size)
Definition: v8.h:4038
void set_max_young_space_size(int value)
Definition: v8.h:3951
Handle< JSObject > NewJSObject(Handle< JSFunction > constructor, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:1319
DateCache * date_cache()
Definition: isolate.h:1025
Handle< String > NewExternalStringFromAscii(const ExternalAsciiString::Resource *resource)
Definition: factory.cc:554
#define CHECK_EQ(expected, value)
Definition: checks.h:252
bool IsTrue() const
Definition: api.cc:2347
bool IsTypedArray() const
Definition: api.cc:2389
Local< Array > AsArray()
Definition: api.cc:2189
uint8_t * GetIndexedPropertiesPixelData()
Definition: api.cc:3774
static bool IsExecutionTerminating(Isolate *isolate=NULL)
Definition: api.cc:6541
static const int kMaxLength
Definition: objects.h:4699
const char * title() const
const char * data
Definition: v8.h:4443
CpuProfiler * GetCpuProfiler()
Definition: api.cc:6346
static int NumberOfHandles(Isolate *isolate)
Definition: api.cc:611
const char * bailout_reason() const
Local< Value > Call(Handle< Value > recv, int argc, Handle< Value > argv[])
Definition: api.cc:3996
Address js_entry_sp()
Definition: isolate.h:659
static internal::Object ** CreateHandle(internal::Isolate *isolate, internal::Object *value)
Definition: api.cc:617
void StopTrackingHeapObjects()
Definition: api.cc:7381
bool DeleteHiddenValue(Handle< String > key)
Definition: api.cc:3694
void Dispose()
Definition: api.cc:6592
static Handle< SharedFunctionInfo > CompileScript(Handle< String > source, Handle< Object > script_name, int line_offset, int column_offset, bool is_shared_cross_origin, Handle< Context > context, v8::Extension *extension, ScriptDataImpl **cached_data, CachedDataMode cached_data_mode, NativesFlag is_natives_code)
Definition: compiler.cc:917
Local< String > GetSource() const
Definition: api.cc:5764
const ExternalAsciiStringResource * GetExternalAsciiStringResource() const
Definition: api.cc:4821
static int GetStressRuns()
Definition: api.cc:7424
void(* CallCompletedCallback)()
Definition: v8.h:4043
void SetEventLogger(LogEventCallback that)
Definition: api.cc:6676
void RecordWrite(Handle< String > string)
Definition: api.h:420
intptr_t * old_pointer_space_size
Definition: heap.h:2564
void SetWrapperClassInfoProvider(uint16_t class_id, WrapperInfoCallback callback)
Definition: api.cc:7396
void Exit()
Definition: api.cc:6609
intptr_t * cell_space_size
Definition: heap.h:2572
const HeapGraphNode * GetFromNode() const
Definition: api.cc:7208
Handle< String > InternalizeString(Handle< String > str)
Definition: factory.cc:225
static void SetArrayBufferAllocator(v8::ArrayBuffer::Allocator *allocator)
Definition: v8.h:110
SnapshotObjectId GetObjectId(Handle< Value > value)
Definition: api.cc:7346
void CollectAllGarbage(int flags, const char *gc_reason=NULL, const GCCallbackFlags gc_callback_flags=kNoGCCallbackFlags)
Definition: heap.cc:731
static Local< Private > ForApi(Isolate *isolate, Local< String > name)
Definition: api.cc:6201
static Local< Value > New(bool value)
Definition: api.cc:5620
void SetSecurityToken(Handle< Value > token)
Definition: api.cc:5207
Extension(const char *name, const char *source=0, int dep_count=0, const char **deps=0, int source_length=-1)
Definition: api.cc:445
Local< Value > Exception() const
Definition: api.cc:1923
static Handle< Object > ToNumber(Isolate *isolate, Handle< Object > obj, bool *exc)
Definition: execution.cc:713
static String * cast(Object *obj)
void ScheduleThrow(Object *exception)
Definition: isolate.cc:956
#define FATAL(msg)
Definition: checks.h:48
void AddGCEpilogueCallback(v8::Isolate::GCEpilogueCallback callback, GCType gc_type_filter, bool pass_isolate=true)
Definition: heap.cc:6834
V8_INLINE HandleScope()
Definition: v8.h:845
Handle< Value > FindObjectById(SnapshotObjectId id)
Definition: api.cc:7352
int * new_space_capacity
Definition: heap.h:2563
static void DeleteHiddenProperty(Handle< JSObject > object, Handle< Name > key)
Definition: objects.cc:4903
HandleScopeImplementer * handle_scope_implementer()
Definition: isolate.h:902
ProfileNode * root() const
static void CancelTerminateExecution(Isolate *isolate)
Definition: api.cc:6548
Definition: v8.h:4622
v8::internal::Handle< v8::internal::JSObject > value()
Definition: api.h:76
void ClearObjectIds()
Definition: api.cc:7360
Handle< Context > GetCallingNativeContext()
Definition: isolate.cc:1382
void set(int index, v8::internal::Object *value)
Definition: api.cc:807
void SetAccessorProperty(Local< String > name, Local< Function > getter, Handle< Function > setter=Handle< Function >(), PropertyAttribute attribute=None, AccessControl settings=DEFAULT)
Definition: api.cc:3460
Local< Object > CloneElementAt(uint32_t index)
Definition: api.cc:5811
void(* FunctionCallback)(const FunctionCallbackInfo< Value > &info)
Definition: v8.h:2603
Definition: v8.h:1407
static Local< Number > NumberToLocal(v8::internal::Handle< v8::internal::Object > obj)
bool StrictEquals(Handle< Value > that) const
Definition: api.cc:2977
V8_INLINE Isolate * GetIsolate() const
Definition: v8.h:6061
int64_t AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes)
Definition: heap-inl.h:582
static Handle< Object > ToObject(Isolate *isolate, Handle< Object > obj, bool *exc)
Definition: execution.cc:731
static void SetAddHistogramSampleFunction(AddHistogramSampleCallback)
Definition: api.cc:6319
Local< Value > Get(Handle< Value > key)
Definition: api.cc:3139
void RemoveGCPrologueCallback(v8::Isolate::GCPrologueCallback callback)
Definition: heap.cc:6822
static Smi * FromInt(int value)
Definition: objects-inl.h:1209
bool IsPromise() const
Definition: api.cc:5833
bool IsNativeError() const
Definition: api.cc:2505
PerIsolateAssertScope< JAVASCRIPT_EXECUTION_ASSERT, true > AllowJavascriptExecution
Definition: assert-scope.h:253
void SetObjectGroupId(const Persistent< T > &object, UniqueId id)
Definition: v8.h:6596
void V8_EXPORT RegisterExtension(Extension *extension)
Definition: api.cc:439
Local< Object > NewInstance()
Definition: api.cc:5284
PropertyAttribute GetPropertyAttributes(Handle< Value > key)
Definition: api.cc:3171
~HandleScope()
Definition: api.cc:606
Handle< JSObject > GetSymbolRegistry()
Definition: isolate.cc:2300
bool HasCaught() const
Definition: api.cc:1901
Local< Array > GetOwnPropertyNames()
Definition: api.cc:3259
void SetCaptureMessage(bool value)
Definition: api.cc:1981
static int WriteEndCharacter(uint16_t character, int last_character, int remaining, char *const buffer, bool replace_invalid_utf8)
Definition: api.cc:4484
StackTraceOptions
Definition: v8.h:1280
static ObjectTemplateInfo * cast(Object *obj)
intptr_t MaxReserved()
Definition: heap.h:593
Handle< Value > GetName() const
Definition: api.cc:7187
static Local< RawOperationDescriptor > NewInternalFieldDereference(Isolate *isolate, int internal_field)
Definition: api.cc:1007
NeanderArray(v8::internal::Isolate *isolate)
Definition: api.cc:770
static Local< AccessorSignature > AccessorSignatureToLocal(v8::internal::Handle< v8::internal::FunctionTemplateInfo > obj)
const char * GetBailoutReason() const
Definition: api.cc:7055
bool SameValue(Handle< Value > that) const
Definition: api.cc:3009
Handle< String > NewStringFromOneByte(Vector< const uint8_t > str, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:265
static void MergeTerminal(int *length, uint8_t state, uint8_t *state_out)
Definition: api.cc:4375
StatsTable * stats_table()
Definition: isolate.cc:2110
Handle< String > GetName() const
Definition: api.cc:7231
SnapshotObjectId GetId() const
Definition: api.cc:7238
bool IsBooleanObject() const
Definition: api.cc:2523
Local< DeclaredAccessorDescriptor > NewPrimitiveValue(Isolate *isolate, DeclaredAccessorDescriptorDataType data_type, uint8_t bool_offset=0)
Definition: api.cc:1053
static Handle< T > cast(Handle< S > that)
Definition: handles.h:75
Local< String > Get() const
Definition: api.cc:1989
static void SetCaptureStackTraceForUncaughtExceptions(bool capture, int frame_limit=10, StackTrace::StackTraceOptions options=StackTrace::kOverview)
Definition: api.cc:6294
void AllowCodeGenerationFromStrings(bool allow)
Definition: api.cc:5261
Contents Externalize()
Definition: api.cc:5962
Handle< JSDataView > NewJSDataView()
Definition: factory.cc:1506
void AddString(String *string)
Definition: heap-inl.h:697
T Max(T a, T b)
Definition: utils.h:227
bool DeletePrivate(Handle< Private > key)
Definition: api.cc:3371
Local< Context > GetEnteredContext()
Definition: api.cc:6377
int64_t GetStartTime() const
Definition: api.cc:7116
const CpuProfileNode * GetChild(int index) const
Definition: api.cc:7081
static void ShutdownPlatform()
Definition: v8.cc:227
V8_INLINE void * GetAlignedPointerFromEmbedderData(int index)
Definition: v8.h:6637
static bool HasRealElementProperty(Handle< JSObject > object, uint32_t index)
Definition: objects.cc:13259
void VisitExternalResources(v8::ExternalResourceVisitor *visitor)
Definition: heap.cc:2073
bool IsExternal() const
Definition: api.cc:2426
bool(* IndexedSecurityCallback)(Local< Object > host, uint32_t index, AccessType type, Local< Value > data)
Definition: v8.h:3418
void Initialize(Isolate *isolate)
Definition: api.cc:589
Local< String > GetConstructorName()
Definition: api.cc:3345
bool SetDeclaredAccessor(Local< String > name, Local< DeclaredAccessorDescriptor > descriptor, PropertyAttribute attribute=None, AccessControl settings=DEFAULT)
Definition: api.cc:3450
bool InitializeICU(const char *icu_data_file)
Definition: icu_util.cc:64
Local< ObjectTemplate > InstanceTemplate()
Definition: api.cc:1223
Local< Int32 > ToInt32() const
Definition: api.cc:2867
double ValueOf() const
Definition: api.cc:5702
void set_function_entry_hook(FunctionEntryHook function_entry_hook)
Definition: isolate.h:1100
kSerializedDataOffset Object
Definition: objects-inl.h:5016
bool IsSymbolObject() const
Definition: api.cc:2469
static Handle< Object > SetPrototype(Handle< JSObject > object, Handle< Object > value, bool skip_hidden_prototypes=false)
Definition: objects.cc:11703
Definition: v8.h:933
#define ARRAY_TYPE_TO_ELEMENTS_KIND(Type, type, TYPE, ctype, size)
Local< Context > CreationContext()
Definition: api.cc:3639
static bool HasRealNamedProperty(Handle< JSObject > object, Handle< Name > key)
Definition: objects.cc:13241
bool ValueOf() const
Definition: api.cc:5634
void Visit(const Char *chars, const int length)
Definition: api.cc:4529
Handle< Symbol > NewPrivateSymbol()
Definition: factory.cc:580
Local< Value > ThrowException(Local< Value > exception)
Definition: api.cc:6386
int int32_t
Definition: unicode.cc:47
static void AddMemoryAllocationCallback(MemoryAllocationCallback callback, ObjectSpace space, AllocationAction action)
Definition: api.cc:6485
v8::DeclaredAccessorDescriptorDataType data_type
Definition: objects.h:10180
void(* MessageCallback)(Handle< Message > message, Handle< Value > error)
Definition: v8.h:3987
Handle< JSArray > NewJSArrayWithElements(Handle< FixedArrayBase > elements, ElementsKind elements_kind, int length, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:1456
Handle< Object > DeleteProperty(Handle< JSObject > object, Handle< Object > key)
Definition: handles.cc:170
static void SetReturnAddressLocationResolver(ReturnAddressLocationResolver return_address_resolver)
Definition: api.cc:4981
bool HasRealNamedCallbackProperty(Handle< String > key)
Definition: api.cc:3507
Local< Value > GetHiddenValue(Handle< String > key)
Definition: api.cc:3679
static bool HasRealNamedCallbackProperty(Handle< JSObject > object, Handle< Name > key)
Definition: objects.cc:13283
Bootstrapper * bootstrapper()
Definition: isolate.h:858
Handle< String > GetScriptResourceName() const
Definition: api.cc:7036
void VisitOneByteString(const uint8_t *chars, int length)
Definition: api.cc:4293
const HeapGraphNode * GetNodeById(SnapshotObjectId id) const
Definition: api.cc:7300
static Local< Context > GetDebugContext()
static void EnqueueMicrotask(Isolate *isolate, Handle< Function > microtask)
Definition: api.cc:6514
const int kMaxInt
Definition: globals.h:248
static Foreign * cast(Object *obj)
int GetStartPosition() const
Definition: api.cc:2076
static const unsigned kMax16BitCodeUnitSize
Definition: unicode.h:175
int length()
Definition: api.cc:775
CodeEntry * entry() const
AllocationAction
Definition: v8.h:4032
static const int kNoColumnInfo
Definition: v8.h:1264
int *(* CounterLookupCallback)(const char *name)
Definition: v8.h:4009
struct ObjectDerefenceDescriptor object_dereference_descriptor
Definition: objects.h:10201
static Handle< Object > GetElementNoExceptionThrown(Isolate *isolate, Handle< Object > object, uint32_t index)
Definition: objects-inl.h:1071
const HeapGraphNode * GetNode(int index) const
Definition: api.cc:7311
static Local< Value > Error(Handle< String > message)
Definition: api.cc:6791
intptr_t * code_space_size
Definition: heap.h:2568
bool SetPrivate(Handle< Private > key, Handle< Value > value)
Definition: api.cc:3109
static void set_context_raw_data(const byte *context_raw_data)
Definition: snapshot.h:64
static Handle< String > GetMessage(Isolate *isolate, Handle< Object > data)
Definition: messages.cc:152
V8_INLINE Local< T > Escape(Local< T > value)
Definition: v8.h:892
Local< Array > GetPropertyNames()
Definition: api.cc:3238
ExternalArrayType GetIndexedPropertiesExternalArrayDataType()
Definition: api.cc:3844
HandleScopeData * handle_scope_data()
Definition: isolate.h:900
void SetReferenceFromGroup(UniqueId id, Object **child)
static Local< String > NewFromOneByte(Isolate *isolate, const uint8_t *data, NewStringType type=kNormalString, int length=-1)
Definition: api.cc:5430
ProfileNode * sample(int index) const
unsigned GetNodeId() const
Definition: api.cc:7071
bool IsRegExp() const
Definition: api.cc:2530
static Handle< Object > SetHiddenProperty(Handle< JSObject > object, Handle< Name > key, Handle< Object > value)
Definition: objects.cc:4861
bool IsBuiltin() const
Definition: api.cc:4107
static Handle< Object > NewDate(Isolate *isolate, double time, bool *exc)
Definition: execution.cc:756
static const int kLineOffsetNotFound
Definition: v8.h:2669
Local< Context > GetCurrentContext()
Definition: api.cc:6359
#define ENTER_V8(isolate)
Definition: api.cc:73
void AddGCPrologueCallback(GCPrologueCallback callback, GCType gc_type_filter=kGCTypeAll)
Definition: api.cc:6427
Utf8Value(Handle< v8::Value > obj)
Definition: api.cc:6681
void(* IndexedPropertyDeleterCallback)(uint32_t index, const PropertyCallbackInfo< Boolean > &info)
Definition: v8.h:3379
#define ASSERT(condition)
Definition: checks.h:329
void Create(Isolate *isolate, Object *object, int *index)
static Vector< const byte > GetScriptsSource()
static void PrintCurrentStackTrace(Isolate *isolate, FILE *out)
Definition: api.cc:2161
void(* GCPrologueCallback)(GCType type, GCCallbackFlags flags)
Definition: v8.h:4080
~TryCatch()
Definition: api.cc:1878
Local< Number > ToNumber() const
Definition: api.cc:2602
void SetFailedAccessCheckCallback(v8::FailedAccessCheckCallback callback)
Definition: isolate.cc:714
void UseDefaultSecurityToken()
Definition: api.cc:5216
static int size()
Definition: snapshot.h:56
CompressionAlgorithm
Definition: v8.h:4438
static StackGuard * GetDefaultIsolateStackGuard()
Definition: isolate.cc:223
DisallowJavascriptExecutionScope(Isolate *isolate, OnFailure on_failure)
Definition: api.cc:6615
static Handle< Object > TryGetFunctionDelegate(Isolate *isolate, Handle< Object > object, bool *has_pending_exception)
Definition: execution.cc:265
static Script * cast(Object *obj)
Handle< Value > GetDisplayName() const
Definition: api.cc:4045
i::Handle< i::JSTypedArray > NewTypedArray(i::Isolate *isolate, Handle< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
Definition: api.cc:6078
ExternalArrayType
Definition: v8.h:2113
void(* MessageHandler2)(const Message &message)
Definition: v8-debug.h:173
unsigned short uint16_t
Definition: unicode.cc:46
void(* AccessorSetterCallback)(Local< String > property, Local< Value > value, const PropertyCallbackInfo< void > &info)
Definition: v8.h:2146
int script_id() const
void * GetIndexedPropertiesExternalArrayData()
Definition: api.cc:3831
TryCatch()
Definition: api.cc:1865
bool IsCallable()
Definition: api.cc:3874
static Handle< Object > ToDetailString(Isolate *isolate, Handle< Object > obj, bool *exc)
Definition: execution.cc:725
static void SetDecompressedStartupData(StartupData *decompressed_data)
Definition: api.cc:364
size_t GetShallowSize() const
Definition: api.cc:7250
Handle< Object > NewRangeError(const char *message, Vector< Handle< Object > > args)
Definition: factory.cc:1050
#define EXCEPTION_BAILOUT_CHECK(isolate, value)
Definition: api.cc:112
ThreadManager * thread_manager()
Definition: isolate.h:922
static Local< Integer > New(Isolate *isolate, int32_t value)
Definition: api.cc:6233
static SharedFunctionInfo * cast(Object *obj)
static Handle< Object > SetAccessor(Handle< JSObject > object, Handle< AccessorInfo > info)
Definition: objects.cc:6482
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:208
void(* FatalErrorCallback)(const char *location, const char *message)
Definition: v8.h:3984
static Local< Private > New(Isolate *isolate, Local< String > name=Local< String >())
Definition: api.cc:6189
Local< String > ToString() const
Definition: api.cc:2536
static const int kNoLineNumberInfo
Definition: v8.h:1263
intptr_t CommittedMemoryExecutable()
Definition: heap.cc:230
static v8::ArrayBuffer::Allocator * ArrayBufferAllocator()
Definition: v8.h:106
Type GetType() const
Definition: api.cc:7182
Handle< Object > NewNumber(double value, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:998
#define CHECK(condition)
Definition: checks.h:75
static const int kShortSize
Definition: objects.h:9243
Handle< Context > CreateEnvironment(Handle< Object > global_object, v8::Handle< v8::ObjectTemplate > global_template, v8::ExtensionConfiguration *extensions)
int GetScriptColumnNumber(Handle< Script > script, int code_pos)
Definition: handles.cc:389
Local< Script > BindToCurrentContext()
Definition: api.cc:1627
int GetLineNumber(int code_pos)
Definition: api.cc:1655
void SetSamplingInterval(int us)
Definition: api.cc:7133
void ResetDateCache()
Definition: date.cc:50
static const int kNoScriptIdInfo
Definition: v8.h:1265
Local< Value > CallAsConstructor(int argc, Handle< Value > argv[])
Definition: api.cc:3918
void(* IndexedPropertySetterCallback)(uint32_t index, Local< Value > value, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:3359
void SetVerbose(bool value)
Definition: api.cc:1976
Handle< Object > GetProperty(Handle< JSReceiver > obj, const char *name)
Definition: handles.cc:196
bool CanMakeExternal()
Definition: api.cc:5571
bool IsDirty()
Definition: api.cc:3606
static Local< StackTrace > CurrentStackTrace(Isolate *isolate, int frame_limit, StackTraceOptions options=kOverview)
Definition: api.cc:2196
void Set(Handle< String > name, Handle< Data > value, PropertyAttribute attributes=None)
Definition: api.cc:841
static void MergeLeafLeft(int *length, uint8_t *state, uint8_t leaf_state)
Definition: api.cc:4339
void SetCallHandler(FunctionCallback callback, Handle< Value > data=Handle< Value >())
Definition: api.cc:1148
Factory * factory()
Definition: isolate.h:995
static void NeuterArrayBuffer(Handle< JSArrayBuffer > array_buffer)
Definition: runtime.cc:820
size_t ByteOffset()
Definition: api.cc:6034
Local< DeclaredAccessorDescriptor > NewHandleDereference(Isolate *isolate)
Definition: api.cc:1027
NeanderObject(v8::internal::Isolate *isolate, int size)
Definition: api.cc:756
void(* IndexedPropertyEnumeratorCallback)(const PropertyCallbackInfo< Array > &info)
Definition: v8.h:3388
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in only print modified registers Don t break for ASM_UNIMPLEMENTED_BREAK macros print stack trace when an illegal exception is thrown randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot testing_bool_flag testing_int_flag string flag tmp file in which to serialize heap Print the time it takes to lazily compile hydrogen code stubs concurrent_recompilation concurrent_sweeping Print usage message
PropertyAttributes
void VisitTwoByteString(const uint16_t *chars, int length)
Definition: api.cc:4180
Handle< Value > GetName() const
Definition: api.cc:4031
int * pending_global_handle_count
Definition: heap.h:2577
static bool Dispose()
Definition: api.cc:5028
static void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback)
Definition: api.cc:6325
void SetIndexedPropertiesToExternalArrayData(void *data, ExternalArrayType array_type, int number_of_elements)
Definition: api.cc:3799
virtual const uint16_t * data() const =0
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in name
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object size
Local< Uint32 > ToUint32() const
Definition: api.cc:2884
bool Equals(Handle< Value > that) const
Definition: api.cc:2950
void RemoveGCEpilogueCallback(GCEpilogueCallback callback)
Definition: api.cc:6447
static void VisitExternalResources(ExternalResourceVisitor *visitor)
Definition: api.cc:5047
#define SET_FIELD_WRAPPED(obj, setter, cdata)
Definition: api.cc:1142
REGEXP_FLAG_ASSERT_EQ(kNone, NONE)
bool IsDefaultIsolate() const
Definition: isolate.h:501
static Symbol * cast(Object *obj)
Handle< String > GetFunctionName() const
Definition: api.cc:7011
Local< DeclaredAccessorDescriptor > NewBitmaskCompare32(Isolate *isolate, uint32_t bitmask, uint32_t compare_value)
Definition: api.cc:1096
kSerializedDataOffset kPrototypeTemplateOffset kIndexedPropertyHandlerOffset kInstanceCallHandlerOffset internal_field_count
Definition: objects-inl.h:5034
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in only print modified registers Don t break for ASM_UNIMPLEMENTED_BREAK macros print stack trace when an illegal exception is thrown randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot testing_bool_flag testing_int_flag string flag tmp file in which to serialize heap Print the time it takes to lazily compile hydrogen code stubs concurrent_recompilation concurrent_sweeping Print usage including flags
static bool HasElement(Handle< JSReceiver > object, uint32_t index)
Definition: objects-inl.h:6356
static void GetCompressedStartupData(StartupData *compressed_data)
Definition: api.cc:333
void SetCounterFunction(CounterLookupCallback f)
Definition: counters.h:45
Local< Value > GetConstructor()
Definition: api.cc:3334
Handle< Value > GetScriptResourceName() const
Definition: api.cc:2001
static void AddGCPrologueCallback(GCPrologueCallback callback, GCType gc_type_filter=kGCTypeAll)
Definition: api.cc:6453
static Smi * cast(Object *object)
void(* FailedAccessCheckCallback)(Local< Object > target, AccessType type, Local< Value > data)
Definition: v8.h:4046
Value(Handle< v8::Value > obj)
Definition: api.cc:6702
Handle< String > FlattenGetString(Handle< String > string)
Definition: handles.cc:156
Handle< Object > ForceDeleteProperty(Handle< JSObject > object, Handle< Object > key)
Definition: handles.cc:179
bool IsExternal() const
Definition: api.cc:4769
v8::internal::Handle< v8::internal::JSObject > value()
Definition: api.h:63
bool HasIndexedPropertiesInExternalArrayData()
Definition: api.cc:3822
bool HasPrivate(Handle< Private > key)
Definition: api.cc:3390
Local< DeclaredAccessorDescriptor > NewPointerCompare(Isolate *isolate, void *compare_value)
Definition: api.cc:1043
Handle< Object > HasProperty(Handle< JSReceiver > obj, Handle< Object > key)
Definition: handles.cc:189
v8::Isolate * GetIsolate()
Definition: api.cc:5233
bool Equals(String *other)
Definition: objects-inl.h:2969
static Local< UnboundScript > CompileUnbound(Isolate *isolate, Source *source, CompileOptions options=kNoCompileOptions)
Definition: api.cc:1723
bool SetDeclaredAccessor(Local< String > name, Local< DeclaredAccessorDescriptor > descriptor, PropertyAttribute attribute=None, Local< AccessorSignature > signature=Local< AccessorSignature >(), AccessControl settings=DEFAULT)
Definition: api.cc:1380
void GetHeapStatistics(HeapStatistics *heap_statistics)
Definition: api.cc:6656
void VisitOneByteString(const uint8_t *chars, int length)
Definition: api.cc:4177
void SetNamedPropertyHandler(NamedPropertyGetterCallback getter, NamedPropertySetterCallback setter=0, NamedPropertyQueryCallback query=0, NamedPropertyDeleterCallback deleter=0, NamedPropertyEnumeratorCallback enumerator=0, Handle< Value > data=Handle< Value >())
Definition: api.cc:1416
void SetInternalField(int index, Handle< Value > value)
Definition: api.cc:4911
static Local< StackFrame > StackFrameToLocal(v8::internal::Handle< v8::internal::JSObject > obj)
bool IsOneByte() const
Definition: api.cc:4143
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in only print modified registers Don t break for ASM_UNIMPLEMENTED_BREAK macros print stack trace when an illegal exception is thrown randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot testing_bool_flag testing_int_flag string flag tmp file in which to serialize heap Print the time it takes to lazily compile hydrogen code stubs concurrent_recompilation concurrent_sweeping Print usage including on console Map counters to a file Enable debugger compile events enable GDBJIT enable GDBJIT interface for all code objects dump only objects containing this substring stress the GC compactor to flush out pretty print source code print source AST function name where to insert a breakpoint print scopes for builtins trace contexts operations print stuff during garbage collection report code statistics after GC report handles after GC trace cache state transitions print interface inference details prints when objects are turned into dictionaries report heap spill statistics along with heap_stats(requires heap_stats)") DEFINE_bool(trace_isolates
void SetClassName(Handle< String > name)
Definition: api.cc:1250
void SetAlignedPointerInInternalField(int index, void *value)
Definition: api.cc:4929
StackGuard * stack_guard()
Definition: isolate.h:874
void(* LogEventCallback)(const char *name, int event)
Definition: v8.h:3991
int isnan(double x)
Object * GetInternalField(int index)
Definition: objects-inl.h:1924
int GetEndColumn() const
Definition: api.cc:2111
bool HasTerminated() const
Definition: api.cc:1911
Handle< Context > global_context()
Definition: isolate.cc:1377
void StartCpuProfiling(Handle< String > title, bool record_samples=false)
Definition: api.cc:7146
intptr_t * lo_space_size
Definition: heap.h:2574
static void DebugBreakForCommand(ClientData *data=NULL, Isolate *isolate=NULL)
V8_INLINE Handle< Boolean > True(Isolate *isolate)
Definition: v8.h:6559
Local< StackFrame > GetFrame(uint32_t index) const
Definition: api.cc:2170
GlobalObject * global_object()
Definition: contexts.h:388
static const char * GetVersion()
Definition: api.cc:5120
Local< Value > GetRealNamedProperty(Handle< String > key)
Definition: api.cc:3572
int NotifyContextDisposed()
Definition: heap.cc:872
bool IsExternalAscii() const
Definition: api.cc:4776
static void TerminateExecution(Isolate *isolate=NULL)
Definition: api.cc:6531
void(* AccessorGetterCallback)(Local< String > property, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:2141
bool IsStringObject() const
Definition: api.cc:2462
bool MakeExternal(ExternalStringResource *resource)
Definition: api.cc:5507
Handle< String > NewStringFromUtf8(Vector< const char > str, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:273
void(* IndexedPropertyGetterCallback)(uint32_t index, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:3350
int * near_death_global_handle_count
Definition: heap.h:2578
ScriptOrigin GetScriptOrigin() const
Definition: api.cc:4068
void(* FunctionEntryHook)(uintptr_t function, uintptr_t return_addr_location)
Definition: v8.h:4509
static int GetCompressedStartupDataCount()
Definition: api.cc:324
static void DefineAccessor(Handle< JSObject > object, Handle< Name > name, Handle< Object > getter, Handle< Object > setter, PropertyAttributes attributes, v8::AccessControl access_control=v8::DEFAULT)
Definition: objects.cc:6288
static uchar Length(uchar chr, int previous)
Definition: unicode-inl.h:163
unsigned GetCallUid() const
Definition: api.cc:7066
void RemoveMemoryAllocationCallback(MemoryAllocationCallback callback)
Definition: spaces.cc:837
bool IsUint32() const
Definition: api.cc:2441
static void SetArrayBufferAllocator(ArrayBuffer::Allocator *allocator)
Definition: api.cc:5018
static Local< StackTrace > StackTraceToLocal(v8::internal::Handle< v8::internal::JSArray > obj)
const int MB
Definition: d8.cc:174
bool IdleNotification(int hint)
Definition: heap.cc:5710
static Handle< DeclaredAccessorDescriptor > Create(Isolate *isolate, const DeclaredAccessorDescriptorData &data, Handle< DeclaredAccessorDescriptor > previous)
Definition: objects.cc:15879
int InternalFieldCount()
Definition: api.cc:4887
int GetChildrenCount() const
Definition: api.cc:7255
static void DeoptimizeGlobalObject(JSObject *object)
Definition: deoptimizer.cc:483
static void Abort()
static bool AddMessageListener(MessageCallback that, Handle< Value > data=Handle< Value >())
Definition: api.cc:6259
#define UNREACHABLE()
Definition: checks.h:52
const CpuProfile * StopCpuProfiling(Handle< String > title)
Definition: api.cc:7158
size_t ByteLength()
Definition: api.cc:6040
static i::ConsString * VisitFlat(i::String *string, int *length, uint8_t *state)
Definition: api.cc:4323
void RemoveGCPrologueCallback(GCPrologueCallback callback)
Definition: api.cc:6434
Handle< JSArrayBuffer > GetBuffer()
Definition: objects.cc:16370
bool HasInstance(Handle< Value > object)
Definition: api.cc:5314
static void SetFlagsFromString(const char *str, int length)
Definition: api.cc:406
virtual const char * Data()=0
static bool SetDebugEventListener(v8::Handle< v8::Object > that, Handle< Value > data=Handle< Value >())
Handle< Map > CopyMap(Handle< Map > map, int extra_inobject_props)
Definition: factory.cc:855
static Local< Message > MessageToLocal(v8::internal::Handle< v8::internal::Object > obj)
void SetEmbedderData(int index, Handle< Value > value)
Definition: api.cc:721
int max_old_space_size() const
Definition: v8.h:3952
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths true
void * Value() const
Definition: api.cc:5333
Local< String > ObjectProtoToString()
Definition: api.cc:3280
T * start() const
Definition: utils.h:426
static void RemoveCallCompletedCallback(CallCompletedCallback callback)
Definition: api.cc:6526
void *(* CreateHistogramCallback)(const char *name, int min, int max, size_t buckets)
Definition: v8.h:4011
void(* NamedPropertyQueryCallback)(Local< String > property, const PropertyCallbackInfo< Integer > &info)
Definition: v8.h:3323
intptr_t * property_cell_space_capacity
Definition: heap.h:2587
void set_max_old_space_size(int value)
Definition: v8.h:3953
bool ContainsOnlyOneByte() const
Definition: api.cc:4258
#define GLOBAL
v8::internal::Object * get(int index)
Definition: api.cc:780
Handle< Object > NewReferenceError(const char *message, Vector< Handle< Object > > args)
Definition: factory.cc:1072
void(* NamedPropertySetterCallback)(Local< String > property, Local< Value > value, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:3312
static Local< ObjectTemplate > New()
Definition: api.cc:1286
V8_INLINE Isolate * GetIsolate() const
Definition: v8.h:840
const ProfileTree * top_down() const
bool HasIndexedPropertiesInPixelData()
Definition: api.cc:3766
static void SetJitCodeEventHandler(JitCodeEventOptions options, JitCodeEventHandler event_handler)
Definition: api.cc:5010
void DetachGlobal()
Definition: api.cc:5253
#define ON_BAILOUT(isolate, location, code)
Definition: api.cc:79
static int NumberOfHandles(Isolate *isolate)
Definition: handles.cc:48
Handle< JSObject > NewNeanderObject()
Definition: factory.cc:1030
bool IsSymbol() const
Definition: api.cc:2369
int max_young_space_size() const
Definition: v8.h:3950
Handle< Value > ReThrow()
Definition: api.cc:1916
FunctionEntryHook function_entry_hook()
Definition: isolate.h:1099
bool Contains(Address a)
Definition: spaces-inl.h:179
V8_INLINE Isolate * GetIsolate() const
Definition: v8.h:6512
static void MemCopy(void *dest, const void *src, size_t size)
Definition: platform.h:399
bool V8_EXPORT SetResourceConstraints(Isolate *isolate, ResourceConstraints *constraints)
Definition: api.cc:508
StringTracker * string_tracker()
Definition: isolate.h:924
SnapshotObjectId GetMaxSnapshotJSObjectId() const
Definition: api.cc:7317
virtual int GetChunkSize()
Definition: v8-profiler.h:293
void SetNativeDataProperty(Local< String > name, AccessorGetterCallback getter, AccessorSetterCallback setter=0, Handle< Value > data=Handle< Value >(), PropertyAttribute attribute=None, Local< AccessorSignature > signature=Local< AccessorSignature >(), AccessControl settings=DEFAULT)
Definition: api.cc:1392
Local< Value > GetPrototype()
Definition: api.cc:3192
static int Calculate(i::ConsString *current)
Definition: api.cc:4439
Handle< Object > Create(Object *value)
static bool IsValid(intptr_t value)
Definition: objects-inl.h:1278
static Local< Uint32 > Uint32ToLocal(v8::internal::Handle< v8::internal::Object > obj)
Local< Promise > GetPromise()
Definition: api.cc:5873
void VisitTwoByteString(const uint16_t *chars, int length)
Definition: api.cc:4304
void set_context(Context *context)
Definition: isolate.h:558
static int context_raw_size()
Definition: snapshot.h:63
static void SetHostDispatchHandler(HostDispatchHandler handler, int period=100)
void CollectAllAvailableGarbage(const char *gc_reason=NULL)
Definition: heap.cc:743
bool ForceDelete(Handle< Value > key)
Definition: api.cc:3115
bool(* AllowCodeGenerationFromStringsCallback)(Local< Context > context)
Definition: v8.h:4056
EscapableHandleScope(Isolate *isolate)
Definition: api.cc:629
JSObject * global_proxy()
Definition: contexts.cc:87
static void EnterDefaultIsolate()
Definition: isolate.cc:229
static Handle< Map > GetElementsTransitionMap(Handle< JSObject > object, ElementsKind to_kind)
Definition: objects.cc:3313
int64_t GetEndTime() const
Definition: api.cc:7122
Handle< String > GetTitle() const
Definition: api.cc:7096
int compressed_size
Definition: v8.h:4444
const int kPointerSize
Definition: globals.h:268
struct PointerShiftDescriptor pointer_shift_descriptor
Definition: objects.h:10202
PerIsolateAssertScope< JAVASCRIPT_EXECUTION_THROWS, true > NoThrowOnJavascriptExecution
Definition: assert-scope.h:261
MemoryAllocator * memory_allocator()
Definition: isolate.h:884
int Utf8Length() const
Definition: api.cc:4460
bool LastEnteredContextWas(Handle< Context > context)
Definition: api.h:644
virtual void VisitEmbedderReference(i::Object **p, uint16_t class_id)
Definition: api.cc:5060
MaybeObject * scheduled_exception()
Definition: isolate.h:627
Handle< Object > NewTypeError(const char *message, Vector< Handle< Object > > args)
Definition: factory.cc:1039
static Local< External > New(Isolate *isolate, void *value)
Definition: api.cc:5322
T * NewArray(size_t size)
Definition: allocation.h:83
EternalHandles * eternal_handles()
Definition: isolate.h:920
void FatalProcessOutOfMemory(const char *message)
int * global_handle_count
Definition: heap.h:2575
void SetInternalFieldCount(int value)
Definition: api.cc:1552
bool IsExternal() const
Definition: api.cc:5957
unsigned int FastD2UI(double x)
int GetColumn() const
Definition: api.cc:2223
Handle< Object > ToBoolean(bool value)
Definition: factory.cc:2022
#define LOG_API(isolate, expr)
Definition: api.cc:71
Local< Value > GetPrivate(Handle< Private > key)
Definition: api.cc:3166
Handle< ExecutableAccessorInfo > NewExecutableAccessorInfo()
Definition: factory.cc:690
static Isolate * New()
Definition: api.cc:6586
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf map
Handle< JSArrayBuffer > NewJSArrayBuffer()
Definition: factory.cc:1496
static Handle< JSObject > Copy(Handle< JSObject > object)
Definition: objects.cc:5636
static void SetFatalErrorHandler(FatalErrorCallback that)
Definition: api.cc:393
bool HasIndexedLookupInterceptor()
Definition: api.cc:3526
intptr_t * cell_space_capacity
Definition: heap.h:2573
Object * GetPrototype(Isolate *isolate)
Definition: objects.cc:1032
intptr_t * memory_allocator_size
Definition: heap.h:2580
uintptr_t(* ReturnAddressLocationResolver)(uintptr_t return_addr_location)
Definition: v8.h:4494
void PrintCurrentStackTrace(FILE *out)
Definition: isolate.cc:993
bool IsArrayBufferView() const
Definition: api.cc:2384
static int ContextDisposedNotification()
Definition: api.cc:5108
static void ShutdownPlatform()
Definition: api.cc:4958
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName)
Definition: globals.h:370
Handle< JSArray > CaptureCurrentStackTrace(int frame_limit, StackTrace::StackTraceOptions options)
Definition: isolate.cc:521
Handle< JSTypedArray > NewJSTypedArray(ExternalArrayType type)
Definition: factory.cc:1534
static Local< FunctionTemplate > New(Isolate *isolate, FunctionCallback callback=0, Handle< Value > data=Handle< Value >(), Handle< Signature > signature=Handle< Signature >(), int length=0)
Definition: api.cc:942
GlobalHandles * global_handles()
Definition: isolate.h:918
int32_t Int32Value() const
Definition: api.cc:2929
static void RemoveCallCompletedCallback(CallCompletedCallback callback)
Definition: v8.cc:141
static Local< Script > Compile(Handle< String > source, ScriptOrigin *origin=NULL, ScriptData *script_data=NULL)
Definition: api.cc:1832
bool IsBoolean() const
Definition: api.cc:2421
Local< Object > NewInstance() const
Definition: api.cc:3970
int InternalFieldCount()
Definition: api.cc:1547
static void TransformToFastProperties(Handle< JSObject > object, int unused_property_fields)
Definition: objects.cc:4663
intptr_t * code_space_capacity
Definition: heap.h:2569
PerIsolateAssertScope< JAVASCRIPT_EXECUTION_THROWS, false > ThrowOnJavascriptExecution
Definition: assert-scope.h:257
bool IsSharedCrossOrigin() const
Definition: api.cc:2130
bool Check(i::String *string)
Definition: api.cc:4172
int ScriptId() const
Definition: api.cc:4113
bool IsConstructor() const
Definition: api.cc:2298
static Local< Value > New(Isolate *isolate, Handle< Symbol > value)
Definition: api.cc:5664
Local< Object > Global()
Definition: api.cc:5239
Handle< JSObject > NewExternal(void *value)
Definition: factory.cc:1284
static Handle< Object > GetOrCreateIdentityHash(Handle< JSReceiver > object)
Definition: objects-inl.h:6342
int raw_size
Definition: v8.h:4445
Handle< String > NewStringFromTwoByte(Vector< const uc16 > str, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:282
Handle< ExternalArray > NewExternalArray(int length, ExternalArrayType array_type, void *external_pointer, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:747
static void * ClearWeakness(Object **location)
static FunctionTemplateInfo * cast(Object *obj)
static Handle< Object > CopyGlobal(Object **location)
void SetIndexedPropertiesToPixelData(uint8_t *data, int length)
Definition: api.cc:3745
static Local< ArrayBuffer > New(Isolate *isolate, size_t byte_length)
Definition: api.cc:5994
static void DeoptimizeAll(Isolate *isolate)
Definition: deoptimizer.cc:450
static PropertyAttributes GetPropertyAttribute(Handle< JSReceiver > object, Handle< Name > name)
Definition: objects-inl.h:6311
Handle< FixedArray > NewFixedArray(int size, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:53
void TurnOnAccessCheck()
Definition: api.cc:3588
bool InContext()
Definition: api.cc:6353
static Handle< Object > ToInteger(Isolate *isolate, Handle< Object > obj, bool *exc)
Definition: execution.cc:738
void RemovePrototype()
Definition: api.cc:1271
static JSTypedArray * cast(Object *obj)
VisitorAdapter(PersistentHandleVisitor *visitor)
Definition: api.cc:5055
int length() const
Definition: utils.h:420
OldSpace * old_pointer_space()
Definition: heap.h:638
static void SetStressRunType(StressType type)
Definition: api.cc:7419
int GetScriptColumnNumber() const
Definition: api.cc:4097
bool ConfigureHeap(int max_semispace_size, intptr_t max_old_gen_size, intptr_t max_executable_size)
Definition: heap.cc:6375
intptr_t * map_space_size
Definition: heap.h:2570
Handle< FixedArray > GetKeysInFixedArrayFor(Handle< JSReceiver > object, KeyCollectionType type, bool *threw)
Definition: handles.cc:505
void Enter()
Definition: api.cc:6603
static const uint8_t kInitialState
Definition: api.cc:4277
static bool IsActive()
Definition: v8threads.cc:93
Local< DeclaredAccessorDescriptor > NewBitmaskCompare8(Isolate *isolate, uint8_t bitmask, uint8_t compare_value)
Definition: api.cc:1080
static void RemoveMessageListeners(MessageCallback that)
Definition: api.cc:6275
const char * resource_name() const
GCType
Definition: v8.h:4067
size_t GetProfilerMemorySize()
Definition: api.cc:7403
static const char * GetVersion()
Definition: version.h:49
static Handle< Object > TryGetConstructorDelegate(Isolate *isolate, Handle< Object > object, bool *has_pending_exception)
Definition: execution.cc:322
void(* AddHistogramSampleCallback)(void *histogram, int sample)
Definition: v8.h:4016
static Handle< JSRegExp > NewJSRegExp(Handle< String > pattern, Handle< String > flags, bool *exc)
Definition: execution.cc:765
static Local< Integer > IntegerToLocal(v8::internal::Handle< v8::internal::Object > obj)
bool SetHiddenValue(Handle< String > key, Handle< Value > value)
Definition: api.cc:3661
Local< String > ToDetailString() const
Definition: api.cc:2553
void SetAlignedPointerInEmbedderData(int index, void *value)
Definition: api.cc:740
Handle< DeclaredAccessorInfo > NewDeclaredAccessorInfo()
Definition: factory.cc:681
Local< Symbol > ValueOf() const
Definition: api.cc:5675
static void EnqueueMicrotask(Isolate *isolate, Handle< Object > microtask)
Definition: execution.cc:371
Local< String > GetScriptNameOrSourceURL() const
Definition: api.cc:2262
void SetReference(HeapObject **parent, Object **child)
#define V8_2PART_UINT64_C(a, b)
Definition: globals.h:226
double FastUI2D(unsigned x)
Definition: conversions.h:89
bool HasNamedLookupInterceptor()
Definition: api.cc:3518
Handle< JSBuiltinsObject > js_builtins_object()
Definition: isolate.h:680
bool BooleanValue() const
Definition: api.cc:2824
static Local< Number > New(Isolate *isolate, double value)
Definition: api.cc:6220
static void UnregisterAll()
Definition: api.cc:429
uint32_t * stack_limit() const
Definition: v8.h:3956
struct PointerCompareDescriptor pointer_compare_descriptor
Definition: objects.h:10199
static bool EnableAgent(const char *name, int port, bool wait_for_connection=false)
static Local< String > NewFromTwoByte(Isolate *isolate, const uint16_t *data, NewStringType type=kNormalString, int length=-1)
Definition: api.cc:5443
Handle< Object > ToObject(Handle< Object > object)
Definition: factory.cc:1696
PerIsolateAssertScope< JAVASCRIPT_EXECUTION_ASSERT, false > DisallowJavascriptExecution
Definition: assert-scope.h:249
bool SetPrototype(Handle< Value > prototype)
Definition: api.cc:3203
bool HasBeenSetUp()
Definition: heap.cc:260
#define STATIC_ASCII_VECTOR(x)
Definition: utils.h:570
static Local< Array > New(Isolate *isolate, int length=0)
Definition: api.cc:5786
static ExternalUint8ClampedArray * cast(Object *obj)
int GetLineNumber() const
Definition: api.cc:2061
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in only print modified registers Don t break for ASM_UNIMPLEMENTED_BREAK macros print stack trace when an illegal exception is thrown randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot testing_bool_flag testing_int_flag string flag tmp file in which to serialize heap Print the time it takes to lazily compile hydrogen code stubs concurrent_recompilation concurrent_sweeping Print usage including on console Map counters to a file Enable debugger compile events enable GDBJIT enable GDBJIT interface for all code objects dump only objects containing this substring stress the GC compactor to flush out pretty print source code print source AST function name where to insert a breakpoint print scopes for builtins trace contexts operations print stuff during garbage collection report code statistics after GC report handles after GC trace cache state transitions print interface inference details prints when objects are turned into dictionaries report heap spill statistics along with trace isolate state changes trace regexp bytecode execution Minimal Log all events to the log file Log API events to the log file Log heap samples on garbage collection for the hp2ps tool log positions Log suspect operations Used with turns on browser compatible mode for profiling v8 Specify the name of the log file Enable low level linux profiler Enable perf linux profiler(experimental annotate support).") DEFINE_string(gc_fake_mmap
bool IsFunction() const
Definition: api.cc:2357
static v8::internal::Handle< To > OpenHandle(v8::Local< From > handle)
Definition: api.h:308
V8_INLINE Handle< Primitive > Undefined(Isolate *isolate)
Definition: v8.h:6541
static Local< Value > RangeError(Handle< String > message)
Definition: api.cc:6722
int * free_global_handle_count
Definition: heap.h:2579
static V8_INLINE Local< T > Cast(Local< S > that)
Definition: v8.h:372
void SetHiddenPrototype(bool value)
Definition: api.cc:1257
#define INSTANCE_TYPE_TO_ARRAY_TYPE(Type, type, TYPE, ctype, size)
Handle< FixedArray > CopyFixedArray(Handle< FixedArray > array)
Definition: factory.cc:886
static const int kAbortIncrementalMarkingMask
Definition: heap.h:1260
void IterateAllRootsWithClassIds(ObjectVisitor *v)
void(* IndexedPropertyQueryCallback)(uint32_t index, const PropertyCallbackInfo< Integer > &info)
Definition: v8.h:3369
bool CollectGarbage(AllocationSpace space, const char *gc_reason=NULL, const GCCallbackFlags gc_callback_flags=kNoGCCallbackFlags)
Definition: heap-inl.h:554
MUST_USE_RESULT MaybeObject * GetProperty(Name *key)
Definition: objects-inl.h:1081
static ScriptDataImpl * PreParse(Isolate *isolate, Utf16CharacterStream *source)
Definition: parser.cc:4624
virtual void VisitPointers(i::Object **start, i::Object **end)
Definition: api.cc:5057
int StrLength(const char *string)
Definition: utils.h:253
static Local< Context > ToLocal(v8::internal::Handle< v8::internal::Context > obj)
intptr_t CommittedMemory()
Definition: heap.cc:202
static Local< Object > New(Isolate *isolate)
Definition: api.cc:5589
intptr_t SizeOfObjects()
Definition: heap.cc:473
const char * name() const
#define T(name, string, precedence)
Definition: token.cc:48
void SetRetainedObjectInfo(UniqueId id, RetainedObjectInfo *info)
Definition: api.cc:7409
static void AddCallCompletedCallback(CallCompletedCallback callback)
Definition: api.cc:6501
Local< Promise > Catch(Handle< Function > handler)
Definition: api.cc:5937
int GetScriptId() const
Definition: api.cc:7029
RegisteredExtension(Extension *extension)
Definition: api.cc:419
bool IsArrayBuffer() const
Definition: api.cc:2379
const int GB
Definition: globals.h:247
Local< String > GetScriptName() const
Definition: api.cc:2249
static bool SetFunctionEntryHook(Isolate *isolate, FunctionEntryHook entry_hook)
Definition: api.cc:4987
int64_t IntegerValue() const
Definition: api.cc:2846
SnapshotObjectId GetHeapStats(OutputStream *stream)
Definition: api.cc:7386
void(* NamedPropertyEnumeratorCallback)(const PropertyCallbackInfo< Array > &info)
Definition: v8.h:3342
int GetSamplesCount() const
Definition: api.cc:7128
Context * context()
Definition: isolate.h:557
static bool HasProperty(Handle< JSReceiver > object, Handle< Name > name)
Definition: objects-inl.h:6291
bool CanContinue() const
Definition: api.cc:1906
AllowJavascriptExecutionScope(Isolate *isolate)
Definition: api.cc:6640
static Local< Value > New(Isolate *isolate, double value)
Definition: api.cc:5600
bool IsObject() const
Definition: api.cc:2411
void(* GCEpilogueCallback)(GCType type, GCCallbackFlags flags)
Definition: v8.h:4081
void SetName(Handle< String > name)
Definition: api.cc:4022
#define EXCEPTION_PREAMBLE(isolate)
Definition: api.cc:86
static Local< Value > New(Isolate *isolate, double time)
Definition: api.cc:5685
Handle< Object > NewNumberFromInt(int32_t value, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:1006
const HeapSnapshot * TakeHeapSnapshot(Handle< String > title, ActivityControl *control=NULL, ObjectNameResolver *global_object_name_resolver=NULL)
Definition: api.cc:7365
double Value() const
Definition: api.cc:4845
bool IsCodeGenerationFromStringsAllowed()
Definition: api.cc:5270
static Local< Context > New(Isolate *isolate, ExtensionConfiguration *extensions=NULL, Handle< ObjectTemplate > global_template=Handle< ObjectTemplate >(), Handle< Value > global_object=Handle< Value >())
Definition: api.cc:5188
static Local< Value > ReferenceError(Handle< String > message)
Definition: api.cc:6739
void SetReferenceFromGroup(UniqueId id, const Persistent< T > &child)
Definition: v8.h:6604
void StartProfiling(Handle< String > title, bool record_samples=false)
Definition: api.cc:7140
void(* JitCodeEventHandler)(const JitCodeEvent *event)
Definition: v8.h:4595
static JSDataView * cast(Object *obj)
Local< Value > StackTrace() const
Definition: api.cc:1935
bool IsFreshUnusedString(Handle< String > string)
Definition: api.h:431
static void SetMessageHandler2(MessageHandler2 handler)
size_t Length()
Definition: api.cc:6046
int GetScriptLineNumber(Handle< Script > script, int code_pos)
Definition: handles.cc:363
int CompleteWrite(bool write_null, int *utf16_chars_read_out)
Definition: api.cc:4625
static Local< DataView > New(Handle< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
Definition: api.cc:6127
intptr_t * old_data_space_capacity
Definition: heap.h:2567
Handle< Object > NewSyntaxError(const char *message, Handle< JSArray > args)
Definition: factory.cc:1061
HeapProfiler * heap_profiler() const
Definition: isolate.h:985
static Handle< JSFunction > InstantiateFunction(Handle< FunctionTemplateInfo > data, bool *exc)
Definition: execution.cc:807
static Local< RegExp > New(Handle< String > pattern, Flags flags)
Definition: api.cc:5748
int GetEndPosition() const
Definition: api.cc:2086
const CpuProfileNode * GetTopDownRoot() const
Definition: api.cc:7104
Local< Context > GetCallingContext()
Definition: api.cc:6369
bool IsDate() const
Definition: api.cc:2455
Handle< String > InternalizeTwoByteString(Vector< const uc16 > str)
Definition: factory.cc:245
NewStringType
Definition: v8.h:1863
void add(v8::internal::Handle< v8::internal::Object > value)
Definition: api.cc:792
static void SetAutorunMicrotasks(Isolate *source, bool autorun)
Definition: api.cc:6521
int max_executable_size() const
Definition: v8.h:3954
void RemoveGCEpilogueCallback(v8::Isolate::GCEpilogueCallback callback)
Definition: heap.cc:6844
static void WriteToFlat(String *source, sinkchar *sink, int from, int to)
Definition: objects.cc:8635
void VisitTwoByteString(const uint16_t *chars, int length)
Definition: api.cc:4621
int GetIndexedPropertiesExternalArrayDataLength()
Definition: api.cc:3861
Local< RawOperationDescriptor > NewRawDereference(Isolate *isolate)
Definition: api.cc:1035
Handle< String > NewExternalStringFromTwoByte(const ExternalTwoByteString::Resource *resource)
Definition: factory.cc:563
uint32_t Uint32Value() const
Definition: api.cc:3023
Local< Promise > Chain(Handle< Function > handler)
Definition: api.cc:5917
Handle< String > InternalizeOneByteString(Vector< const uint8_t > str)
Definition: factory.cc:232
static double nan_value()
void set_max_available_threads(int value)
Definition: v8.h:3961
enable upcoming ES6 features enable harmony block scoping enable harmony symbols(a.k.a.private names)") DEFINE_bool(harmony_proxies
static void SetDebugMessageDispatchHandler(DebugMessageDispatchHandler handler, bool provide_locker=false)
int * weak_global_handle_count
Definition: heap.h:2576
void SetReference(const Persistent< T > &parent, const Persistent< S > &child)
Definition: v8.h:6613
static Handle< Object > Call(Isolate *isolate, Handle< Object > callable, Handle< Object > receiver, int argc, Handle< Object > argv[], bool *pending_exception, bool convert_receiver=false)
Definition: execution.cc:153
const HeapSnapshot * GetHeapSnapshot(int index)
Definition: api.cc:7340
void Continue(InterruptFlag after_what)
Definition: execution.cc:561
void Exit()
Definition: api.cc:661
static Handle< Object > SetProperty(Handle< JSReceiver > object, Handle< Name > key, Handle< Object > value, PropertyAttributes attributes, StrictMode strict_mode, StoreFromKeyed store_mode=MAY_BE_STORE_FROM_KEYED)
Definition: objects.cc:2858
static void SetEntropySource(EntropySource source)
Definition: api.cc:4976
bool is_null() const
Definition: handles.h:81
Handle< T > handle(T *t, Isolate *isolate)
Definition: handles.h:103
void Neuter()
Definition: api.cc:5976
static Handle< Object > ToInt32(Isolate *isolate, Handle< Object > obj, bool *exc)
Definition: execution.cc:750
V8_INLINE bool IsEmpty() const
Definition: v8.h:248
bool IsNumber() const
Definition: api.cc:2416
bool IsDataView() const
Definition: api.cc:2406
static void CancelDebugBreak(Isolate *isolate=NULL)
CpuProfiler * cpu_profiler() const
Definition: isolate.h:984
void DetachGlobal(Handle< Context > env)
Handle< Object > Get(int index)
void SetCallAsFunctionHandler(FunctionCallback callback, Handle< Value > data=Handle< Value >())
Definition: api.cc:1525
Handle< String > GetTitle() const
Definition: api.cc:7288
uint32_t SnapshotObjectId
Definition: v8-profiler.h:39
ExternalStringTable * external_string_table()
Definition: heap.h:1799
size_t CommittedPhysicalMemory()
Definition: heap.cc:216
Local< Function > GetFunction()
Definition: api.cc:5299
bool ForceSet(Handle< Value > key, Handle< Value > value, PropertyAttribute attribs=None)
Definition: api.cc:3087
Handle< Symbol > NewSymbol()
Definition: factory.cc:572
Utf8WriterVisitor(char *buffer, int capacity, bool skip_capacity_check, bool replace_invalid_utf8)
Definition: api.cc:4469
static void set_raw_data(const byte *raw_data)
Definition: snapshot.h:58
int GetNodesCount() const
Definition: api.cc:7306
int GetScriptId() const
Definition: api.cc:2236
static Local< Value > SyntaxError(Handle< String > message)
Definition: api.cc:6757
Local< ArrayBuffer > Buffer()
Definition: api.cc:6019
static ConsString * VisitFlat(Visitor *visitor, String *string, int offset, int length, int32_t type)
Definition: objects-inl.h:3124
static void AddCallCompletedCallback(CallCompletedCallback callback)
Definition: v8.cc:130
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function info
void(* NamedPropertyGetterCallback)(Local< String > property, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:3303
static Local< String > NewExternal(Isolate *isolate, ExternalStringResource *resource)
Definition: api.cc:5493
int GetChildrenCount() const
Definition: api.cc:7076
Local< Object > Clone()
Definition: api.cc:3611
static void MakeWeak(Object **location, void *parameter, WeakCallback weak_callback)
Handle< String > InternalizeUtf8String(Vector< const char > str)
Definition: factory.cc:218
virtual const char * data() const =0
virtual int Length()=0
static void DisableAgent()
#define EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, value)
Definition: api.cc:107
void CopyBytes(uint8_t *target, uint8_t *source)
Definition: runtime.cc:1309
Local< Value > GetBoundFunction() const
Definition: api.cc:4123
static int context_size()
Definition: snapshot.h:62
Handle< Object > GetScriptNameOrSourceURL(Handle< Script > script)
Definition: handles.cc:474
static const unsigned kBytesSavedByCombiningSurrogates
Definition: unicode.h:171
void InvokeAccessorGetterCallback(v8::Local< v8::String > property, const v8::PropertyCallbackInfo< v8::Value > &info, v8::AccessorGetterCallback getter)
Definition: api.cc:7628
const HeapGraphNode * GetRoot() const
Definition: api.cc:7295
static bool SetDebugEventListener2(EventCallback2 that, Handle< Value > data=Handle< Value >())
static void PrintError(const char *format,...)
static void SetupArrayBuffer(Isolate *isolate, Handle< JSArrayBuffer > array_buffer, bool is_external, void *data, size_t allocated_length)
Definition: runtime.cc:768
void ClearInterrupt()
Definition: api.cc:6560
#define TYPED_ARRAYS(V)
Definition: objects.h:4663
int GetColumnNumber() const
Definition: api.cc:7049
Local< Value > Name() const
Definition: api.cc:4840
const uint8_t * data
Definition: v8.h:1117
int GetIndexedPropertiesPixelDataLength()
Definition: api.cc:3787
bool(* NamedSecurityCallback)(Local< Object > host, Local< Value > key, AccessType type, Local< Value > data)
Definition: v8.h:3408
static int Calculate(i::ConsString *current, uint8_t *state_out)
Definition: api.cc:4388
static void RemoveMemoryAllocationCallback(MemoryAllocationCallback callback)
Definition: api.cc:6494
Local< ObjectTemplate > PrototypeTemplate()
Definition: api.cc:888
Handle< Foreign > NewForeign(Address addr, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:726
bool IsFalse() const
Definition: api.cc:2352
static void VisitHandlesWithClassIds(PersistentHandleVisitor *visitor)
Definition: api.cc:5070
const int kHandleBlockSize
Definition: api.h:616
static bool InitializeICU(const char *icu_data_file=NULL)
Definition: api.cc:5115
void SetObjectGroupId(Object **handle, UniqueId id)
Flags GetFlags() const
Definition: api.cc:5780
void set(int index, v8::internal::Object *value)
Definition: api.h:112
#define ASSERT_EQ(v1, v2)
Definition: checks.h:330
void MarkAsUndetectable()
Definition: api.cc:1449
static void SetReturnAddressLocationResolver(ReturnAddressLocationResolver resolver)
Definition: v8.cc:124
void(* InterruptCallback)(Isolate *isolate, void *data)
Definition: v8.h:4083
static Local< Value > TypeError(Handle< String > message)
Definition: api.cc:6774
#define TYPED_ARRAY_NEW(Type, type, TYPE, ctype, size)
Definition: api.cc:6107
static void TearDown()
Definition: v8.cc:93
bool(* EntropySource)(unsigned char *buffer, size_t length)
Definition: v8.h:4478
double ValueOf() const
Definition: api.cc:5611
unsigned GetHitCount() const
Definition: api.cc:7061
Handle< Object > GetSingleton(SingletonHandle singleton)
static Handle< Object > ToUint32(Isolate *isolate, Handle< Object > obj, bool *exc)
Definition: execution.cc:744
static void Register(RegisteredExtension *that)
Definition: api.cc:423
void USE(T)
Definition: globals.h:341
Counters * counters()
Definition: isolate.h:859
int GetScriptLineNumber() const
Definition: api.cc:4087
static Local< Resolver > New(Isolate *isolate)
Definition: api.cc:5855
static Handle< JSObject > InstantiateObject(Handle< ObjectTemplateInfo > data, bool *exc)
Definition: execution.cc:832
virtual void VisitPersistentHandle(Persistent< Value > *value, uint16_t class_id)
Definition: v8.h:4614
static void RemoveGCEpilogueCallback(GCEpilogueCallback callback)
Definition: api.cc:6478
static void PrepareStressRun(int run)
Definition: api.cc:7441
Handle< StackTrace > GetStackTrace() const
Definition: api.cc:2017
int64_t Value() const
Definition: api.cc:4857
bool IsTemplateFor(Object *object)
Definition: objects.cc:219
static void VisitHandlesForPartialDependence(Isolate *isolate, PersistentHandleVisitor *visitor)
Definition: api.cc:5079
DeclaredAccessorDescriptorDataType
Definition: v8.h:3805
static void SetCreateHistogramFunction(CreateHistogramCallback)
Definition: api.cc:6311
bool IsNumberObject() const
Definition: api.cc:2478
int GetSnapshotCount()
Definition: api.cc:7335
static FixedArray * cast(Object *obj)
void InitializeLoggingAndCounters()
Definition: isolate.cc:1851
static Local< Value > Call(v8::Handle< v8::Function > fun, Handle< Value > data=Handle< Value >())
void Delete()
Definition: api.cc:7088
static void RemoveGCPrologueCallback(GCPrologueCallback callback)
Definition: api.cc:6462
static bool EndsWithSurrogate(uint8_t state)
Definition: api.cc:4279
static bool SetupArrayBufferAllocatingData(Isolate *isolate, Handle< JSArrayBuffer > array_buffer, size_t allocated_length, bool initialize=true)
Definition: runtime.cc:793
Local< UnboundScript > GetUnboundScript()
Definition: api.cc:1716
Failure * TerminateExecution()
Definition: isolate.cc:900
void IterateAllRootsInNewSpaceWithClassIds(ObjectVisitor *v)
Local< Value > GetRealNamedPropertyInPrototypeChain(Handle< String > key)
Definition: api.cc:3557
#define VALUE_IS_TYPED_ARRAY(Type, typeName, TYPE, ctype, size)
Definition: api.cc:2394
void SetCreateHistogramFunction(CreateHistogramCallback f)
Definition: counters.h:51
static const int kBoundFunctionIndex
Definition: objects.h:7534
intptr_t * old_pointer_space_capacity
Definition: heap.h:2565
ObjectSpace
Definition: v8.h:4019
static Handle< Object > SetObjectProperty(Isolate *isolate, Handle< Object > object, Handle< Object > key, Handle< Object > value, PropertyAttributes attr, StrictMode strict_mode)
Definition: runtime.cc:5283
Local< Value > Run()
Definition: api.cc:1686
bool Has(Handle< Value > key)
Definition: api.cc:3376
static Local< String > Concat(Handle< String > left, Handle< String > right)
Definition: api.cc:5456
Logger * logger()
Definition: isolate.h:868
static Handle< Object > DeleteElement(Handle< JSReceiver > object, uint32_t index, DeleteMode mode=NORMAL_DELETION)
Definition: objects.cc:5262
bool HasOwnProperty(Handle< String > key)
Definition: api.cc:3481
const uint32_t kMaxUInt32
Definition: globals.h:259
static bool ApiCheck(bool condition, const char *location, const char *message)
Definition: api.h:199
Object * get(int index)
Definition: objects-inl.h:2127
static Local< Script > Compile(Isolate *isolate, Source *source, CompileOptions options=kNoCompileOptions)
Definition: api.cc:1816
void StartTrackingHeapObjects(bool track_allocations=false)
Definition: api.cc:7375
void AddGCEpilogueCallback(GCEpilogueCallback callback, GCType gc_type_filter=kGCTypeAll)
Definition: api.cc:6440
void RecordStats(HeapStats *stats, bool take_snapshot=false)
Definition: heap.cc:6463
static Handle< Object > GetElement(Isolate *isolate, Handle< Object > object, uint32_t index)
Definition: objects-inl.h:1060
static void InitializePlatform(v8::Platform *platform)
Definition: v8.cc:220
void RegisterTryCatchHandler(v8::TryCatch *that)
Definition: isolate.cc:339
bool IsInGCPostProcessing()
Definition: heap.h:1510
static Local< Value > Parse(Local< String > json_string)
Definition: api.cc:2310
Type GetType() const
Definition: api.cc:7226
static Local< TypeSwitch > New(Handle< FunctionTemplate > type)
Definition: api.cc:1104
Local< Object > ToObject() const
Definition: api.cc:2570
bool IsArray() const
Definition: api.cc:2374
int64_t AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes)
Definition: api.cc:6332
Handle< Struct > NewStruct(InstanceType type)
Definition: factory.cc:658
HeapObject * obj
static void RunMicrotasks(Isolate *isolate)
Definition: api.cc:6507
bool has_scheduled_exception()
Definition: isolate.h:631
static void RunMicrotasks(Isolate *isolate)
Definition: v8.cc:172
struct PrimitiveValueDescriptor primitive_value_descriptor
Definition: objects.h:10200
void SetAccessorProperty(Local< String > name, Local< FunctionTemplate > getter=Local< FunctionTemplate >(), Local< FunctionTemplate > setter=Local< FunctionTemplate >(), PropertyAttribute attribute=None, AccessControl settings=DEFAULT)
Definition: api.cc:857
static bool IsLeadSurrogate(int code)
Definition: unicode.h:108
static void LowMemoryNotification()
Definition: api.cc:5101
uint32_t Length() const
Definition: api.cc:5800
void EnterContext(Handle< Context > context)
Definition: api.h:634
Handle< Object > ForceSetProperty(Handle< JSObject > object, Handle< Object > key, Handle< Object > value, PropertyAttributes attributes)
Definition: handles.cc:161
Local< Value > Name() const
Definition: api.cc:4833
static bool StartsWithSurrogate(uint8_t state)
Definition: api.cc:4283
static Local< AccessorSignature > New(Isolate *isolate, Handle< FunctionTemplate > receiver=Handle< FunctionTemplate >())
Definition: api.cc:981
static JSArrayBuffer * cast(Object *obj)
static ScriptData * New(const char *data, int length)
Definition: api.cc:1587
Local< Boolean > ToBoolean() const
Definition: api.cc:2587
void Reject(Handle< Value > value)
Definition: api.cc:5898
Handle< String > NewConsString(Handle< String > left, Handle< String > right)
Definition: factory.cc:370
static Local< Symbol > New(Isolate *isolate, Local< String > name=Local< String >())
Definition: api.cc:6142
Local< Integer > ToInteger() const
Definition: api.cc:2619
static void SendCommand(const uint16_t *command, int length, ClientData *client_data=NULL, Isolate *isolate=NULL)
intptr_t * map_space_capacity
Definition: heap.h:2571
Local< DeclaredAccessorDescriptor > NewBitmaskCompare16(Isolate *isolate, uint16_t bitmask, uint16_t compare_value)
Definition: api.cc:1088
void SetIndexedPropertyHandler(IndexedPropertyGetterCallback getter, IndexedPropertySetterCallback setter=0, IndexedPropertyQueryCallback query=0, IndexedPropertyDeleterCallback deleter=0, IndexedPropertyEnumeratorCallback enumerator=0, Handle< Value > data=Handle< Value >())
Definition: api.cc:1492
size_t ByteLength() const
Definition: api.cc:5988
static bool IsTrailSurrogate(int code)
Definition: unicode.h:112
static void SetFlagsFromCommandLine(int *argc, char **argv, bool remove_flags)
Definition: api.cc:411
static void DebugBreak(Isolate *isolate=NULL)
static V8_EXPORT void CheckInitializedImpl(v8::Isolate *isolate)
Handle< Object > NewNumberFromSize(size_t value, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.h:623
Handle< Object > NewError(const char *maker, const char *message, Handle< JSArray > args)
Definition: factory.cc:1153
void Delete()
Definition: api.cc:7272
void ConfigureDefaults(uint64_t physical_memory, uint32_t number_of_processors)
Definition: api.cc:469
Local< Value > CallAsFunction(Handle< Value > recv, int argc, Handle< Value > argv[])
Definition: api.cc:3884
void SetIdle(bool is_idle)
Definition: api.cc:7163
bool IsInt32() const
Definition: api.cc:2431
int max_available_threads() const
Definition: v8.h:3959
bool HasRealNamedProperty(Handle< String > key)
Definition: api.cc:3490
#define STATIC_ASSERT(test)
Definition: checks.h:341
const CpuProfileNode * GetSample(int index) const
Definition: api.cc:7110
static ScriptData * PreCompile(Handle< String > source)
Definition: api.cc:1573
bool Delete(Handle< Value > key)
Definition: api.cc:3356
kSerializedDataOffset prototype_template
Definition: objects-inl.h:5016
unsigned GetUid() const
Definition: api.cc:7283
static Local< Value > GetMirror(v8::Handle< v8::Value > obj)
void DeleteArray(T *array)
Definition: allocation.h:91
static const int kNoScriptId
Definition: v8.h:1031
signed short int16_t
Definition: unicode.cc:45
intptr_t * memory_allocator_capacity
Definition: heap.h:2581
int GetStartColumn() const
Definition: api.cc:2096
Handle< Value > GetInferredName() const
Definition: api.cc:4038
static void InitializePlatform(Platform *platform)
Definition: api.cc:4949
bool Exists(SingletonHandle singleton)
#define FUNCTION_ADDR(f)
Definition: globals.h:345
Local< Object > FindInstanceInPrototypeChain(Handle< FunctionTemplate > tmpl)
Definition: api.cc:3220
static bool Initialize(const char *snapshot_file=NULL)
void SetStackLimit(uintptr_t limit)
Definition: execution.cc:400
bool SetAccessor(Handle< String > name, AccessorGetterCallback getter, AccessorSetterCallback setter=0, Handle< Value > data=Handle< Value >(), AccessControl settings=DEFAULT, PropertyAttribute attribute=None)
Definition: api.cc:3439
CompressedStartupDataItems
Definition: api.cc:315
static void DateTimeConfigurationChangeNotification(Isolate *isolate)
Definition: api.cc:5711
void InvokeFunctionCallback(const v8::FunctionCallbackInfo< v8::Value > &info, v8::FunctionCallback callback)
Definition: api.cc:7642
static FixedArrayBase * cast(Object *object)
Definition: objects-inl.h:2121
void Resolve(Handle< Value > value)
Definition: api.cc:5879
bool has_name_prefix() const
static Local< Function > New(Isolate *isolate, FunctionCallback callback, Local< Value > data=Local< Value >(), int length=0)
Definition: api.cc:3957
static const int kMaxValue
Definition: objects.h:1681
static StartupData::CompressionAlgorithm GetCompressedStartupDataAlgorithm()
Definition: api.cc:306
intptr_t * old_data_space_size
Definition: heap.h:2566
virtual ~StartupDataDecompressor()
Definition: api.cc:273
void Reset()
Definition: api.cc:1965
#define CHECK_TYPED_ARRAY_CAST(Type, typeName, TYPE, ctype, size)
Definition: api.cc:2747
void ReadOnlyPrototype()
Definition: api.cc:1264
void RequestGarbageCollectionForTesting(GarbageCollectionType type)
Definition: api.cc:6565
HeapProfiler * GetHeapProfiler()
Definition: api.cc:6339
static void DeoptimizeAll()
Definition: api.cc:7477
const HeapGraphNode * GetToNode() const
Definition: api.cc:7214
Handle< Value > GetSecurityToken()
Definition: api.cc:5224
static void FatalProcessOutOfMemory(const char *location, bool take_snapshot=false)
int32_t Value() const
Definition: api.cc:4867
static Handle< Object > ToString(Isolate *isolate, Handle< Object > obj, bool *exc)
Definition: execution.cc:719
static Local< External > ExternalToLocal(v8::internal::Handle< v8::internal::JSObject > obj)
#define ARRAY_SIZE(a)
Definition: globals.h:333
static void ProcessDebugMessages()
static int raw_size()
Definition: snapshot.h:57
void SetErrorMessageForCodeGenerationFromStrings(Handle< String > message)
Definition: api.cc:5276
const int kCharSize
Definition: globals.h:261
static Local< Value > New(Handle< String > value)
Definition: api.cc:5643
Local< String > ValueOf() const
Definition: api.cc:5654
static const byte * context_data()
Definition: snapshot.h:61
static V8_INLINE v8::Local< v8::String > Empty(Isolate *isolate)
Definition: v8.h:6182
void(* NamedPropertyDeleterCallback)(Local< String > property, const PropertyCallbackInfo< Boolean > &info)
Definition: v8.h:3333
int match(Handle< Value > value)
Definition: api.cc:1127
void Serialize(OutputStream *stream, SerializationFormat format) const
Definition: api.cc:7322
Local< v8::Message > Message() const
Definition: api.cc:1953
int Write(uint16_t *buffer, int start=0, int length=-1, int options=NO_OPTIONS) const
Definition: api.cc:4761
Local< RawOperationDescriptor > NewRawShift(Isolate *isolate, int16_t byte_offset)
Definition: api.cc:1017
AccessControl
Definition: v8.h:2165
void Inherit(Handle< FunctionTemplate > parent)
Definition: api.cc:902
PropertyAttribute
Definition: v8.h:2106
CpuProfile * StopProfiling(Handle< String > title)
Definition: api.cc:7151
static JSObject * cast(Object *obj)
static bool Initialize()
Definition: api.cc:4967
void AddGCPrologueCallback(v8::Isolate::GCPrologueCallback callback, GCType gc_type_filter, bool pass_isolate=true)
Definition: heap.cc:6812
static void SetRawScriptsSource(Vector< const char > raw_source)
Handle< JSArray > NewJSArray(ElementsKind elements_kind, int length, int capacity, ArrayStorageAllocationMode mode=INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:1437
Local< String > GetFunctionName() const
Definition: api.cc:2275
Local< String > GetSourceLine() const
Definition: api.cc:2143
static const int kNoPreviousCharacter
Definition: unicode.h:120
static void SetCounterFunction(CounterLookupCallback)
Definition: api.cc:6305
v8::internal::Object * get(int index)
Definition: api.h:106
Local< Uint32 > ToArrayIndex() const
Definition: api.cc:2901
Handle< T > CloseAndEscape(Handle< T > handle_value)
Definition: handles-inl.h:146
void AddMemoryAllocationCallback(MemoryAllocationCallback callback, ObjectSpace space, AllocationAction action)
Definition: spaces.cc:826
int size()
Definition: api.cc:765
struct BitmaskCompareDescriptor bitmask_compare_descriptor
Definition: objects.h:10198
int GetLineNumber() const
Definition: api.cc:7044
int WriteOneByte(uint8_t *buffer, int start=0, int length=-1, int options=NO_OPTIONS) const
Definition: api.cc:4753
uint32_t Value() const
Definition: api.cc:4877
int GetIdentityHash()
Definition: api.cc:3650
void set_max_executable_size(int value)
Definition: v8.h:3955
const char * name_prefix() const
JitCodeEventOptions
Definition: v8.h:4583
void SetAccessCheckCallbacks(NamedSecurityCallback named_handler, IndexedSecurityCallback indexed_handler, Handle< Value > data=Handle< Value >(), bool turned_on_by_default=true)
Definition: api.cc:1461
bool Value() const
Definition: api.cc:4851
static Local< Integer > NewFromUnsigned(Isolate *isolate, uint32_t value)
Definition: api.cc:6246
bool Set(Handle< Value > key, Handle< Value > value, PropertyAttribute attribs=None)
Definition: api.cc:3044
void SetCodeEventHandler(uint32_t options, JitCodeEventHandler event_handler)
Definition: log.cc:2098
intptr_t * property_cell_space_size
Definition: heap.h:2586
int GetFrameCount() const
Definition: api.cc:2182
Handle< Value > GetScriptName()
Definition: api.cc:1670
static Local< String > NewFromUtf8(Isolate *isolate, const char *data, NewStringType type=kNormalString, int length=-1)
Definition: api.cc:5417
static bool IdleNotification(int hint=1000)
Definition: api.cc:5091
static bool HasLocalProperty(Handle< JSReceiver >, Handle< Name > name)
Definition: objects-inl.h:6301
static v8::Testing::StressType stress_type()
Definition: api.h:707
static Local< Symbol > For(Isolate *isolate, Local< String > name)
Definition: api.cc:6153
static JSFunction * cast(Object *obj)