| OLD | NEW | 
|      1 // Copyright 2012 the V8 project authors. All rights reserved. |      1 // Copyright 2012 the V8 project authors. All rights reserved. | 
|      2 // Redistribution and use in source and binary forms, with or without |      2 // Redistribution and use in source and binary forms, with or without | 
|      3 // modification, are permitted provided that the following conditions are |      3 // modification, are permitted provided that the following conditions are | 
|      4 // met: |      4 // met: | 
|      5 // |      5 // | 
|      6 //     * Redistributions of source code must retain the above copyright |      6 //     * Redistributions of source code must retain the above copyright | 
|      7 //       notice, this list of conditions and the following disclaimer. |      7 //       notice, this list of conditions and the following disclaimer. | 
|      8 //     * Redistributions in binary form must reproduce the above |      8 //     * Redistributions in binary form must reproduce the above | 
|      9 //       copyright notice, this list of conditions and the following |      9 //       copyright notice, this list of conditions and the following | 
|     10 //       disclaimer in the documentation and/or other materials provided |     10 //       disclaimer in the documentation and/or other materials provided | 
| (...skipping 9784 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   9795     CHECK(!try_catch.HasCaught()); |   9795     CHECK(!try_catch.HasCaught()); | 
|   9796     CHECK(value->IsObject()); |   9796     CHECK(value->IsObject()); | 
|   9797  |   9797  | 
|   9798     Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate); |   9798     Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate); | 
|   9799     instance_template->SetCallAsFunctionHandler(FakeConstructorCallback); |   9799     instance_template->SetCallAsFunctionHandler(FakeConstructorCallback); | 
|   9800     Local<Object> instance2 = instance_template->NewInstance(); |   9800     Local<Object> instance2 = instance_template->NewInstance(); | 
|   9801     context->Global()->Set(v8_str("obj5"), instance2); |   9801     context->Global()->Set(v8_str("obj5"), instance2); | 
|   9802     CHECK(!try_catch.HasCaught()); |   9802     CHECK(!try_catch.HasCaught()); | 
|   9803  |   9803  | 
|   9804     CHECK(instance2->IsObject()); |   9804     CHECK(instance2->IsObject()); | 
|   9805     CHECK(!instance2->IsFunction()); |   9805     CHECK(instance2->IsFunction()); | 
|   9806  |   9806  | 
|   9807     value = CompileRun("new obj5(28)"); |   9807     value = CompileRun("new obj5(28)"); | 
|   9808     CHECK(!try_catch.HasCaught()); |   9808     CHECK(!try_catch.HasCaught()); | 
|   9809     CHECK(!value->IsObject()); |   9809     CHECK(!value->IsObject()); | 
|   9810  |   9810  | 
|   9811     Local<Value> args2[] = {v8_num(28)}; |   9811     Local<Value> args2[] = {v8_num(28)}; | 
|   9812     value = instance2->CallAsConstructor(1, args2); |   9812     value = instance2->CallAsConstructor(1, args2); | 
|   9813     CHECK(!try_catch.HasCaught()); |   9813     CHECK(!try_catch.HasCaught()); | 
|   9814     CHECK(!value->IsObject()); |   9814     CHECK(!value->IsObject()); | 
|   9815   } |   9815   } | 
| (...skipping 9808 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  19624   v8::Isolate* isolate = env->GetIsolate(); |  19624   v8::Isolate* isolate = env->GetIsolate(); | 
|  19625   v8::HandleScope scope(isolate); |  19625   v8::HandleScope scope(isolate); | 
|  19626   Local<Object> data = v8::Object::New(isolate); |  19626   Local<Object> data = v8::Object::New(isolate); | 
|  19627   function_new_expected_env = data; |  19627   function_new_expected_env = data; | 
|  19628   Local<Function> func = Function::New(isolate, FunctionNewCallback, data); |  19628   Local<Function> func = Function::New(isolate, FunctionNewCallback, data); | 
|  19629   env->Global()->Set(v8_str("func"), func); |  19629   env->Global()->Set(v8_str("func"), func); | 
|  19630   Local<Value> result = CompileRun("func();"); |  19630   Local<Value> result = CompileRun("func();"); | 
|  19631   CHECK(v8::Integer::New(isolate, 17)->Equals(result)); |  19631   CHECK(v8::Integer::New(isolate, 17)->Equals(result)); | 
|  19632   i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |  19632   i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 
|  19633   // Verify function not cached |  19633   // Verify function not cached | 
|  19634   auto serial_number = handle(i::Smi::cast(v8::Utils::OpenHandle(*func) |  19634   auto serial_number = handle( | 
|  19635                                                ->shared() |  19635       i::Smi::cast(i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*func)) | 
|  19636                                                ->get_api_func_data() |  19636                        ->shared() | 
|  19637                                                ->serial_number()), |  19637                        ->get_api_func_data() | 
|  19638                               i_isolate); |  19638                        ->serial_number()), | 
 |  19639       i_isolate); | 
|  19639   auto cache = i_isolate->function_cache(); |  19640   auto cache = i_isolate->function_cache(); | 
|  19640   CHECK(cache->Lookup(serial_number)->IsTheHole()); |  19641   CHECK(cache->Lookup(serial_number)->IsTheHole()); | 
|  19641   // Verify that each Function::New creates a new function instance |  19642   // Verify that each Function::New creates a new function instance | 
|  19642   Local<Object> data2 = v8::Object::New(isolate); |  19643   Local<Object> data2 = v8::Object::New(isolate); | 
|  19643   function_new_expected_env = data2; |  19644   function_new_expected_env = data2; | 
|  19644   Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2); |  19645   Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2); | 
|  19645   CHECK(!func2->IsNull()); |  19646   CHECK(!func2->IsNull()); | 
|  19646   CHECK(!func->Equals(func2)); |  19647   CHECK(!func->Equals(func2)); | 
|  19647   env->Global()->Set(v8_str("func2"), func2); |  19648   env->Global()->Set(v8_str("func2"), func2); | 
|  19648   Local<Value> result2 = CompileRun("func2();"); |  19649   Local<Value> result2 = CompileRun("func2();"); | 
| (...skipping 2283 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  21932  |  21933  | 
|  21933   Local<ObjectTemplate> object_template = v8::ObjectTemplate::New(isolate); |  21934   Local<ObjectTemplate> object_template = v8::ObjectTemplate::New(isolate); | 
|  21934   object_template->SetIntrinsicDataProperty(v8_str("values"), |  21935   object_template->SetIntrinsicDataProperty(v8_str("values"), | 
|  21935                                             v8::kArrayProto_values); |  21936                                             v8::kArrayProto_values); | 
|  21936   Local<Object> object = object_template->NewInstance(); |  21937   Local<Object> object = object_template->NewInstance(); | 
|  21937  |  21938  | 
|  21938   env->Global()->Set(v8_str("obj1"), object); |  21939   env->Global()->Set(v8_str("obj1"), object); | 
|  21939   ExpectString("typeof obj1.values", "function"); |  21940   ExpectString("typeof obj1.values", "function"); | 
|  21940  |  21941  | 
|  21941   auto values = Local<Function>::Cast(object->Get(v8_str("values"))); |  21942   auto values = Local<Function>::Cast(object->Get(v8_str("values"))); | 
|  21942   auto fn = v8::Utils::OpenHandle(*values); |  21943   auto fn = i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*values)); | 
|  21943   auto ctx = v8::Utils::OpenHandle(*env.local()); |  21944   auto ctx = v8::Utils::OpenHandle(*env.local()); | 
|  21944   CHECK_EQ(fn->GetCreationContext(), *ctx); |  21945   CHECK_EQ(fn->GetCreationContext(), *ctx); | 
|  21945  |  21946  | 
|  21946   { |  21947   { | 
|  21947     LocalContext env2; |  21948     LocalContext env2; | 
|  21948     Local<Object> object2 = object_template->NewInstance(); |  21949     Local<Object> object2 = object_template->NewInstance(); | 
|  21949     env2->Global()->Set(v8_str("obj2"), object2); |  21950     env2->Global()->Set(v8_str("obj2"), object2); | 
|  21950     ExpectString("typeof obj2.values", "function"); |  21951     ExpectString("typeof obj2.values", "function"); | 
|  21951     CHECK_NE(*object->Get(v8_str("values")), *object2->Get(v8_str("values"))); |  21952     CHECK_NE(*object->Get(v8_str("values")), *object2->Get(v8_str("values"))); | 
|  21952  |  21953  | 
|  21953     auto values2 = Local<Function>::Cast(object2->Get(v8_str("values"))); |  21954     auto values2 = Local<Function>::Cast(object2->Get(v8_str("values"))); | 
|  21954     auto fn2 = v8::Utils::OpenHandle(*values2); |  21955     auto fn2 = i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*values2)); | 
|  21955     auto ctx2 = v8::Utils::OpenHandle(*env2.local()); |  21956     auto ctx2 = v8::Utils::OpenHandle(*env2.local()); | 
|  21956     CHECK_EQ(fn2->GetCreationContext(), *ctx2); |  21957     CHECK_EQ(fn2->GetCreationContext(), *ctx2); | 
|  21957   } |  21958   } | 
|  21958 } |  21959 } | 
| OLD | NEW |