37 using ::v8::ObjectTemplate;
44 using ::v8::AccessorInfo;
45 using ::v8::Extension;
48 const AccessorInfo&) {
57 fun_templ->InstanceTemplate()->SetAccessor(v8_str(
"foo"), handle_property);
59 Local<Function> fun = fun_templ->GetFunction();
60 env->
Global()->Set(v8_str(
"Fun"), fun);
61 Local<Script> getter = v8_compile(
"var obj = new Fun(); obj.foo;");
62 CHECK_EQ(900, getter->Run()->Int32Value());
63 Local<Script> setter = v8_compile(
"obj.foo = 901;");
64 CHECK_EQ(901, setter->Run()->Int32Value());
69 const AccessorInfo& info) {
73 return v8_num(*value);
77 static void SetIntValue(Local<String> property,
79 const AccessorInfo& info) {
82 *field = value->Int32Value();
106 v8_compile(
"foo = (++bar) + baz")->Run();
112 static int x_register = 0;
120 CHECK_EQ(isolate, info.GetIsolate());
123 return v8_num(x_register);
127 static void XSetter(Local<String> name,
129 const AccessorInfo& info) {
131 CHECK_EQ(isolate, info.GetIsolate());
134 x_register = value->Int32Value();
144 context->
Global()->Set(v8_str(
"holder"), x_holder);
146 context->
Global()->Set(v8_str(
"obj"), x_receiver);
148 "obj.__proto__ = holder;"
150 "for (var i = 0; i < 10; i++) {"
152 " result.push(obj.x);"
156 for (
int i = 0; i < 10; i++) {
165 const AccessorInfo& info) {
174 Local<ObjectTemplate> templ = ObjectTemplate::New();
175 templ->SetAccessor(v8_str(
"x"),
176 AccessorProhibitsOverwritingGetter,
181 Local<v8::Object> instance = templ->NewInstance();
182 context->
Global()->Set(v8_str(
"obj"), instance);
183 Local<Value> value = CompileRun(
184 "obj.__defineGetter__('x', function() { return false; });"
186 CHECK(value->BooleanValue());
188 "var setter_called = false;"
189 "obj.__defineSetter__('x', function() { setter_called = true; });"
192 CHECK(!value->BooleanValue());
195 "obj2.__proto__ = obj;"
196 "obj2.__defineGetter__('x', function() { return false; });"
198 CHECK(value->BooleanValue());
200 "var setter_called = false;"
202 "obj2.__proto__ = obj;"
203 "obj2.__defineSetter__('x', function() { setter_called = true; });"
206 CHECK(!value->BooleanValue());
212 const AccessorInfo& info) {
214 for (
int i = 0; i < C; i++)
223 obj->
SetAccessor(v8_str(
"one"), HandleAllocatingGetter<1>);
224 obj->
SetAccessor(v8_str(
"many"), HandleAllocatingGetter<1024>);
232 "for (var i = 0; i < 1000; i++) {"
238 CHECK_EQ(count_before, count_after);
242 const AccessorInfo& info) {
244 CHECK(info.This() == info.Holder());
248 CHECK(info.This() == info.Holder());
252 CHECK(info.This() == info.Holder());
261 CheckAccessorArgsCorrect,
268 for (
int i = 0; i < 10; i++) {
269 Local<Value> result = scr->Run();
270 CHECK(!result.IsEmpty());
276 const AccessorInfo& info) {
277 CheckAccessorArgsCorrect(name, info);
279 CheckAccessorArgsCorrect(name, info);
291 for (
int i = 0; i < 10; i++) {
292 Local<Value> result = scr->Run();
309 for (
int i = 0; i < 2; i++) {
310 Local<Value> result = scr->Run();
317 CheckAccessorArgsCorrect,
324 for (
int i = 0; i < 10; i++) {
325 Local<Value> result = scr->Run();
326 CHECK(!result.IsEmpty());
333 const AccessorInfo& info) {
339 static void ThrowingSetAccessor(Local<String> name,
341 const AccessorInfo& info) {
360 result = Script::Compile(v8_str(
362 "for (var i = 0; i < 5; i++) {"
363 " try { obj.x; } catch (e) { result += e; }"
364 "}; result"))->Run();
367 result = Script::Compile(String::New(
369 "for (var i = 0; i < 5; i++) {"
370 " try { obj.x = i; } catch (e) { result += e; }"
371 "}; result"))->Run();
377 const AccessorInfo& info) {
389 Script::Compile(String::New(
391 "for (var i = 0; i < 2048; i++) {"
392 " var result = obj.xxx;"
400 const AccessorInfo& info) {
401 i::StackFrameIterator iter;
402 for (
int i = 0; !iter.done(); i++) {
404 CHECK(i != 0 || (frame->type() == i::StackFrame::EXIT));
406 CHECK(code->IsCode());
422 Script::Compile(String::New(
426 "for (var i = 0; i < 100; i++) {"
433 const AccessorInfo& info) {
451 "for (var i = 0; i < 4; i++)"
static Isolate * GetCurrent()
static Local< Script > Compile(Handle< String > source, ScriptOrigin *origin=NULL, ScriptData *pre_data=NULL, Handle< String > script_data=Handle< String >())
static int NumberOfHandles()
#define CHECK_EQ(expected, value)
static Local< FunctionTemplate > New(InvocationCallback callback=0, Handle< Value > data=Handle< Value >(), Handle< Signature > signature=Handle< Signature >())
Handle< Boolean > V8EXPORT True()
V8EXPORT Local< Value > Get(Handle< Value > key)
Local< Object > NewInstance()
static V8EXPORT Local< String > New(const char *data, int length=-1)
Local< ObjectTemplate > InstanceTemplate()
static Handle< T > Cast(Handle< S > that)
HANDLE HANDLE LPSTACKFRAME64 StackFrame
static const int kNoGCFlags
void SetAccessor(Handle< String > name, AccessorGetter getter, AccessorSetter setter=0, Handle< Value > data=Handle< Value >(), AccessControl settings=DEFAULT, PropertyAttribute attribute=None, Handle< AccessorSignature > signature=Handle< AccessorSignature >())
V8EXPORT int32_t Int32Value() const
static Local< T > New(Handle< T > that)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra code(assertions) for debugging") DEFINE_bool(code_comments
const int kHandleBlockSize
static V8EXPORT Local< Integer > New(int32_t value)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit 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 SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available 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 MIPS FPU instructions if NULL
Handle< Primitive > V8EXPORT Undefined()
static void ClearMentionedObjectCache()
V8EXPORT uint32_t Length() const
static V8EXPORT Local< External > New(void *value)
Handle< Value > V8EXPORT ThrowException(Handle< Value > exception)
THREADED_TEST(PropertyHandler)
static V8EXPORT Local< Object > New()