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
test-accessors.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 <stdlib.h>
29 
30 #include "v8.h"
31 
32 #include "api.h"
33 #include "cctest.h"
34 #include "frames-inl.h"
35 #include "string-stream.h"
36 
37 using ::v8::ObjectTemplate;
38 using ::v8::Value;
39 using ::v8::Context;
40 using ::v8::Local;
41 using ::v8::String;
42 using ::v8::Script;
43 using ::v8::Function;
44 using ::v8::Extension;
45 
46 static void handle_property(Local<String> name,
49  info.GetReturnValue().Set(v8_num(900));
50 }
51 
52 static void handle_property_2(Local<String> name,
55  info.GetReturnValue().Set(v8_num(902));
56 }
57 
58 
59 static void handle_property(const v8::FunctionCallbackInfo<v8::Value>& info) {
61  CHECK_EQ(0, info.Length());
62  info.GetReturnValue().Set(v8_num(907));
63 }
64 
65 
66 THREADED_TEST(PropertyHandler) {
67  LocalContext env;
68  v8::Isolate* isolate = env->GetIsolate();
69  v8::HandleScope scope(isolate);
70  Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(isolate);
71  fun_templ->InstanceTemplate()->SetAccessor(v8_str("foo"), handle_property);
72  Local<v8::FunctionTemplate> getter_templ =
73  v8::FunctionTemplate::New(isolate, handle_property);
74  getter_templ->SetLength(0);
75  fun_templ->
76  InstanceTemplate()->SetAccessorProperty(v8_str("bar"), getter_templ);
77  fun_templ->InstanceTemplate()->
78  SetNativeDataProperty(v8_str("instance_foo"), handle_property);
79  fun_templ->SetNativeDataProperty(v8_str("object_foo"), handle_property_2);
80  Local<Function> fun = fun_templ->GetFunction();
81  env->Global()->Set(v8_str("Fun"), fun);
82  Local<Script> getter;
83  Local<Script> setter;
84  // check function instance accessors
85  getter = v8_compile("var obj = new Fun(); obj.instance_foo;");
86  CHECK_EQ(900, getter->Run()->Int32Value());
87  setter = v8_compile("obj.instance_foo = 901;");
88  CHECK_EQ(901, setter->Run()->Int32Value());
89  getter = v8_compile("obj.bar;");
90  CHECK_EQ(907, getter->Run()->Int32Value());
91  setter = v8_compile("obj.bar = 908;");
92  CHECK_EQ(908, setter->Run()->Int32Value());
93  // check function static accessors
94  getter = v8_compile("Fun.object_foo;");
95  CHECK_EQ(902, getter->Run()->Int32Value());
96  setter = v8_compile("Fun.object_foo = 903;");
97  CHECK_EQ(903, setter->Run()->Int32Value());
98 }
99 
100 
101 static void GetIntValue(Local<String> property,
104  int* value =
105  static_cast<int*>(v8::Handle<v8::External>::Cast(info.Data())->Value());
106  info.GetReturnValue().Set(v8_num(*value));
107 }
108 
109 
110 static void SetIntValue(Local<String> property,
111  Local<Value> value,
112  const v8::PropertyCallbackInfo<void>& info) {
113  int* field =
114  static_cast<int*>(v8::Handle<v8::External>::Cast(info.Data())->Value());
115  *field = value->Int32Value();
116 }
117 
118 int foo, bar, baz;
119 
120 THREADED_TEST(GlobalVariableAccess) {
121  foo = 0;
122  bar = -4;
123  baz = 10;
124  v8::Isolate* isolate = CcTest::isolate();
125  v8::HandleScope scope(isolate);
127  templ->InstanceTemplate()->SetAccessor(
128  v8_str("foo"), GetIntValue, SetIntValue,
129  v8::External::New(isolate, &foo));
130  templ->InstanceTemplate()->SetAccessor(
131  v8_str("bar"), GetIntValue, SetIntValue,
132  v8::External::New(isolate, &bar));
133  templ->InstanceTemplate()->SetAccessor(
134  v8_str("baz"), GetIntValue, SetIntValue,
135  v8::External::New(isolate, &baz));
136  LocalContext env(0, templ->InstanceTemplate());
137  v8_compile("foo = (++bar) + baz")->Run();
138  CHECK_EQ(bar, -3);
139  CHECK_EQ(foo, 7);
140 }
141 
142 
143 static int x_register[2] = {0, 0};
144 static v8::Handle<v8::Object> x_receiver;
145 static v8::Handle<v8::Object> x_holder;
146 
147 template<class Info>
148 static void XGetter(const Info& info, int offset) {
150  v8::Isolate* isolate = CcTest::isolate();
151  CHECK_EQ(isolate, info.GetIsolate());
152  CHECK_EQ(x_receiver, info.This());
153  info.GetReturnValue().Set(v8_num(x_register[offset]));
154 }
155 
156 
157 static void XGetter(Local<String> name,
159  CHECK_EQ(x_holder, info.Holder());
160  XGetter(info, 0);
161 }
162 
163 
164 static void XGetter(const v8::FunctionCallbackInfo<v8::Value>& info) {
165  CHECK_EQ(x_receiver, info.Holder());
166  XGetter(info, 1);
167 }
168 
169 
170 template<class Info>
171 static void XSetter(Local<Value> value, const Info& info, int offset) {
172  v8::Isolate* isolate = CcTest::isolate();
173  CHECK_EQ(isolate, info.GetIsolate());
174  CHECK_EQ(x_holder, info.This());
175  CHECK_EQ(x_holder, info.Holder());
176  x_register[offset] = value->Int32Value();
177  info.GetReturnValue().Set(v8_num(-1));
178 }
179 
180 
181 static void XSetter(Local<String> name,
182  Local<Value> value,
183  const v8::PropertyCallbackInfo<void>& info) {
184  XSetter(value, info, 0);
185 }
186 
187 
188 static void XSetter(const v8::FunctionCallbackInfo<v8::Value>& info) {
189  CHECK_EQ(1, info.Length());
190  XSetter(info[0], info, 1);
191 }
192 
193 
194 THREADED_TEST(AccessorIC) {
195  LocalContext context;
196  v8::Isolate* isolate = context->GetIsolate();
197  v8::HandleScope scope(isolate);
198  v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate);
199  obj->SetAccessor(v8_str("x0"), XGetter, XSetter);
200  obj->SetAccessorProperty(v8_str("x1"),
201  v8::FunctionTemplate::New(isolate, XGetter),
202  v8::FunctionTemplate::New(isolate, XSetter));
203  x_holder = obj->NewInstance();
204  context->Global()->Set(v8_str("holder"), x_holder);
205  x_receiver = v8::Object::New(isolate);
206  context->Global()->Set(v8_str("obj"), x_receiver);
208  "obj.__proto__ = holder;"
209  "var result = [];"
210  "var key_0 = 'x0';"
211  "var key_1 = 'x1';"
212  "for (var j = 0; j < 10; j++) {"
213  " var i = 4*j;"
214  " result.push(holder.x0 = i);"
215  " result.push(obj.x0);"
216  " result.push(holder.x1 = i + 1);"
217  " result.push(obj.x1);"
218  " result.push(holder[key_0] = i + 2);"
219  " result.push(obj[key_0]);"
220  " result.push(holder[key_1] = i + 3);"
221  " result.push(obj[key_1]);"
222  "}"
223  "result"));
224  CHECK_EQ(80, array->Length());
225  for (int i = 0; i < 80; i++) {
226  v8::Handle<Value> entry = array->Get(v8::Integer::New(isolate, i));
227  CHECK_EQ(v8::Integer::New(isolate, i/2), entry);
228  }
229 }
230 
231 
232 static void AccessorProhibitsOverwritingGetter(
233  Local<String> name,
236  info.GetReturnValue().Set(true);
237 }
238 
239 
240 THREADED_TEST(AccessorProhibitsOverwriting) {
241  LocalContext context;
242  v8::Isolate* isolate = context->GetIsolate();
243  v8::HandleScope scope(isolate);
244  Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
245  templ->SetAccessor(v8_str("x"),
246  AccessorProhibitsOverwritingGetter,
247  0,
250  v8::ReadOnly);
251  Local<v8::Object> instance = templ->NewInstance();
252  context->Global()->Set(v8_str("obj"), instance);
253  Local<Value> value = CompileRun(
254  "obj.__defineGetter__('x', function() { return false; });"
255  "obj.x");
256  CHECK(value->BooleanValue());
257  value = CompileRun(
258  "var setter_called = false;"
259  "obj.__defineSetter__('x', function() { setter_called = true; });"
260  "obj.x = 42;"
261  "setter_called");
262  CHECK(!value->BooleanValue());
263  value = CompileRun(
264  "obj2 = {};"
265  "obj2.__proto__ = obj;"
266  "obj2.__defineGetter__('x', function() { return false; });"
267  "obj2.x");
268  CHECK(value->BooleanValue());
269  value = CompileRun(
270  "var setter_called = false;"
271  "obj2 = {};"
272  "obj2.__proto__ = obj;"
273  "obj2.__defineSetter__('x', function() { setter_called = true; });"
274  "obj2.x = 42;"
275  "setter_called");
276  CHECK(!value->BooleanValue());
277 }
278 
279 
280 template <int C>
281 static void HandleAllocatingGetter(
282  Local<String> name,
285  for (int i = 0; i < C; i++)
286  v8::String::NewFromUtf8(info.GetIsolate(), "foo");
287  info.GetReturnValue().Set(v8::String::NewFromUtf8(info.GetIsolate(), "foo"));
288 }
289 
290 
291 THREADED_TEST(HandleScopePop) {
292  LocalContext context;
293  v8::Isolate* isolate = context->GetIsolate();
294  v8::HandleScope scope(isolate);
295  v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate);
296  obj->SetAccessor(v8_str("one"), HandleAllocatingGetter<1>);
297  obj->SetAccessor(v8_str("many"), HandleAllocatingGetter<1024>);
298  v8::Handle<v8::Object> inst = obj->NewInstance();
299  context->Global()->Set(v8::String::NewFromUtf8(isolate, "obj"), inst);
300  int count_before =
301  i::HandleScope::NumberOfHandles(reinterpret_cast<i::Isolate*>(isolate));
302  {
303  v8::HandleScope scope(isolate);
304  CompileRun(
305  "for (var i = 0; i < 1000; i++) {"
306  " obj.one;"
307  " obj.many;"
308  "}");
309  }
310  int count_after =
311  i::HandleScope::NumberOfHandles(reinterpret_cast<i::Isolate*>(isolate));
312  CHECK_EQ(count_before, count_after);
313 }
314 
315 static void CheckAccessorArgsCorrect(
316  Local<String> name,
318  CHECK(info.GetIsolate() == CcTest::isolate());
319  CHECK(info.This() == info.Holder());
320  CHECK(
321  info.Data()->Equals(v8::String::NewFromUtf8(CcTest::isolate(), "data")));
323  CHECK(info.GetIsolate() == CcTest::isolate());
324  CHECK(info.This() == info.Holder());
325  CHECK(
326  info.Data()->Equals(v8::String::NewFromUtf8(CcTest::isolate(), "data")));
328  CHECK(info.GetIsolate() == CcTest::isolate());
329  CHECK(info.This() == info.Holder());
330  CHECK(
331  info.Data()->Equals(v8::String::NewFromUtf8(CcTest::isolate(), "data")));
332  info.GetReturnValue().Set(17);
333 }
334 
335 
336 THREADED_TEST(DirectCall) {
337  LocalContext context;
338  v8::Isolate* isolate = context->GetIsolate();
339  v8::HandleScope scope(isolate);
340  v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate);
341  obj->SetAccessor(v8_str("xxx"),
342  CheckAccessorArgsCorrect,
343  NULL,
344  v8::String::NewFromUtf8(isolate, "data"));
345  v8::Handle<v8::Object> inst = obj->NewInstance();
346  context->Global()->Set(v8::String::NewFromUtf8(isolate, "obj"),
347  inst);
348  Local<Script> scr = v8::Script::Compile(
349  v8::String::NewFromUtf8(isolate, "obj.xxx"));
350  for (int i = 0; i < 10; i++) {
351  Local<Value> result = scr->Run();
352  CHECK(!result.IsEmpty());
353  CHECK_EQ(17, result->Int32Value());
354  }
355 }
356 
357 static void EmptyGetter(Local<String> name,
359  CheckAccessorArgsCorrect(name, info);
361  CheckAccessorArgsCorrect(name, info);
363 }
364 
365 
366 THREADED_TEST(EmptyResult) {
367  LocalContext context;
368  v8::Isolate* isolate = context->GetIsolate();
369  v8::HandleScope scope(isolate);
370  v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate);
371  obj->SetAccessor(v8_str("xxx"), EmptyGetter, NULL,
372  v8::String::NewFromUtf8(isolate, "data"));
373  v8::Handle<v8::Object> inst = obj->NewInstance();
374  context->Global()->Set(v8::String::NewFromUtf8(isolate, "obj"), inst);
375  Local<Script> scr =
376  v8::Script::Compile(v8::String::NewFromUtf8(isolate, "obj.xxx"));
377  for (int i = 0; i < 10; i++) {
378  Local<Value> result = scr->Run();
379  CHECK(result == v8::Undefined(isolate));
380  }
381 }
382 
383 
384 THREADED_TEST(NoReuseRegress) {
385  // Check that the IC generated for the one test doesn't get reused
386  // for the other.
387  v8::Isolate* isolate = CcTest::isolate();
388  v8::HandleScope scope(isolate);
389  {
390  v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate);
391  obj->SetAccessor(v8_str("xxx"), EmptyGetter, NULL,
392  v8::String::NewFromUtf8(isolate, "data"));
393  LocalContext context;
394  v8::Handle<v8::Object> inst = obj->NewInstance();
395  context->Global()->Set(v8::String::NewFromUtf8(isolate, "obj"), inst);
396  Local<Script> scr =
397  v8::Script::Compile(v8::String::NewFromUtf8(isolate, "obj.xxx"));
398  for (int i = 0; i < 2; i++) {
399  Local<Value> result = scr->Run();
400  CHECK(result == v8::Undefined(isolate));
401  }
402  }
403  {
404  v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate);
405  obj->SetAccessor(v8_str("xxx"),
406  CheckAccessorArgsCorrect,
407  NULL,
408  v8::String::NewFromUtf8(isolate, "data"));
409  LocalContext context;
410  v8::Handle<v8::Object> inst = obj->NewInstance();
411  context->Global()->Set(v8::String::NewFromUtf8(isolate, "obj"), inst);
412  Local<Script> scr =
413  v8::Script::Compile(v8::String::NewFromUtf8(isolate, "obj.xxx"));
414  for (int i = 0; i < 10; i++) {
415  Local<Value> result = scr->Run();
416  CHECK(!result.IsEmpty());
417  CHECK_EQ(17, result->Int32Value());
418  }
419  }
420 }
421 
422 static void ThrowingGetAccessor(
423  Local<String> name,
426  info.GetIsolate()->ThrowException(v8_str("g"));
427 }
428 
429 
430 static void ThrowingSetAccessor(Local<String> name,
431  Local<Value> value,
432  const v8::PropertyCallbackInfo<void>& info) {
433  info.GetIsolate()->ThrowException(value);
434 }
435 
436 
437 THREADED_TEST(Regress1054726) {
438  LocalContext env;
439  v8::Isolate* isolate = env->GetIsolate();
440  v8::HandleScope scope(isolate);
441  v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate);
442  obj->SetAccessor(v8_str("x"),
443  ThrowingGetAccessor,
444  ThrowingSetAccessor,
445  Local<Value>());
446 
447  env->Global()->Set(v8_str("obj"), obj->NewInstance());
448 
449  // Use the throwing property setter/getter in a loop to force
450  // the accessor ICs to be initialized.
451  v8::Handle<Value> result;
452  result = Script::Compile(v8_str(
453  "var result = '';"
454  "for (var i = 0; i < 5; i++) {"
455  " try { obj.x; } catch (e) { result += e; }"
456  "}; result"))->Run();
457  CHECK_EQ(v8_str("ggggg"), result);
458 
459  result = Script::Compile(String::NewFromUtf8(
460  isolate,
461  "var result = '';"
462  "for (var i = 0; i < 5; i++) {"
463  " try { obj.x = i; } catch (e) { result += e; }"
464  "}; result"))->Run();
465  CHECK_EQ(v8_str("01234"), result);
466 }
467 
468 
469 static void AllocGetter(Local<String> name,
472  info.GetReturnValue().Set(v8::Array::New(info.GetIsolate(), 1000));
473 }
474 
475 
477  LocalContext env;
478  v8::Isolate* isolate = env->GetIsolate();
479  v8::HandleScope scope(isolate);
480  v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate);
481  obj->SetAccessor(v8_str("xxx"), AllocGetter);
482  env->Global()->Set(v8_str("obj"), obj->NewInstance());
483  Script::Compile(String::NewFromUtf8(
484  isolate,
485  "var last = [];"
486  "for (var i = 0; i < 2048; i++) {"
487  " var result = obj.xxx;"
488  " result[0] = last;"
489  " last = result;"
490  "}"))->Run();
491 }
492 
493 
494 static void StackCheck(Local<String> name,
496  i::StackFrameIterator iter(reinterpret_cast<i::Isolate*>(info.GetIsolate()));
497  for (int i = 0; !iter.done(); i++) {
498  i::StackFrame* frame = iter.frame();
499  CHECK(i != 0 || (frame->type() == i::StackFrame::EXIT));
500  i::Code* code = frame->LookupCode();
501  CHECK(code->IsCode());
502  i::Address pc = frame->pc();
503  CHECK(code->contains(pc));
504  iter.Advance();
505  }
506 }
507 
508 
509 THREADED_TEST(StackIteration) {
510  LocalContext env;
511  v8::Isolate* isolate = env->GetIsolate();
512  v8::HandleScope scope(isolate);
513  v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate);
515  reinterpret_cast<i::Isolate*>(isolate));
516  obj->SetAccessor(v8_str("xxx"), StackCheck);
517  env->Global()->Set(v8_str("obj"), obj->NewInstance());
518  Script::Compile(String::NewFromUtf8(
519  isolate,
520  "function foo() {"
521  " return obj.xxx;"
522  "}"
523  "for (var i = 0; i < 100; i++) {"
524  " foo();"
525  "}"))->Run();
526 }
527 
528 
529 static void AllocateHandles(Local<String> name,
531  for (int i = 0; i < i::kHandleBlockSize + 1; i++) {
533  }
534  info.GetReturnValue().Set(v8::Integer::New(info.GetIsolate(), 100));
535 }
536 
537 
538 THREADED_TEST(HandleScopeSegment) {
539  // Check that we can return values past popping of handle scope
540  // segments.
541  LocalContext env;
542  v8::Isolate* isolate = env->GetIsolate();
543  v8::HandleScope scope(isolate);
544  v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate);
545  obj->SetAccessor(v8_str("xxx"), AllocateHandles);
546  env->Global()->Set(v8_str("obj"), obj->NewInstance());
547  v8::Handle<v8::Value> result = Script::Compile(String::NewFromUtf8(
548  isolate,
549  "var result;"
550  "for (var i = 0; i < 4; i++)"
551  " result = obj.xxx;"
552  "result;"))->Run();
553  CHECK_EQ(100, result->Int32Value());
554 }
555 
556 
559  array->Set(0, v8_str("regress"));
560  info.GetReturnValue().Set(array);
561 }
562 
563 
564 void JSONStringifyGetter(Local<String> name,
566  info.GetReturnValue().Set(v8_str("crbug-161028"));
567 }
568 
569 
570 THREADED_TEST(JSONStringifyNamedInterceptorObject) {
571  LocalContext env;
572  v8::Isolate* isolate = env->GetIsolate();
573  v8::HandleScope scope(isolate);
574 
575  v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate);
578  env->Global()->Set(v8_str("obj"), obj->NewInstance());
579  v8::Handle<v8::String> expected = v8_str("{\"regress\":\"crbug-161028\"}");
580  CHECK(CompileRun("JSON.stringify(obj)")->Equals(expected));
581 }
582 
583 
584 static v8::Local<v8::Context> expected_current_context;
585 static v8::Local<v8::Context> expected_calling_context;
586 
587 
588 static void check_contexts(const v8::FunctionCallbackInfo<v8::Value>& info) {
590  CHECK(expected_current_context == info.GetIsolate()->GetCurrentContext());
591  CHECK(expected_calling_context == info.GetIsolate()->GetCallingContext());
592 }
593 
594 
595 THREADED_TEST(AccessorPropertyCrossContext) {
596  LocalContext env;
597  v8::Isolate* isolate = env->GetIsolate();
598  v8::HandleScope scope(isolate);
599  v8::Handle<v8::Function> fun = v8::Function::New(isolate, check_contexts);
600  LocalContext switch_context;
601  switch_context->Global()->Set(v8_str("fun"), fun);
602  v8::TryCatch try_catch;
603  expected_current_context = env.local();
604  expected_calling_context = switch_context.local();
605  CompileRun(
606  "var o = Object.create(null, { n: { get:fun } });"
607  "for (var i = 0; i < 10; i++) o.n;");
608  CHECK(!try_catch.HasCaught());
609 }
610 
611 
612 THREADED_TEST(GlobalObjectAccessor) {
613  LocalContext env;
614  v8::Isolate* isolate = env->GetIsolate();
615  v8::HandleScope scope(isolate);
616  CompileRun(
617  "var set_value = 1;"
618  "Object.defineProperty(this.__proto__, 'x', {"
619  " get : function() { return this; },"
620  " set : function() { set_value = this; }"
621  "});"
622  "function getter() { return x; }"
623  "function setter() { x = 1; }"
624  "for (var i = 0; i < 4; i++) { getter(); setter(); }");
625  CHECK(v8::Utils::OpenHandle(*CompileRun("getter()"))->IsJSGlobalProxy());
626  CHECK(v8::Utils::OpenHandle(*CompileRun("set_value"))->IsJSGlobalProxy());
627 }
byte * Address
Definition: globals.h:186
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
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
static V8_INLINE Local< T > New(Isolate *isolate, Handle< T > that)
Definition: v8.h:5713
#define CHECK_EQ(expected, value)
Definition: checks.h:252
void CollectAllGarbage(int flags, const char *gc_reason=NULL, const GCCallbackFlags gc_callback_flags=kNoGCCallbackFlags)
Definition: heap.cc:731
V8_INLINE Isolate * GetIsolate() const
Definition: v8.h:6061
Local< Value > Get(Handle< Value > key)
Definition: api.cc:3139
Local< Object > NewInstance()
Definition: api.cc:5284
bool HasCaught() const
Definition: api.cc:1901
V8_INLINE ReturnValue< T > GetReturnValue() const
Definition: v8.h:6067
void JSONStringifyGetter(Local< String > name, const v8::PropertyCallbackInfo< v8::Value > &info)
V8_INLINE int Length() const
Definition: v8.h:6079
Local< ObjectTemplate > InstanceTemplate()
Definition: api.cc:1223
V8_INLINE Local< Object > Holder() const
Definition: v8.h:6530
static i::Heap * heap()
Definition: cctest.h:106
static Local< Integer > New(Isolate *isolate, int32_t value)
Definition: api.cc:6233
#define CHECK(condition)
Definition: checks.h:75
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
v8::Isolate * GetIsolate()
Definition: api.cc:5233
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
bool contains(byte *pc)
Definition: objects-inl.h:5892
int foo
HANDLE HANDLE LPSTACKFRAME64 StackFrame
static int NumberOfHandles(Isolate *isolate)
Definition: handles.cc:48
V8_INLINE Isolate * GetIsolate() const
Definition: v8.h:6512
static void Fuzz()
Definition: test-api.cc:13100
static const int kNoGCFlags
Definition: heap.h:1257
static Local< External > New(Isolate *isolate, void *value)
Definition: api.cc:5322
V8_INLINE Local< Object > Holder() const
Definition: v8.h:6048
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
int32_t Int32Value() const
Definition: api.cc:2929
static Local< Script > Compile(Handle< String > source, ScriptOrigin *origin=NULL, ScriptData *script_data=NULL)
Definition: api.cc:1832
static V8_INLINE Handle< T > Cast(Handle< S > that)
Definition: v8.h:297
Local< Object > Global()
Definition: api.cc:5239
const Register pc
V8_INLINE ReturnValue< T > GetReturnValue() const
Definition: v8.h:6536
Definition: v8.h:123
static Local< Array > New(Isolate *isolate, int length=0)
Definition: api.cc:5786
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< Object > New(Isolate *isolate)
Definition: api.cc:5589
V8_INLINE Local< Object > This() const
Definition: v8.h:6524
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 code(assertions) for debugging") DEFINE_bool(code_comments
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
int baz
const int kHandleBlockSize
Definition: api.h:616
void JSONStringifyEnumerator(const v8::PropertyCallbackInfo< v8::Array > &info)
static void ClearMentionedObjectCache(Isolate *isolate)
HeapObject * obj
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
uint32_t Length() const
Definition: api.cc:5800
v8::Local< v8::Context > local()
Definition: cctest.h:272
int bar
static Local< Function > New(Isolate *isolate, FunctionCallback callback, Local< Value > data=Local< Value >(), int length=0)
Definition: api.cc:3957
V8_INLINE Local< Value > Data() const
Definition: v8.h:6518
THREADED_TEST(PropertyHandler)
Definition: v8.h:124
bool Set(Handle< Value > key, Handle< Value > value, PropertyAttribute attribs=None)
Definition: api.cc:3044
static v8::Isolate * isolate()
Definition: cctest.h:96
static Local< String > NewFromUtf8(Isolate *isolate, const char *data, NewStringType type=kNormalString, int length=-1)
Definition: api.cc:5417