| OLD | NEW |
| 1 // Copyright 2007-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2009 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
| 15 // | 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include <limits.h> | 28 #include <limits.h> |
| 29 | 29 |
| 30 #define USE_NEW_QUERY_CALLBACKS |
| 31 |
| 30 #include "v8.h" | 32 #include "v8.h" |
| 31 | 33 |
| 32 #include "api.h" | 34 #include "api.h" |
| 33 #include "compilation-cache.h" | 35 #include "compilation-cache.h" |
| 34 #include "execution.h" | 36 #include "execution.h" |
| 35 #include "snapshot.h" | 37 #include "snapshot.h" |
| 36 #include "platform.h" | 38 #include "platform.h" |
| 37 #include "top.h" | 39 #include "top.h" |
| 38 #include "utils.h" | 40 #include "utils.h" |
| 39 #include "cctest.h" | 41 #include "cctest.h" |
| (...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 | 1115 |
| 1114 v8::Handle<v8::Boolean> CheckThisIndexedPropertyQuery( | 1116 v8::Handle<v8::Boolean> CheckThisIndexedPropertyQuery( |
| 1115 uint32_t index, | 1117 uint32_t index, |
| 1116 const AccessorInfo& info) { | 1118 const AccessorInfo& info) { |
| 1117 ApiTestFuzzer::Fuzz(); | 1119 ApiTestFuzzer::Fuzz(); |
| 1118 CHECK(info.This()->Equals(bottom)); | 1120 CHECK(info.This()->Equals(bottom)); |
| 1119 return v8::Handle<v8::Boolean>(); | 1121 return v8::Handle<v8::Boolean>(); |
| 1120 } | 1122 } |
| 1121 | 1123 |
| 1122 | 1124 |
| 1123 v8::Handle<v8::Boolean> CheckThisNamedPropertyQuery(Local<String> property, | 1125 v8::Handle<v8::Integer> CheckThisNamedPropertyQuery(Local<String> property, |
| 1124 const AccessorInfo& info) { | 1126 const AccessorInfo& info) { |
| 1125 ApiTestFuzzer::Fuzz(); | 1127 ApiTestFuzzer::Fuzz(); |
| 1126 CHECK(info.This()->Equals(bottom)); | 1128 CHECK(info.This()->Equals(bottom)); |
| 1127 return v8::Handle<v8::Boolean>(); | 1129 return v8::Handle<v8::Integer>(); |
| 1128 } | 1130 } |
| 1129 | 1131 |
| 1130 | 1132 |
| 1131 v8::Handle<v8::Boolean> CheckThisIndexedPropertyDeleter( | 1133 v8::Handle<v8::Boolean> CheckThisIndexedPropertyDeleter( |
| 1132 uint32_t index, | 1134 uint32_t index, |
| 1133 const AccessorInfo& info) { | 1135 const AccessorInfo& info) { |
| 1134 ApiTestFuzzer::Fuzz(); | 1136 ApiTestFuzzer::Fuzz(); |
| 1135 CHECK(info.This()->Equals(bottom)); | 1137 CHECK(info.This()->Equals(bottom)); |
| 1136 return v8::Handle<v8::Boolean>(); | 1138 return v8::Handle<v8::Boolean>(); |
| 1137 } | 1139 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1214 static v8::Handle<Value> PrePropertyHandlerGet(Local<String> key, | 1216 static v8::Handle<Value> PrePropertyHandlerGet(Local<String> key, |
| 1215 const AccessorInfo& info) { | 1217 const AccessorInfo& info) { |
| 1216 ApiTestFuzzer::Fuzz(); | 1218 ApiTestFuzzer::Fuzz(); |
| 1217 if (v8_str("pre")->Equals(key)) { | 1219 if (v8_str("pre")->Equals(key)) { |
| 1218 return v8_str("PrePropertyHandler: pre"); | 1220 return v8_str("PrePropertyHandler: pre"); |
| 1219 } | 1221 } |
| 1220 return v8::Handle<String>(); | 1222 return v8::Handle<String>(); |
| 1221 } | 1223 } |
| 1222 | 1224 |
| 1223 | 1225 |
| 1224 static v8::Handle<v8::Boolean> PrePropertyHandlerHas(Local<String> key, | 1226 static v8::Handle<v8::Integer> PrePropertyHandlerQuery(Local<String> key, |
| 1225 const AccessorInfo&) { | 1227 const AccessorInfo&) { |
| 1226 if (v8_str("pre")->Equals(key)) { | 1228 if (v8_str("pre")->Equals(key)) { |
| 1227 return v8::True(); | 1229 return v8::Integer::New(v8::None); |
| 1228 } | 1230 } |
| 1229 | 1231 |
| 1230 return v8::Handle<v8::Boolean>(); // do not intercept the call | 1232 return v8::Handle<v8::Integer>(); // do not intercept the call |
| 1231 } | 1233 } |
| 1232 | 1234 |
| 1233 | 1235 |
| 1234 THREADED_TEST(PrePropertyHandler) { | 1236 THREADED_TEST(PrePropertyHandler) { |
| 1235 v8::HandleScope scope; | 1237 v8::HandleScope scope; |
| 1236 v8::Handle<v8::FunctionTemplate> desc = v8::FunctionTemplate::New(); | 1238 v8::Handle<v8::FunctionTemplate> desc = v8::FunctionTemplate::New(); |
| 1237 desc->InstanceTemplate()->SetNamedPropertyHandler(PrePropertyHandlerGet, | 1239 desc->InstanceTemplate()->SetNamedPropertyHandler(PrePropertyHandlerGet, |
| 1238 0, | 1240 0, |
| 1239 PrePropertyHandlerHas); | 1241 PrePropertyHandlerQuery); |
| 1240 LocalContext env(NULL, desc->InstanceTemplate()); | 1242 LocalContext env(NULL, desc->InstanceTemplate()); |
| 1241 Script::Compile(v8_str( | 1243 Script::Compile(v8_str( |
| 1242 "var pre = 'Object: pre'; var on = 'Object: on';"))->Run(); | 1244 "var pre = 'Object: pre'; var on = 'Object: on';"))->Run(); |
| 1243 v8::Handle<Value> result_pre = Script::Compile(v8_str("pre"))->Run(); | 1245 v8::Handle<Value> result_pre = Script::Compile(v8_str("pre"))->Run(); |
| 1244 CHECK_EQ(v8_str("PrePropertyHandler: pre"), result_pre); | 1246 CHECK_EQ(v8_str("PrePropertyHandler: pre"), result_pre); |
| 1245 v8::Handle<Value> result_on = Script::Compile(v8_str("on"))->Run(); | 1247 v8::Handle<Value> result_on = Script::Compile(v8_str("on"))->Run(); |
| 1246 CHECK_EQ(v8_str("Object: on"), result_on); | 1248 CHECK_EQ(v8_str("Object: on"), result_on); |
| 1247 v8::Handle<Value> result_post = Script::Compile(v8_str("post"))->Run(); | 1249 v8::Handle<Value> result_post = Script::Compile(v8_str("post"))->Run(); |
| 1248 CHECK(result_post.IsEmpty()); | 1250 CHECK(result_post.IsEmpty()); |
| 1249 } | 1251 } |
| (...skipping 9369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10619 const char* code = | 10621 const char* code = |
| 10620 "(function() {" | 10622 "(function() {" |
| 10621 " for (var i = 0; i < 2*16; i++) {" | 10623 " for (var i = 0; i < 2*16; i++) {" |
| 10622 " %_GetFromCache(0, 'a' + i);" | 10624 " %_GetFromCache(0, 'a' + i);" |
| 10623 " };" | 10625 " };" |
| 10624 " return 'PASSED';" | 10626 " return 'PASSED';" |
| 10625 "})()"; | 10627 "})()"; |
| 10626 v8::internal::Heap::ClearJSFunctionResultCaches(); | 10628 v8::internal::Heap::ClearJSFunctionResultCaches(); |
| 10627 ExpectString(code, "PASSED"); | 10629 ExpectString(code, "PASSED"); |
| 10628 } | 10630 } |
| OLD | NEW |